x86: Detect Extended Feature Disable (XFD)

Message ID 20200706140504.2170889-1-hjl.tools@gmail.com
State New
Headers show
Series
  • x86: Detect Extended Feature Disable (XFD)
Related show

Commit Message

Alejandro Colomar via Libc-alpha July 6, 2020, 2:05 p.m.
An extension called extended feature disable (XFD) is an extension added
for Intel AMX to the XSAVE feature set that allows an operating system
to enable a feature while preventing specific user threads from using
the feature.
---
 sysdeps/x86/cpu-features.h         | 3 +++
 sysdeps/x86/tst-get-cpu-features.c | 1 +
 2 files changed, 4 insertions(+)

-- 
2.26.2

Comments

Alejandro Colomar via Libc-alpha July 6, 2020, 2:49 p.m. | #1
On Mon, Jul 6, 2020 at 7:05 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>

> An extension called extended feature disable (XFD) is an extension added

> for Intel AMX to the XSAVE feature set that allows an operating system

> to enable a feature while preventing specific user threads from using

> the feature.

> ---

>  sysdeps/x86/cpu-features.h         | 3 +++

>  sysdeps/x86/tst-get-cpu-features.c | 1 +

>  2 files changed, 4 insertions(+)

>

> diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h

> index f25df778cc..bc425462d6 100644

> --- a/sysdeps/x86/cpu-features.h

> +++ b/sysdeps/x86/cpu-features.h

> @@ -393,6 +393,7 @@ extern const struct cpu_features *__get_cpu_features (void)

>  #define bit_cpu_XSAVEC         (1u << 1)

>  #define bit_cpu_XGETBV_ECX_1   (1u << 2)

>  #define bit_cpu_XSAVES         (1u << 3)

> +#define bit_cpu_XFD            (1u << 4)

>

>  /* COMMON_CPUID_INDEX_80000007.  */

>

> @@ -578,6 +579,7 @@ extern const struct cpu_features *__get_cpu_features (void)

>  #define index_cpu_XSAVEC       COMMON_CPUID_INDEX_D_ECX_1

>  #define index_cpu_XGETBV_ECX_1 COMMON_CPUID_INDEX_D_ECX_1

>  #define index_cpu_XSAVES       COMMON_CPUID_INDEX_D_ECX_1

> +#define index_cpu_XFD          COMMON_CPUID_INDEX_D_ECX_1

>

>  /* COMMON_CPUID_INDEX_80000007.  */

>

> @@ -763,6 +765,7 @@ extern const struct cpu_features *__get_cpu_features (void)

>  #define reg_XSAVEC             eax

>  #define reg_XGETBV_ECX_1       eax

>  #define reg_XSAVES             eax

> +#define reg_XFD                        eax

>

>  /* COMMON_CPUID_INDEX_80000007.  */

>

> diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c

> index dafd66434c..2cff2e86ba 100644

> --- a/sysdeps/x86/tst-get-cpu-features.c

> +++ b/sysdeps/x86/tst-get-cpu-features.c

> @@ -214,6 +214,7 @@ do_test (void)

>    CHECK_CPU_FEATURE (XSAVEC);

>    CHECK_CPU_FEATURE (XGETBV_ECX_1);

>    CHECK_CPU_FEATURE (XSAVES);

> +  CHECK_CPU_FEATURE (XFD);

>    CHECK_CPU_FEATURE (INVARIANT_TSC);

>    CHECK_CPU_FEATURE (WBNOINVD);

>    CHECK_CPU_FEATURE (AVX512_BF16);

> --

> 2.26.2

>


I checked it in.

-- 
H.J.

Patch

diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h
index f25df778cc..bc425462d6 100644
--- a/sysdeps/x86/cpu-features.h
+++ b/sysdeps/x86/cpu-features.h
@@ -393,6 +393,7 @@  extern const struct cpu_features *__get_cpu_features (void)
 #define bit_cpu_XSAVEC		(1u << 1)
 #define bit_cpu_XGETBV_ECX_1	(1u << 2)
 #define bit_cpu_XSAVES		(1u << 3)
+#define bit_cpu_XFD		(1u << 4)
 
 /* COMMON_CPUID_INDEX_80000007.  */
 
@@ -578,6 +579,7 @@  extern const struct cpu_features *__get_cpu_features (void)
 #define index_cpu_XSAVEC	COMMON_CPUID_INDEX_D_ECX_1
 #define index_cpu_XGETBV_ECX_1	COMMON_CPUID_INDEX_D_ECX_1
 #define index_cpu_XSAVES	COMMON_CPUID_INDEX_D_ECX_1
+#define index_cpu_XFD		COMMON_CPUID_INDEX_D_ECX_1
 
 /* COMMON_CPUID_INDEX_80000007.  */
 
@@ -763,6 +765,7 @@  extern const struct cpu_features *__get_cpu_features (void)
 #define reg_XSAVEC		eax
 #define reg_XGETBV_ECX_1	eax
 #define reg_XSAVES		eax
+#define reg_XFD			eax
 
 /* COMMON_CPUID_INDEX_80000007.  */
 
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
index dafd66434c..2cff2e86ba 100644
--- a/sysdeps/x86/tst-get-cpu-features.c
+++ b/sysdeps/x86/tst-get-cpu-features.c
@@ -214,6 +214,7 @@  do_test (void)
   CHECK_CPU_FEATURE (XSAVEC);
   CHECK_CPU_FEATURE (XGETBV_ECX_1);
   CHECK_CPU_FEATURE (XSAVES);
+  CHECK_CPU_FEATURE (XFD);
   CHECK_CPU_FEATURE (INVARIANT_TSC);
   CHECK_CPU_FEATURE (WBNOINVD);
   CHECK_CPU_FEATURE (AVX512_BF16);