diff mbox series

[1/4] x86: KVM: Advertise SHA512 CPUID to userspace

Message ID 20241104063559.727228-2-tao1.su@linux.intel.com (mailing list archive)
State New
Headers show
Series Advertise CPUID for new instructions in Clearwater Forest | expand

Commit Message

Tao Su Nov. 4, 2024, 6:35 a.m. UTC
SHA512 is a new set of instructions in the latest Intel platform
Clearwater Forest, which contains VSHA512MSG1, VSHA512MSG2, VSHA512RNDS2.

SHA512 is enumerated via CPUID.(EAX=7,ECX=1):EAX[bit 0].

SHA512 is on an expected-dense CPUID leaf and some other bits on this leaf
have kernel usages. Considering SHA512 itself has not truly kernel usages,
hide this one in /proc/cpuinfo.

These instructions only operate in xmm, ymm registers and have no new VMX
controls, so there is no additional host enabling required for guests to
use these instructions, i.e. advertising SHA512 CPUID to userspace is
safe.

Tested-by: Jiaan Lu <jiaan.lu@intel.com>
Tested-by: Xuelian Guo <xuelian.guo@intel.com>
Signed-off-by: Tao Su <tao1.su@linux.intel.com>
---
 arch/x86/include/asm/cpufeatures.h | 1 +
 arch/x86/kvm/cpuid.c               | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 913fd3a7bac6..896794528b81 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -317,6 +317,7 @@ 
 #define X86_FEATURE_ZEN1		(11*32+31) /* CPU based on Zen1 microarchitecture */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
+#define X86_FEATURE_SHA512		(12*32+ 0) /* SHA512 instructions */
 #define X86_FEATURE_AVX_VNNI		(12*32+ 4) /* "avx_vnni" AVX VNNI instructions */
 #define X86_FEATURE_AVX512_BF16		(12*32+ 5) /* "avx512_bf16" AVX512 BFLOAT16 instructions */
 #define X86_FEATURE_CMPCCXADD           (12*32+ 7) /* CMPccXADD instructions */
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 41786b834b16..5c7772567a4e 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -698,7 +698,7 @@  void kvm_set_cpu_caps(void)
 		kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD);
 
 	kvm_cpu_cap_mask(CPUID_7_1_EAX,
-		F(AVX_VNNI) | F(AVX512_BF16) | F(CMPCCXADD) |
+		F(SHA512) | F(AVX_VNNI) | F(AVX512_BF16) | F(CMPCCXADD) |
 		F(FZRM) | F(FSRS) | F(FSRC) |
 		F(AMX_FP16) | F(AVX_IFMA) | F(LAM)
 	);