From patchwork Tue Jul 25 19:04:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1812832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=d5YKs2Jn; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R9RKZ5q25z1ydq for ; Wed, 26 Jul 2023 05:04:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A8092385AF9F for ; Tue, 25 Jul 2023 19:04:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A8092385AF9F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690311871; bh=ZMZ3+Fg8G+XWKsTjemqQep2OJEB3LyY4pdYqsby9fUI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=d5YKs2JnNX9IXPpk/3IgheUuKeY8yDZd8k80bPeBJwqtc05aiB8x8x+wzvH/snRbM 4SBcFzPE3Pjl57AoHyU/glRQfULJPC3raGY7AYfje0px2t8PKcpTVAX6P7LMck8sLm a2Sa9zZj8JtAN3GfS2E9FMUCG1EKJzwmzhzUjar8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id CAE673858C3A for ; Tue, 25 Jul 2023 19:04:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CAE673858C3A Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-666ed230c81so5499463b3a.0 for ; Tue, 25 Jul 2023 12:04:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690311854; x=1690916654; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZMZ3+Fg8G+XWKsTjemqQep2OJEB3LyY4pdYqsby9fUI=; b=iY1IzGDCsNJSW2JeZfWlKeycZhgQw3DBJMKWkk8BPBnMXsSBm20MjArpmNNwrn++Ay H/5alzVAnsYgK6Pomm2b8e7O2S7iQ+40r4QMZPmvLtAgW+1PE8p2zj45P+uUJNepZiK1 XDvmJfNXq3mXaMY+EO+lNZVhXAvGgGAN2uWsZ593J2BoO7rlpOGesJp61aWfZMClFnyn FB1zDOnml9ayLvJGhDfWQ2IWEKgZCuE0osPBYnfYZLBUyHc4xRJ1KstQJqSPSNIWOFI8 5uMbdYyrqA3fAXkgJPoyKWiFJbfmBN9daydXGQG/8Q8SjEuh13bbLQPwQ233ZHXPD7xZ 1LTg== X-Gm-Message-State: ABy/qLZfqb5q69uqCB2acrbpU0xxLO0bKSGoPdWajE1asJDj++LZ/OB/ Q8qJjVb1w2ykl7fMXIJdafuiSHjslgc= X-Google-Smtp-Source: APBJJlHVV1o9Sj5P+ZopTU9BDKMxUamnE19jZZXRtIpfNGqjVNMIgnCtlLfn2opAHGzcueu4OqPO6Q== X-Received: by 2002:a05:6a20:748b:b0:138:60e:9ba with SMTP id p11-20020a056a20748b00b00138060e09bamr17730196pzd.29.1690311853605; Tue, 25 Jul 2023 12:04:13 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.59.161.42]) by smtp.gmail.com with ESMTPSA id q18-20020a639812000000b00563709c8647sm11006209pgd.7.2023.07.25.12.04.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 12:04:13 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id DCB8A74032A for ; Tue, 25 Jul 2023 12:04:11 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH] : Add APX support Date: Tue, 25 Jul 2023 12:04:11 -0700 Message-ID: <20230725190411.2192265-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3025.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Libc-alpha" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Add support for Intel Advanced Performance Extensions: https://www.intel.com/content/www/us/en/developer/articles/technical/advanced-performance-extensions-apx.html to . --- manual/platform.texi | 3 +++ sysdeps/x86/bits/platform/x86.h | 1 + sysdeps/x86/cpu-features.c | 4 ++++ sysdeps/x86/include/cpu-features.h | 4 ++++ sysdeps/x86/tst-get-cpu-features.c | 2 ++ 5 files changed, 14 insertions(+) diff --git a/manual/platform.texi b/manual/platform.texi index c6ed73cb97..2a2d557067 100644 --- a/manual/platform.texi +++ b/manual/platform.texi @@ -209,6 +209,9 @@ The supported processor features are: @item @code{AMX_TILE} -- Tile architecture. +@item +@code{APX_F} -- The APX instruction extensions. + @item @code{ARCH_CAPABILITIES} -- IA32_ARCH_CAPABILITIES MSR. diff --git a/sysdeps/x86/bits/platform/x86.h b/sysdeps/x86/bits/platform/x86.h index 6555f9b91d..88ca071aa7 100644 --- a/sysdeps/x86/bits/platform/x86.h +++ b/sysdeps/x86/bits/platform/x86.h @@ -312,6 +312,7 @@ enum x86_cpu_AVX_NE_CONVERT = x86_cpu_index_7_ecx_1_edx + 5, x86_cpu_AMX_COMPLEX = x86_cpu_index_7_ecx_1_edx + 8, x86_cpu_PREFETCHI = x86_cpu_index_7_ecx_1_edx + 14, + x86_cpu_APX_F = x86_cpu_index_7_ecx_1_edx + 21, x86_cpu_index_19_ebx = (CPUID_INDEX_19 * 8 * 4 * sizeof (unsigned int) diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c index 9ac195810f..376e3c7501 100644 --- a/sysdeps/x86/cpu-features.c +++ b/sysdeps/x86/cpu-features.c @@ -226,6 +226,10 @@ update_active (struct cpu_features *cpu_features) CPU_FEATURE_SET_ACTIVE (cpu_features, AMX_COMPLEX); } + /* Is AVX state usable? */ + if ((xcrlow & bit_AVX_state) != 0) + CPU_FEATURE_SET_ACTIVE (cpu_features, APX_F); + /* These features are usable only when OSXSAVE is enabled. */ CPU_FEATURE_SET (cpu_features, XSAVE); CPU_FEATURE_SET_ACTIVE (cpu_features, XSAVEOPT); diff --git a/sysdeps/x86/include/cpu-features.h b/sysdeps/x86/include/cpu-features.h index c740e1a5fc..68db82f732 100644 --- a/sysdeps/x86/include/cpu-features.h +++ b/sysdeps/x86/include/cpu-features.h @@ -319,6 +319,7 @@ enum #define bit_cpu_AVX_NE_CONVERT (1u << 5) #define bit_cpu_AMX_COMPLEX (1u << 8) #define bit_cpu_PREFETCHI (1u << 14) +#define bit_cpu_APX_F (1u << 21) /* CPUID_INDEX_19. */ @@ -562,6 +563,7 @@ enum #define index_cpu_AVX_NE_CONVERT CPUID_INDEX_7_ECX_1 #define index_cpu_AMX_COMPLEX CPUID_INDEX_7_ECX_1 #define index_cpu_PREFETCHI CPUID_INDEX_7_ECX_1 +#define index_cpu_APX_F CPUID_INDEX_7_ECX_1 /* CPUID_INDEX_19. */ @@ -807,6 +809,7 @@ enum #define reg_AVX_NE_CONVERT edx #define reg_AMX_COMPLEX edx #define reg_PREFETCHI edx +#define reg_APX_F edx /* CPUID_INDEX_19. */ @@ -845,6 +848,7 @@ enum #define bit_ZMM16_31_state (1u << 7) #define bit_XTILECFG_state (1u << 17) #define bit_XTILEDATA_state (1u << 18) +#define bit_AVX_state (1u << 19) enum cpu_features_kind { diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c index 1bd7e0be53..b27fa7324a 100644 --- a/sysdeps/x86/tst-get-cpu-features.c +++ b/sysdeps/x86/tst-get-cpu-features.c @@ -219,6 +219,7 @@ do_test (void) CHECK_CPU_FEATURE_PRESENT (AVX_NE_CONVERT); CHECK_CPU_FEATURE_PRESENT (AMX_COMPLEX); CHECK_CPU_FEATURE_PRESENT (PREFETCHI); + CHECK_CPU_FEATURE_PRESENT (APX_F); CHECK_CPU_FEATURE_PRESENT (AESKLE); CHECK_CPU_FEATURE_PRESENT (WIDE_KL); CHECK_CPU_FEATURE_PRESENT (PTWRITE); @@ -390,6 +391,7 @@ do_test (void) CHECK_CPU_FEATURE_ACTIVE (AVX_NE_CONVERT); CHECK_CPU_FEATURE_ACTIVE (AMX_COMPLEX); CHECK_CPU_FEATURE_ACTIVE (PREFETCHI); + CHECK_CPU_FEATURE_ACTIVE (APX_F); CHECK_CPU_FEATURE_ACTIVE (AESKLE); CHECK_CPU_FEATURE_ACTIVE (WIDE_KL); CHECK_CPU_FEATURE_ACTIVE (PTWRITE);