Skip to content

Commit a0423af

Browse files
taosu-linuxbonzini
authored andcommitted
x86: KVM: Advertise CPUIDs for new instructions in Clearwater Forest
Latest Intel platform Clearwater Forest has introduced new instructions enumerated by CPUIDs of SHA512, SM3, SM4 and AVX-VNNI-INT16. Advertise these CPUIDs to userspace so that guests can query them directly. SHA512, SM3 and SM4 are on an expected-dense CPUID leaf and some other bits on this leaf have kernel usages. Considering they have not truly kernel usages, hide them in /proc/cpuinfo. These new 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 these CPUIDs to userspace is safe. Tested-by: Jiaan Lu <[email protected]> Tested-by: Xuelian Guo <[email protected]> Signed-off-by: Tao Su <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 35ff7bf commit a0423af

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@
317317
#define X86_FEATURE_ZEN1 (11*32+31) /* CPU based on Zen1 microarchitecture */
318318

319319
/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
320+
#define X86_FEATURE_SHA512 (12*32+ 0) /* SHA512 instructions */
321+
#define X86_FEATURE_SM3 (12*32+ 1) /* SM3 instructions */
322+
#define X86_FEATURE_SM4 (12*32+ 2) /* SM4 instructions */
320323
#define X86_FEATURE_AVX_VNNI (12*32+ 4) /* "avx_vnni" AVX VNNI instructions */
321324
#define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* "avx512_bf16" AVX512 BFLOAT16 instructions */
322325
#define X86_FEATURE_CMPCCXADD (12*32+ 7) /* CMPccXADD instructions */

arch/x86/kvm/cpuid.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -700,14 +700,14 @@ void kvm_set_cpu_caps(void)
700700
kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD);
701701

702702
kvm_cpu_cap_mask(CPUID_7_1_EAX,
703-
F(AVX_VNNI) | F(AVX512_BF16) | F(CMPCCXADD) |
704-
F(FZRM) | F(FSRS) | F(FSRC) |
705-
F(AMX_FP16) | F(AVX_IFMA) | F(LAM)
703+
F(SHA512) | F(SM3) | F(SM4) | F(AVX_VNNI) | F(AVX512_BF16) |
704+
F(CMPCCXADD) | F(FZRM) | F(FSRS) | F(FSRC) | F(AMX_FP16) |
705+
F(AVX_IFMA) | F(LAM)
706706
);
707707

708708
kvm_cpu_cap_init_kvm_defined(CPUID_7_1_EDX,
709-
F(AVX_VNNI_INT8) | F(AVX_NE_CONVERT) | F(PREFETCHITI) |
710-
F(AMX_COMPLEX) | F(AVX10)
709+
F(AVX_VNNI_INT8) | F(AVX_NE_CONVERT) | F(AMX_COMPLEX) |
710+
F(AVX_VNNI_INT16) | F(PREFETCHITI) | F(AVX10)
711711
);
712712

713713
kvm_cpu_cap_init_kvm_defined(CPUID_7_2_EDX,

arch/x86/kvm/reverse_cpuid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ enum kvm_only_cpuid_leafs {
4646
#define X86_FEATURE_AVX_VNNI_INT8 KVM_X86_FEATURE(CPUID_7_1_EDX, 4)
4747
#define X86_FEATURE_AVX_NE_CONVERT KVM_X86_FEATURE(CPUID_7_1_EDX, 5)
4848
#define X86_FEATURE_AMX_COMPLEX KVM_X86_FEATURE(CPUID_7_1_EDX, 8)
49+
#define X86_FEATURE_AVX_VNNI_INT16 KVM_X86_FEATURE(CPUID_7_1_EDX, 10)
4950
#define X86_FEATURE_PREFETCHITI KVM_X86_FEATURE(CPUID_7_1_EDX, 14)
5051
#define X86_FEATURE_AVX10 KVM_X86_FEATURE(CPUID_7_1_EDX, 19)
5152

0 commit comments

Comments
 (0)