|
|
b1dca6 |
commit f2c679d4b2c73a95f437c705f960a4af1fa23498
|
|
|
b1dca6 |
Author: H.J. Lu <hjl.tools@gmail.com>
|
|
|
b1dca6 |
Date: Tue Sep 15 05:49:27 2020 -0700
|
|
|
b1dca6 |
|
|
|
b1dca6 |
<sys/platform/x86.h>: Add Intel Key Locker support
|
|
|
b1dca6 |
|
|
|
b1dca6 |
Add Intel Key Locker:
|
|
|
b1dca6 |
|
|
|
b1dca6 |
https://software.intel.com/content/www/us/en/develop/download/intel-key-locker-specification.html
|
|
|
b1dca6 |
|
|
|
b1dca6 |
support to <sys/platform/x86.h>. Intel Key Locker has
|
|
|
b1dca6 |
|
|
|
b1dca6 |
1. KL: AES Key Locker instructions.
|
|
|
b1dca6 |
2. WIDE_KL: AES wide Key Locker instructions.
|
|
|
b1dca6 |
3. AESKLE: AES Key Locker instructions are enabled by OS.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
Applications should use
|
|
|
b1dca6 |
|
|
|
b1dca6 |
if (CPU_FEATURE_USABLE (KL))
|
|
|
b1dca6 |
|
|
|
b1dca6 |
and
|
|
|
b1dca6 |
|
|
|
b1dca6 |
if (CPU_FEATURE_USABLE (WIDE_KL))
|
|
|
b1dca6 |
|
|
|
b1dca6 |
to check if AES Key Locker instructions and AES wide Key Locker
|
|
|
b1dca6 |
instructions are usable.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
diff --git a/manual/platform.texi b/manual/platform.texi
|
|
|
b1dca6 |
index 2c145acdc3564cbb..95b0ed0642c9f8a9 100644
|
|
|
b1dca6 |
--- a/manual/platform.texi
|
|
|
b1dca6 |
+++ b/manual/platform.texi
|
|
|
b1dca6 |
@@ -177,6 +177,9 @@ The supported processor features are:
|
|
|
b1dca6 |
@item
|
|
|
b1dca6 |
@code{AES} -- The AES instruction extensions.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+@item
|
|
|
b1dca6 |
+@code{AESKLE} -- AES Key Locker instructions are enabled by OS.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
@item
|
|
|
b1dca6 |
@code{AMX_BF16} -- Tile computational operations on bfloat16 numbers.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
@@ -353,6 +356,9 @@ the indirect branch predictor barrier (IBPB).
|
|
|
b1dca6 |
@item
|
|
|
b1dca6 |
@code{INVPCID} -- INVPCID instruction.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+@item
|
|
|
b1dca6 |
+@code{KL} -- AES Key Locker instructions.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
@item
|
|
|
b1dca6 |
@code{L1D_FLUSH} -- IA32_FLUSH_CMD MSR.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
@@ -598,6 +604,9 @@ using a TSC deadline value.
|
|
|
b1dca6 |
@item
|
|
|
b1dca6 |
@code{WBNOINVD} -- WBINVD/WBNOINVD instructions.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+@item
|
|
|
b1dca6 |
+@code{WIDE_KL} -- AES wide Key Locker instructions.
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
@item
|
|
|
b1dca6 |
@code{X2APIC} -- x2APIC.
|
|
|
b1dca6 |
|
|
|
b1dca6 |
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
|
|
|
b1dca6 |
index 6954728c47d0126b..77a596a15404b575 100644
|
|
|
b1dca6 |
--- a/sysdeps/x86/cpu-features.c
|
|
|
b1dca6 |
+++ b/sysdeps/x86/cpu-features.c
|
|
|
b1dca6 |
@@ -269,6 +269,14 @@ update_usable (struct cpu_features *cpu_features)
|
|
|
b1dca6 |
/* Determine if PKU is usable. */
|
|
|
b1dca6 |
if (CPU_FEATURES_CPU_P (cpu_features, OSPKE))
|
|
|
b1dca6 |
CPU_FEATURE_SET (cpu_features, PKU);
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+ /* Determine if Key Locker instructions are usable. */
|
|
|
b1dca6 |
+ if (CPU_FEATURES_CPU_P (cpu_features, AESKLE))
|
|
|
b1dca6 |
+ {
|
|
|
b1dca6 |
+ CPU_FEATURE_SET (cpu_features, AESKLE);
|
|
|
b1dca6 |
+ CPU_FEATURE_SET_USABLE (cpu_features, KL);
|
|
|
b1dca6 |
+ CPU_FEATURE_SET_USABLE (cpu_features, WIDE_KL);
|
|
|
b1dca6 |
+ }
|
|
|
b1dca6 |
}
|
|
|
b1dca6 |
|
|
|
b1dca6 |
static void
|
|
|
b1dca6 |
@@ -341,6 +349,12 @@ get_common_indices (struct cpu_features *cpu_features,
|
|
|
b1dca6 |
cpu_features->features[COMMON_CPUID_INDEX_D_ECX_1].cpuid.ecx,
|
|
|
b1dca6 |
cpu_features->features[COMMON_CPUID_INDEX_D_ECX_1].cpuid.edx);
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+ if (cpu_features->basic.max_cpuid >= 0x19)
|
|
|
b1dca6 |
+ __cpuid_count (0x19, 0,
|
|
|
b1dca6 |
+ cpu_features->features[COMMON_CPUID_INDEX_19].cpuid.eax,
|
|
|
b1dca6 |
+ cpu_features->features[COMMON_CPUID_INDEX_19].cpuid.ebx,
|
|
|
b1dca6 |
+ cpu_features->features[COMMON_CPUID_INDEX_19].cpuid.ecx,
|
|
|
b1dca6 |
+ cpu_features->features[COMMON_CPUID_INDEX_19].cpuid.edx);
|
|
|
b1dca6 |
}
|
|
|
b1dca6 |
|
|
|
b1dca6 |
_Static_assert (((index_arch_Fast_Unaligned_Load
|
|
|
b1dca6 |
diff --git a/sysdeps/x86/sys/platform/x86.h b/sysdeps/x86/sys/platform/x86.h
|
|
|
b1dca6 |
index ebc5f6fc16cb8104..bcc81ab5f8ac8265 100644
|
|
|
b1dca6 |
--- a/sysdeps/x86/sys/platform/x86.h
|
|
|
b1dca6 |
+++ b/sysdeps/x86/sys/platform/x86.h
|
|
|
b1dca6 |
@@ -28,6 +28,7 @@ enum
|
|
|
b1dca6 |
COMMON_CPUID_INDEX_80000007,
|
|
|
b1dca6 |
COMMON_CPUID_INDEX_80000008,
|
|
|
b1dca6 |
COMMON_CPUID_INDEX_7_ECX_1,
|
|
|
b1dca6 |
+ COMMON_CPUID_INDEX_19,
|
|
|
b1dca6 |
/* Keep the following line at the end. */
|
|
|
b1dca6 |
COMMON_CPUID_INDEX_MAX
|
|
|
b1dca6 |
};
|
|
|
b1dca6 |
@@ -224,7 +225,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
|
|
|
b1dca6 |
/* Note: Bits 17-21: The value of MAWAU used by the BNDLDX and BNDSTX
|
|
|
b1dca6 |
instructions in 64-bit mode. */
|
|
|
b1dca6 |
#define bit_cpu_RDPID (1u << 22)
|
|
|
b1dca6 |
-#define bit_cpu_INDEX_7_ECX_23 (1u << 23)
|
|
|
b1dca6 |
+#define bit_cpu_KL (1u << 23)
|
|
|
b1dca6 |
#define bit_cpu_INDEX_7_ECX_24 (1u << 24)
|
|
|
b1dca6 |
#define bit_cpu_CLDEMOTE (1u << 25)
|
|
|
b1dca6 |
#define bit_cpu_INDEX_7_ECX_26 (1u << 26)
|
|
|
b1dca6 |
@@ -312,6 +313,12 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
|
|
|
b1dca6 |
/* EAX. */
|
|
|
b1dca6 |
#define bit_cpu_AVX512_BF16 (1u << 5)
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+/* COMMON_CPUID_INDEX_19. */
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+/* EBX. */
|
|
|
b1dca6 |
+#define bit_cpu_AESKLE (1u << 0)
|
|
|
b1dca6 |
+#define bit_cpu_WIDE_KL (1u << 2)
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
/* COMMON_CPUID_INDEX_1. */
|
|
|
b1dca6 |
|
|
|
b1dca6 |
/* ECX. */
|
|
|
b1dca6 |
@@ -437,7 +444,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
|
|
|
b1dca6 |
#define index_cpu_INDEX_7_ECX_15 COMMON_CPUID_INDEX_7
|
|
|
b1dca6 |
#define index_cpu_INDEX_7_ECX_16 COMMON_CPUID_INDEX_7
|
|
|
b1dca6 |
#define index_cpu_RDPID COMMON_CPUID_INDEX_7
|
|
|
b1dca6 |
-#define index_cpu_INDEX_7_ECX_23 COMMON_CPUID_INDEX_7
|
|
|
b1dca6 |
+#define index_cpu_KL COMMON_CPUID_INDEX_7
|
|
|
b1dca6 |
#define index_cpu_INDEX_7_ECX_24 COMMON_CPUID_INDEX_7
|
|
|
b1dca6 |
#define index_cpu_CLDEMOTE COMMON_CPUID_INDEX_7
|
|
|
b1dca6 |
#define index_cpu_INDEX_7_ECX_26 COMMON_CPUID_INDEX_7
|
|
|
b1dca6 |
@@ -525,6 +532,12 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
|
|
|
b1dca6 |
/* EAX. */
|
|
|
b1dca6 |
#define index_cpu_AVX512_BF16 COMMON_CPUID_INDEX_7_ECX_1
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+/* COMMON_CPUID_INDEX_19. */
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+/* EBX. */
|
|
|
b1dca6 |
+#define index_cpu_AESKLE COMMON_CPUID_INDEX_19
|
|
|
b1dca6 |
+#define index_cpu_WIDE_KL COMMON_CPUID_INDEX_19
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
/* COMMON_CPUID_INDEX_1. */
|
|
|
b1dca6 |
|
|
|
b1dca6 |
/* ECX. */
|
|
|
b1dca6 |
@@ -650,7 +663,7 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
|
|
|
b1dca6 |
#define reg_INDEX_7_ECX_15 ecx
|
|
|
b1dca6 |
#define reg_INDEX_7_ECX_16 ecx
|
|
|
b1dca6 |
#define reg_RDPID ecx
|
|
|
b1dca6 |
-#define reg_INDEX_7_ECX_23 ecx
|
|
|
b1dca6 |
+#define reg_KL ecx
|
|
|
b1dca6 |
#define reg_INDEX_7_ECX_24 ecx
|
|
|
b1dca6 |
#define reg_CLDEMOTE ecx
|
|
|
b1dca6 |
#define reg_INDEX_7_ECX_26 ecx
|
|
|
b1dca6 |
@@ -738,4 +751,10 @@ extern const struct cpu_features *__x86_get_cpu_features (unsigned int)
|
|
|
b1dca6 |
/* EAX. */
|
|
|
b1dca6 |
#define reg_AVX512_BF16 eax
|
|
|
b1dca6 |
|
|
|
b1dca6 |
+/* COMMON_CPUID_INDEX_19. */
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
+/* EBX. */
|
|
|
b1dca6 |
+#define reg_AESKLE ebx
|
|
|
b1dca6 |
+#define reg_WIDE_KL ebx
|
|
|
b1dca6 |
+
|
|
|
b1dca6 |
#endif /* _SYS_PLATFORM_X86_H */
|
|
|
b1dca6 |
diff --git a/sysdeps/x86/tst-get-cpu-features.c b/sysdeps/x86/tst-get-cpu-features.c
|
|
|
b1dca6 |
index 95e0d33f6c7eeace..c01d701b52090983 100644
|
|
|
b1dca6 |
--- a/sysdeps/x86/tst-get-cpu-features.c
|
|
|
b1dca6 |
+++ b/sysdeps/x86/tst-get-cpu-features.c
|
|
|
b1dca6 |
@@ -170,6 +170,7 @@ do_test (void)
|
|
|
b1dca6 |
CHECK_CPU_FEATURE (AVX512_BITALG);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE (AVX512_VPOPCNTDQ);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE (RDPID);
|
|
|
b1dca6 |
+ CHECK_CPU_FEATURE (KL);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE (CLDEMOTE);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE (MOVDIRI);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE (MOVDIR64B);
|
|
|
b1dca6 |
@@ -217,6 +218,8 @@ do_test (void)
|
|
|
b1dca6 |
CHECK_CPU_FEATURE (INVARIANT_TSC);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE (WBNOINVD);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE (AVX512_BF16);
|
|
|
b1dca6 |
+ CHECK_CPU_FEATURE (AESKLE);
|
|
|
b1dca6 |
+ CHECK_CPU_FEATURE (WIDE_KL);
|
|
|
b1dca6 |
|
|
|
b1dca6 |
printf ("Usable CPU features:\n");
|
|
|
b1dca6 |
CHECK_CPU_FEATURE_USABLE (SSE3);
|
|
|
b1dca6 |
@@ -323,6 +326,7 @@ do_test (void)
|
|
|
b1dca6 |
CHECK_CPU_FEATURE_USABLE (AVX512_BITALG);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE_USABLE (AVX512_VPOPCNTDQ);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE_USABLE (RDPID);
|
|
|
b1dca6 |
+ CHECK_CPU_FEATURE_USABLE (KL);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE_USABLE (CLDEMOTE);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE_USABLE (MOVDIRI);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE_USABLE (MOVDIR64B);
|
|
|
b1dca6 |
@@ -370,6 +374,8 @@ do_test (void)
|
|
|
b1dca6 |
CHECK_CPU_FEATURE_USABLE (INVARIANT_TSC);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE_USABLE (WBNOINVD);
|
|
|
b1dca6 |
CHECK_CPU_FEATURE_USABLE (AVX512_BF16);
|
|
|
b1dca6 |
+ CHECK_CPU_FEATURE_USABLE (AESKLE);
|
|
|
b1dca6 |
+ CHECK_CPU_FEATURE_USABLE (WIDE_KL);
|
|
|
b1dca6 |
|
|
|
b1dca6 |
return 0;
|
|
|
b1dca6 |
}
|