Skip to content

Commit c841192

Browse files
taosu-linuxquanxianwang
authored andcommitted
x86: KVM: Advertise CPUIDs for new instructions in Clearwater Forest
commit a0423af92cb31e6fc4f53ef9b6e19fdf08ad4395 upstream. 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. Intel-SIG: commit a0423af92cb3 x86: KVM: Advertise CPUIDs for new instructions in Clearwater Forest. ClearWater support including CPU model and new ISAs and its dependency 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]> [ Quanxian Wang: amend commit log ] Signed-off-by: Quanxian Wang <[email protected]>
1 parent 0ca77b5 commit c841192

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
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 instructions */
321324
#define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */
322325
#define X86_FEATURE_ARCH_PERFMON_EXT (12*32+ 8) /* "" Intel Architectural PerfMon Extension */

arch/x86/kvm/cpuid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,12 @@ void kvm_set_cpu_caps(void)
524524
kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD);
525525

526526
kvm_cpu_cap_mask(CPUID_7_1_EAX,
527-
F(AVX_VNNI) | F(AVX512_BF16) |
527+
F(SHA512) | F(SM3) | F(SM4) | F(AVX_VNNI) | F(AVX512_BF16) |
528528
F(FZRM) | F(FSRS) | F(FSRC)
529529
);
530530

531531
kvm_cpu_cap_init_scattered(CPUID_7_1_EDX,
532-
F(AVX_VNNI_INT8)
532+
F(AVX_VNNI_INT8) | F(AVX_VNNI_INT16)
533533
);
534534

535535
kvm_cpu_cap_mask(CPUID_D_1_EAX,

arch/x86/kvm/reverse_cpuid.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum kvm_only_cpuid_leafs {
2727

2828
/* Intel-defined sub-features, CPUID level 0x00000007:1 (EDX) */
2929
#define X86_FEATURE_AVX_VNNI_INT8 KVM_X86_FEATURE(CPUID_7_1_EDX, 4)
30+
#define X86_FEATURE_AVX_VNNI_INT16 KVM_X86_FEATURE(CPUID_7_1_EDX, 10)
3031

3132
struct cpuid_reg {
3233
u32 function;

0 commit comments

Comments
 (0)