From patchwork Wed Jul 26 15:20:16 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: 73234 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8CE813858C52 for ; Wed, 26 Jul 2023 15:20:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8CE813858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1690384852; bh=6RJJsfhI5lhDGEre2/4AUqIodbYdvQpkzYDcI83g3XI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=WIDEbqbjfiYgFvcH4HPCYlU5Yij8dVZL7d+jyOCRX3c8C2JmNyQUUvJT+41K2NLc4 4S+U7Ibv468Q7Uvbm2e4KPBdh/6FeifLEdY7EsbHgvSgLLeqGypjAXXpmZGSOMb0Yc /K1C93RxjY8rm+UTTO+oh1wz/WH86enQnmQBEDq8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 412773858C52 for ; Wed, 26 Jul 2023 15:20:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 412773858C52 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-686ea67195dso253517b3a.2 for ; Wed, 26 Jul 2023 08:20:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690384818; x=1690989618; 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=6RJJsfhI5lhDGEre2/4AUqIodbYdvQpkzYDcI83g3XI=; b=cgmwUUv6rt7q0dby/gyTGkW2q9+LYOphZ3YZ5X3qud2qgwAD0Y9+8+3AGh7jTqGYK8 /BqBOL+P31EGyVem0N90wEFVG9LLJg7hfsoHW/MNkwgfTmapCoFQv5leo4CQfMKqWjp0 3JRxaDQn+2fhbP7IWrbA0gc9Z454p5JsPzF5+TV9b47+BrxaK771oG8yCb5qNC7chwYw nTzR1o4KzLPbnN8kkUUKYM92ya4qcVX2vZsIsQFpGl2h2rcNVFVdNF5RX39dQvggTNT9 E4VJFCJ4teBChg2QpWyZrml/2OCwCZOPrMvb60bLN1QAzxr0zHn6Ivrh5/2RUzXNZWa8 2qKQ== X-Gm-Message-State: ABy/qLZBYWvtIVMgPV/ft5IW/LZpMIV2nqvoxqrauaIEL9yJRJXFI2sk Qh+tPCkzoDJefCInB7dUclhuMLZkjAA= X-Google-Smtp-Source: APBJJlGw+SE3iKoe2yy2QDWyQ+xBWM5jMiZ0Yg0DCqBhD9dtyDTP+A49COt7ya4YYcVUep+jMoAeEA== X-Received: by 2002:a05:6a20:3208:b0:13b:7757:d5b6 with SMTP id hl8-20020a056a20320800b0013b7757d5b6mr1745492pzc.57.1690384817897; Wed, 26 Jul 2023 08:20:17 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.59.161.42]) by smtp.gmail.com with ESMTPSA id x9-20020a63aa49000000b0056334a7b9b2sm12907672pgo.33.2023.07.26.08.20.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 08:20:17 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 71335740166 for ; Wed, 26 Jul 2023 08:20:16 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v2] : Add APX support Date: Wed, 26 Jul 2023 08:20:16 -0700 Message-ID: <20230726152016.2246387-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+patchwork=sourceware.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..badf088874 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); } + /* APX is usable only if the APX state is supported by kernel. */ + if ((xcrlow & bit_APX_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..eb30d342a6 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_APX_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);