e354a5
commit 28c13ae5bbc81aa2ae67890ce53e65257d4703a4
e354a5
Author: H.J. Lu <hjl.tools@gmail.com>
e354a5
Date:   Mon Jul 6 06:57:08 2020 -0700
e354a5
e354a5
    x86: Detect Extended Feature Disable (XFD)
e354a5
    
e354a5
    An extension called extended feature disable (XFD) is an extension added
e354a5
    for Intel AMX to the XSAVE feature set that allows an operating system
e354a5
    to enable a feature while preventing specific user threads from using
e354a5
    the feature.
e354a5
e354a5
diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h
e354a5
index 535b3cb2d25b245b..e7ea9e8ece3e8211 100644
e354a5
--- a/sysdeps/x86/cpu-features.h
e354a5
+++ b/sysdeps/x86/cpu-features.h
e354a5
@@ -393,6 +393,7 @@ extern const struct cpu_features *__get_cpu_features (void)
e354a5
 #define bit_cpu_XSAVEC		(1u << 1)
e354a5
 #define bit_cpu_XGETBV_ECX_1	(1u << 2)
e354a5
 #define bit_cpu_XSAVES		(1u << 3)
e354a5
+#define bit_cpu_XFD		(1u << 4)
e354a5
 
e354a5
 /* COMMON_CPUID_INDEX_80000007.  */
e354a5
 
e354a5
@@ -578,6 +579,7 @@ extern const struct cpu_features *__get_cpu_features (void)
e354a5
 #define index_cpu_XSAVEC	COMMON_CPUID_INDEX_D_ECX_1
e354a5
 #define index_cpu_XGETBV_ECX_1	COMMON_CPUID_INDEX_D_ECX_1
e354a5
 #define index_cpu_XSAVES	COMMON_CPUID_INDEX_D_ECX_1
e354a5
+#define index_cpu_XFD		COMMON_CPUID_INDEX_D_ECX_1
e354a5
 
e354a5
 /* COMMON_CPUID_INDEX_80000007.  */
e354a5
 
e354a5
@@ -763,6 +765,7 @@ extern const struct cpu_features *__get_cpu_features (void)
e354a5
 #define reg_XSAVEC		eax
e354a5
 #define reg_XGETBV_ECX_1	eax
e354a5
 #define reg_XSAVES		eax
e354a5
+#define reg_XFD			eax
e354a5
 
e354a5
 /* COMMON_CPUID_INDEX_80000007.  */
e354a5
 
e354a5
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
e354a5
index c4d91be3a48de886..c56f309ba0736c0d 100644
e354a5
--- a/sysdeps/x86/tst-get-cpu-features.c
e354a5
+++ b/sysdeps/x86/tst-get-cpu-features.c
e354a5
@@ -212,6 +212,7 @@ do_test (void)
e354a5
   CHECK_CPU_FEATURE (XSAVEC);
e354a5
   CHECK_CPU_FEATURE (XGETBV_ECX_1);
e354a5
   CHECK_CPU_FEATURE (XSAVES);
e354a5
+  CHECK_CPU_FEATURE (XFD);
e354a5
   CHECK_CPU_FEATURE (INVARIANT_TSC);
e354a5
   CHECK_CPU_FEATURE (WBNOINVD);
e354a5
   CHECK_CPU_FEATURE (AVX512_BF16);