x86: KVM: Advertise CPUID of new Intel platform instructions to user space
v2 cover x86: KVM: Advertise CPUID of new Intel platform instructions to user space
Latest Intel platform Granite Rapids/Sierra Forest has introduced below new instructions and CPUIDs:
- CMPccXADD CPUID.(EAX=7,ECX=1):EAX[bit 7]
- AMX-FP16 CPUID.(EAX=7,ECX=1):EAX[bit 21]
- AVX-IFMA CPUID.(EAX=7,ECX=1):EAX[bit 23]
- AVX-VNNI-INT8 CPUID.(EAX=7,ECX=1):EDX[bit 4]
- AVX-NE-CONVERT CPUID.(EAX=7,ECX=1):EDX[bit 5]
- PREFETCHITI CPUID.(EAX=7,ECX=1):EDX[bit 14]
Details can be found in recent Intel ISE (Instruction Set Extensions)[1].
This patch series advertises KVM support of these CPUIDs to host userspace.
[1] Intel ISE: https://cdrdv2.intel.com/v1/dl/getContent/671368
v2:
- Remove vague descriptions in the changelogs, including pronouns and "this patch" kind of things.
- Move the two CPUIDs of cpuid_leaf[12] CPUID_7_1_EAX to kvm-only subleaves.
- Replace cpuid_leaf[12] CPUID_7_1_EAX with the last leaf CPUID_8000_001F_EAX to shorten array length.
- Change the newly-added CPUID leaf [CPUID_7_1_EDX] in v1 into kvm-only subleaves.
v1:
https://lore.kernel.org/all/[email protected]/
Jiaxi Chen (8):
x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only
leaf
x86/cpufeatures: Replace [CPUID_DUMMY] in cpuid_leafs[] with the last
leaf
x86: KVM: Advertise CMPccXADD CPUID to user space
x86: KVM: Advertise AMX-FP16 CPUID to user space
x86: KVM: Advertise AVX-IFMA CPUID to user space
x86: KVM: Advertise AVX-VNNI-INT8 CPUID to user space
x86: KVM: Advertise AVX-NE-CONVERT CPUID to user space
x86: KVM: Advertise PREFETCHIT0/1 CPUID to user space
arch/x86/include/asm/cpufeature.h | 9 +++------ arch/x86/include/asm/cpufeatures.h | 20 ++++++++------------ arch/x86/include/asm/disabled-features.h | 3 +-- arch/x86/include/asm/required-features.h | 3 +-- arch/x86/kernel/cpu/common.c | 6 ------ arch/x86/kernel/cpu/cpuid-deps.c | 1 - arch/x86/kvm/cpuid.c | 11 ++++++++--- arch/x86/kvm/reverse_cpuid.h | 15 +++++++++++++++ 8 files changed, 36 insertions(+), 32 deletions(-)
base-commit: e18d6152ff0f41b7f01f9817372022df04e0d354
Signature · 1 line
2.27.0
PATCH v2 1/8 x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only leaf
cpuid_leaf[12] CPUID_7_1_EAX has only two bits are in use currently:
- AVX-VNNI CPUID.(EAX=7,ECX=1):EAX[bit 4]
- AVX512-BF16 CPUID.(EAX=7,ECX=1):EAX[bit 5]
These two bits have no other kernel usages other than the guest CPUID advertisement in KVM. Given that and to save space for kernel feature bits, move these two bits to the kvm-only subleaves. The existing leaf cpuid_leafs[12] is set to CPUID_DUMMY so future feature can pick it. This basically reverts:
- commit b85a0425d805 ("Enumerate AVX Vector Neural Network
instructions")
- commit b302e4b176d0 ("x86/cpufeatures: Enumerate the new AVX512
BFLOAT16 instructions")
- commit 1085a6b585d7 ("KVM: Expose AVX_VNNI instruction to guset")
--- arch/x86/include/asm/cpufeature.h | 2 +- arch/x86/include/asm/cpufeatures.h | 4 ---- arch/x86/kernel/cpu/common.c | 6 ------ arch/x86/kernel/cpu/cpuid-deps.c | 1 - arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/reverse_cpuid.h | 5 +++++ 6 files changed, 7 insertions(+), 13 deletions(-)
arch/x86/include/asm/cpufeature.h +1 -1
@@ -24,7 +24,7 @@ enum cpuid_leafsCPUID_7_0_EBX ,CPUID_D_1_EAX ,CPUID_LNX_4 , -CPUID_7_1_EAX , +CPUID_DUMMY ,CPUID_8000_0008_EBX ,CPUID_6_EAX , CPUID_8000_000A_EDX,
arch/x86/include/asm/cpufeatures.h +0 -4
@@ -305,10 +305,6 @@#define X86_FEATURE_USE_IBPB_FW (11*32+16)/* "" Use IBPB during runtime firmware calls */ #define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17)/* "" Fill RSB on VM exit when EIBRS is enabled */ -/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ -#define X86_FEATURE_AVX_VNNI (12*32+ 4)/* AVX VNNI instructions */ -#define X86_FEATURE_AVX512_BF16 (12*32+ 5)/* AVX512 BFLOAT16 instructions */ -/* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0)/* CLZERO instruction */ #define X86_FEATURE_IRPERF (13*32+ 1)/* Instructions Retired Count */
arch/x86/kernel/cpu/common.c +0 -6
@@ -1026,12 +1026,6 @@ void get_cpu_cap(struct cpuinfo_x86 *c) c->x86_capability[CPUID_7_0_EBX ] = ebx; c->x86_capability[CPUID_7_ECX ] = ecx; c->x86_capability[CPUID_7_EDX ] = edx; - -/* Check valid sub-leaf index before accessing it */ -if (eax >=1 ) { -cpuid_count (0x00000007 ,1 , &eax, &ebx, &ecx, &edx); - c->x86_capability[CPUID_7_1_EAX ] = eax; - } }/* Extended state features: level 0x0000000d */
arch/x86/kernel/cpu/cpuid-deps.c +0 -1
@@ -68,7 +68,6 @@ static const struct cpuid_dep cpuid_deps[] = { { X86_FEATURE_CQM_OCCUP_LLC, X86_FEATURE_CQM_LLC }, { X86_FEATURE_CQM_MBM_TOTAL, X86_FEATURE_CQM_LLC }, { X86_FEATURE_CQM_MBM_LOCAL, X86_FEATURE_CQM_LLC }, - { X86_FEATURE_AVX512_BF16, X86_FEATURE_AVX512VL }, { X86_FEATURE_AVX512_FP16, X86_FEATURE_AVX512BW }, { X86_FEATURE_ENQCMD, X86_FEATURE_XSAVES }, { X86_FEATURE_PER_THREAD_MBA, X86_FEATURE_MBA },
arch/x86/kvm/cpuid.c +1 -1
@@ -656,7 +656,7 @@ void kvm_set_cpu_caps(void)if (boot_cpu_has (X86_FEATURE_AMD_SSBD ))kvm_cpu_cap_set (X86_FEATURE_SPEC_CTRL_SSBD ); -kvm_cpu_cap_mask (CPUID_7_1_EAX , +kvm_cpu_cap_init_scattered (CPUID_7_1_EAX ,F (AVX_VNNI ) |F (AVX512_BF16 ) );
arch/x86/kvm/reverse_cpuid.h +5 -0
@@ -13,6 +13,7 @@*/ enum kvm_only_cpuid_leafs {CPUID_12_EAX =NCAPINTS , +CPUID_7_1_EAX ,NR_KVM_CPU_CAPS ,NKVMCAPINTS =NR_KVM_CPU_CAPS -NCAPINTS ,
@@ -24,6 +25,10 @@ enum kvm_only_cpuid_leafs {#define KVM_X86_FEATURE_SGX1 KVM_X86_FEATURE(CPUID_12_EAX, 0)#define KVM_X86_FEATURE_SGX2 KVM_X86_FEATURE(CPUID_12_EAX, 1) +/* Intel-defined sub-features, CPUID level 0x00000007:1 (EAX) */ +#define X86_FEATURE_AVX_VNNI KVM_X86_FEATURE(CPUID_7_1_EAX, 4) +#define X86_FEATURE_AVX512_BF16 KVM_X86_FEATURE(CPUID_7_1_EAX, 5) +struct cpuid_reg {u32 function;u32 index;
Signature · 1 line
2.27.0
Borislav Petkov
maintainerRe: [PATCH v2 1/8] x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only leaf
arch/x86/include/asm/cpufeature.h enum cpuid_leafs · line 30
Quoted 13 lines · Jiaxi Chen
arch/x86/include/asm/cpufeature.h +1
-1@@ -24,7 +24,7 @@ enum cpuid_leafsCPUID_7_0_EBX ,CPUID_D_1_EAX ,CPUID_LNX_4 , -CPUID_7_1_EAX , +CPUID_DUMMY ,CPUID_8000_0008_EBX ,CPUID_6_EAX , CPUID_8000_000A_EDX,
No, do this (diff ontop):
arch/x86/include/asm/cpufeature.h +1 -1
@@ -24,7 +24,7 @@ enum cpuid_leafsCPUID_7_0_EBX ,CPUID_D_1_EAX ,CPUID_LNX_4 , -CPUID_DUMMY , +CPUID_LNX_5 ,CPUID_8000_0008_EBX ,CPUID_6_EAX , CPUID_8000_000A_EDX,
arch/x86/include/asm/cpufeatures.h +2 -0
@@ -306,6 +306,8 @@#define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17)/* "" Fill RSB on VM exit when EIBRS is enabled */ #define X86_FEATURE_CALL_DEPTH (11*32+18)/* "" Call depth tracking for RSB stuffing */ +/* Linux-defined mapping, word 12 */ +/* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0)/* CLZERO instruction */ #define X86_FEATURE_IRPERF (13*32+ 1)/* Instructions Retired Count */
---
I'm pretty sure we'll need new bits soon so let's reuse that one for Linux-defined flags.
Then you can drop patch 2.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v2 1/8] x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only leaf
Quoted 46 lines · Borislav Petkov
arch/x86/include/asm/cpufeature.h enum cpuid_leafs · line 30
Quoted 13 lines · Jiaxi Chen
arch/x86/include/asm/cpufeature.h +1
-1@@ -24,7 +24,7 @@ enum cpuid_leafsCPUID_7_0_EBX ,CPUID_D_1_EAX ,CPUID_LNX_4 , -CPUID_7_1_EAX , +CPUID_DUMMY ,CPUID_8000_0008_EBX ,CPUID_6_EAX , CPUID_8000_000A_EDX,No, do this (diff ontop):
arch/x86/include/asm/cpufeature.h +1
-1@@ -24,7 +24,7 @@ enum cpuid_leafsCPUID_7_0_EBX ,CPUID_D_1_EAX ,CPUID_LNX_4 , -CPUID_DUMMY , +CPUID_LNX_5 ,CPUID_8000_0008_EBX ,CPUID_6_EAX , CPUID_8000_000A_EDX,arch/x86/include/asm/cpufeatures.h +2
-1@@ -306,6 +306,8 @@#define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17)/* "" Fill RSB on VM exit when EIBRS is enabled */ #define X86_FEATURE_CALL_DEPTH (11*32+18)/* "" Call depth tracking for RSB stuffing */ +/* Linux-defined mapping, word 12 */ +/* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0)/* CLZERO instruction */ #define X86_FEATURE_IRPERF (13*32+ 1)/* Instructions Retired Count */ ---
Quoted 5 lines
I'm pretty sure we'll need new bits soon so let's reuse that one for Linux-defined flags.
Then you can drop patch 2.
Hi Boris,
Yes, that's reasonable. I understand the goodnees of putting CPUID_LNX_5 here is to avoid changing the array length [NCAPINTS] and other parts twice. But before new bits come, word 12 is empty in this gap. Is that ok?
Signature · 2 lines
Regards, Jiaxi
Borislav Petkov
maintainerRe: [PATCH v2 1/8] x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only leaf
Quoted 1 line · Jiaxi Chen
But before new bits come, word 12 is empty in this gap. Is that ok?
Yes.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquettePATCH v2 2/8 x86/cpufeatures: Replace [CPUID_DUMMY] in cpuid_leafs[] with the last leaf
In reply to Jiaxi ChenWe now have empty feature bits in cpuid_leafs[12] CPUID_DUMMY, move the last one cpuid_leafs[19] CPUID_8000_001F_EAX to the hole and we can shorten the length of cpuid_leafs[] from current 20 to 19.
--- arch/x86/include/asm/cpufeature.h | 9 +++------ arch/x86/include/asm/cpufeatures.h | 18 +++++++++--------- arch/x86/include/asm/disabled-features.h | 3 +-- arch/x86/include/asm/required-features.h | 3 +-- 4 files changed, 14 insertions(+), 19 deletions(-)
arch/x86/include/asm/cpufeature.h +3 -6
@@ -24,14 +24,13 @@ enum cpuid_leafsCPUID_7_0_EBX ,CPUID_D_1_EAX ,CPUID_LNX_4 , -CPUID_DUMMY , +CPUID_8000_001F_EAX ,CPUID_8000_0008_EBX ,CPUID_6_EAX ,CPUID_8000_000A_EDX ,CPUID_7_ECX ,CPUID_8000_0007_EBX , CPUID_7_EDX, - CPUID_8000_001F_EAX, };#define X86_CAP_FMT_NUM "%d:%d"
@@ -93,9 +92,8 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 16, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \ - CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 19, feature_bit) || \ REQUIRED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 20)) + BUILD_BUG_ON_ZERO(NCAPINTS != 19))#define DISABLED_MASK_BIT_SET (feature_bit) \ ( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \
@@ -117,9 +115,8 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 16, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \ - CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 19, feature_bit) || \ DISABLED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 20)) + BUILD_BUG_ON_ZERO(NCAPINTS != 19))#define cpu_has (c, bit) \ (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
arch/x86/include/asm/cpufeatures.h +9 -9
@@ -13,7 +13,7 @@/* * Defines x86 CPU feature bits */ -#define NCAPINTS 20/* N 32-bit words worth of info */ +#define NCAPINTS 19/* N 32-bit words worth of info */ #define NBUGINTS 1/* N 32-bit bug flags */ /*
@@ -305,6 +305,14 @@#define X86_FEATURE_USE_IBPB_FW (11*32+16)/* "" Use IBPB during runtime firmware calls */ #define X86_FEATURE_RSB_VMEXIT_LITE (11*32+17)/* "" Fill RSB on VM exit when EIBRS is enabled */ +/* AMD-defined memory encryption features, CPUID level 0x8000001f (EAX), word 12 */ +#define X86_FEATURE_SME (12*32+ 0)/* AMD Secure Memory Encryption */ +#define X86_FEATURE_SEV (12*32+ 1)/* AMD Secure Encrypted Virtualization */ +#define X86_FEATURE_VM_PAGE_FLUSH (12*32+ 2)/* "" VM Page Flush MSR is supported */ +#define X86_FEATURE_SEV_ES (12*32+ 3)/* AMD Secure Encrypted Virtualization - Encrypted State */ +#define X86_FEATURE_V_TSC_AUX (12*32+ 9)/* "" Virtual TSC_AUX */ +#define X86_FEATURE_SME_COHERENT (12*32+10)/* "" AMD hardware-enforced cache coherency */ +/* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0)/* CLZERO instruction */ #define X86_FEATURE_IRPERF (13*32+ 1)/* Instructions Retired Count */
@@ -408,14 +416,6 @@#define X86_FEATURE_CORE_CAPABILITIES (18*32+30)/* "" IA32_CORE_CAPABILITIES MSR */ #define X86_FEATURE_SPEC_CTRL_SSBD (18*32+31)/* "" Speculative Store Bypass Disable */ -/* AMD-defined memory encryption features, CPUID level 0x8000001f (EAX), word 19 */ -#define X86_FEATURE_SME (19*32+ 0)/* AMD Secure Memory Encryption */ -#define X86_FEATURE_SEV (19*32+ 1)/* AMD Secure Encrypted Virtualization */ -#define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2)/* "" VM Page Flush MSR is supported */ -#define X86_FEATURE_SEV_ES (19*32+ 3)/* AMD Secure Encrypted Virtualization - Encrypted State */ -#define X86_FEATURE_V_TSC_AUX (19*32+ 9)/* "" Virtual TSC_AUX */ -#define X86_FEATURE_SME_COHERENT (19*32+10)/* "" AMD hardware-enforced cache coherency */ -/* * BUG word(s) */
arch/x86/include/asm/disabled-features.h +1 -2
@@ -110,7 +110,6 @@ DISABLE_ENQCMD)#define DISABLED_MASK17 0#define DISABLED_MASK18 0 -#define DISABLED_MASK19 0 -#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) +#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)#endif /* _ASM_X86_DISABLED_FEATURES_H */
arch/x86/include/asm/required-features.h +1 -2
@@ -97,7 +97,6 @@#define REQUIRED_MASK16 0#define REQUIRED_MASK17 0#define REQUIRED_MASK18 0 -#define REQUIRED_MASK19 0 -#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) +#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)#endif /* _ASM_X86_REQUIRED_FEATURES_H */
Signature · 1 line
2.27.0
PATCH v2 3/8 x86: KVM: Advertise CMPccXADD CPUID to user space
In reply to Jiaxi ChenCMPccXADD is a new set of instructions in the latest Intel platform Sierra Forest. This new instruction set includes a semaphore operation that can compare and add the operands if condition is met, which can improve database performance.
The bit definition:
CPUID.(EAX=7,ECX=1):EAX[bit 7]
This CPUID is exposed to userspace. Besides, there is no other VMX control for this instruction.
--- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +1 -1
@@ -657,7 +657,7 @@ void kvm_set_cpu_caps(void)kvm_cpu_cap_set (X86_FEATURE_SPEC_CTRL_SSBD );kvm_cpu_cap_init_scattered (CPUID_7_1_EAX , -F (AVX_VNNI ) |F (AVX512_BF16 ) +F (AVX_VNNI ) |F (AVX512_BF16 ) |F (CMPCCXADD ) ); kvm_cpu_cap_mask(CPUID_D_1_EAX,
arch/x86/kvm/reverse_cpuid.h +1 -0
@@ -28,6 +28,7 @@ enum kvm_only_cpuid_leafs {/* Intel-defined sub-features, CPUID level 0x00000007:1 (EAX) */ #define X86_FEATURE_AVX_VNNI KVM_X86_FEATURE(CPUID_7_1_EAX, 4)#define X86_FEATURE_AVX512_BF16 KVM_X86_FEATURE(CPUID_7_1_EAX, 5) +#define X86_FEATURE_CMPCCXADD KVM_X86_FEATURE(CPUID_7_1_EAX, 7)struct cpuid_reg {u32 function;
Signature · 1 line
2.27.0
PATCH v2 4/8 x86: KVM: Advertise AMX-FP16 CPUID to user space
In reply to Jiaxi ChenLatest Intel platform Granite Rapids has introduced a new instruction - AMX-FP16, which performs dot-products of two FP16 tiles and accumulates the results into a packed single precision tile. This instrucion needs no additional enabling on top of the existing kernel AMX enabling.
AMX-FP16 adds FP16 capability and also allows a FP16 GPU trained model to run faster without loss of accuracy or added SW overhead.
The bit definition:
CPUID.(EAX=7,ECX=1):EAX[bit 21]
This CPUID is exposed to user space. Besides, there is no other VMX control for this instruction.
--- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +1 -1
@@ -657,7 +657,7 @@ void kvm_set_cpu_caps(void)kvm_cpu_cap_set (X86_FEATURE_SPEC_CTRL_SSBD );kvm_cpu_cap_init_scattered (CPUID_7_1_EAX , -F (AVX_VNNI ) |F (AVX512_BF16 ) |F (CMPCCXADD ) +F (AVX_VNNI ) |F (AVX512_BF16 ) |F (CMPCCXADD ) |F (AMX_FP16 ) ); kvm_cpu_cap_mask(CPUID_D_1_EAX,
arch/x86/kvm/reverse_cpuid.h +1 -0
@@ -29,6 +29,7 @@ enum kvm_only_cpuid_leafs {#define X86_FEATURE_AVX_VNNI KVM_X86_FEATURE(CPUID_7_1_EAX, 4)#define X86_FEATURE_AVX512_BF16 KVM_X86_FEATURE(CPUID_7_1_EAX, 5)#define X86_FEATURE_CMPCCXADD KVM_X86_FEATURE(CPUID_7_1_EAX, 7) +#define X86_FEATURE_AMX_FP16 KVM_X86_FEATURE(CPUID_7_1_EAX, 21)struct cpuid_reg {u32 function;
Signature · 1 line
2.27.0
PATCH v2 5/8 x86: KVM: Advertise AVX-IFMA CPUID to user space
In reply to Jiaxi ChenAVX-IFMA is a new instruction in the latest Intel platform Sierra Forest. This instruction packed multiplies unsigned 52-bit integers and adds the low/high 52-bit products to Qword Accumulators.
The bit definition:
CPUID.(EAX=7,ECX=1):EAX[bit 23]
This CPUID is exposed to user space. Besides, there is no other VMX control for this instruction.
--- arch/x86/kvm/cpuid.c | 3 ++- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +2 -1
@@ -657,7 +657,8 @@ void kvm_set_cpu_caps(void)kvm_cpu_cap_set (X86_FEATURE_SPEC_CTRL_SSBD );kvm_cpu_cap_init_scattered (CPUID_7_1_EAX , -F (AVX_VNNI ) |F (AVX512_BF16 ) |F (CMPCCXADD ) |F (AMX_FP16 ) +F (AVX_VNNI ) |F (AVX512_BF16 ) |F (CMPCCXADD ) |F (AMX_FP16 ) | +F (AVX_IFMA ) ); kvm_cpu_cap_mask(CPUID_D_1_EAX,
arch/x86/kvm/reverse_cpuid.h +1 -0
@@ -30,6 +30,7 @@ enum kvm_only_cpuid_leafs {#define X86_FEATURE_AVX512_BF16 KVM_X86_FEATURE(CPUID_7_1_EAX, 5)#define X86_FEATURE_CMPCCXADD KVM_X86_FEATURE(CPUID_7_1_EAX, 7)#define X86_FEATURE_AMX_FP16 KVM_X86_FEATURE(CPUID_7_1_EAX, 21) +#define X86_FEATURE_AVX_IFMA KVM_X86_FEATURE(CPUID_7_1_EAX, 23)struct cpuid_reg {u32 function;
Signature · 1 line
2.27.0
PATCH v2 6/8 x86: KVM: Advertise AVX-VNNI-INT8 CPUID to user space
In reply to Jiaxi ChenAVX-VNNI-INT8 is a new set of instructions in the latest Intel platform Sierra Forest, aims for the platform to have superior AI capabilities. This instruction multiplies the individual bytes of two unsigned or unsigned source operands, then adds and accumulates the results into the destination dword element size operand.
The bit definition:
CPUID.(EAX=7,ECX=1):EDX[bit 4]
This CPUID is exposed to user space. Besides, there is no other VMX control for this instruction.
--- arch/x86/kvm/cpuid.c | 5 ++++- arch/x86/kvm/reverse_cpuid.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +4 -1
@@ -661,6 +661,9 @@ void kvm_set_cpu_caps(void)F (AVX_IFMA ) ); +kvm_cpu_cap_init_scattered (CPUID_7_1_EDX , +F (AVX_VNNI_INT8 )); +kvm_cpu_cap_mask (CPUID_D_1_EAX ,F (XSAVEOPT ) |F (XSAVEC ) |F (XGETBV1 ) |F (XSAVES ) | f_xfd );
@@ -914,9 +917,9 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) goto out;cpuid_entry_override (entry,CPUID_7_1_EAX ); +cpuid_entry_override (entry,CPUID_7_1_EDX ); entry->ebx =0 ; entry->ecx =0 ; - entry->edx =0 ; }break ;case 0xa : {/* Architectural Performance Monitoring */
arch/x86/kvm/reverse_cpuid.h +5 -0
@@ -14,6 +14,7 @@enum kvm_only_cpuid_leafs {CPUID_12_EAX =NCAPINTS ,CPUID_7_1_EAX , +CPUID_7_1_EDX ,NR_KVM_CPU_CAPS ,NKVMCAPINTS =NR_KVM_CPU_CAPS -NCAPINTS ,
@@ -32,6 +33,9 @@ enum kvm_only_cpuid_leafs {#define X86_FEATURE_AMX_FP16 KVM_X86_FEATURE(CPUID_7_1_EAX, 21)#define X86_FEATURE_AVX_IFMA KVM_X86_FEATURE(CPUID_7_1_EAX, 23) +/* Intel-defined sub-features, CPUID level 0x00000007:1 (EDX) */ +#define X86_FEATURE_AVX_VNNI_INT8 KVM_X86_FEATURE(CPUID_7_1_EDX, 4) +struct cpuid_reg {u32 function;u32 index;
@@ -56,6 +60,7 @@ static const struct cpuid_reg reverse_cpuid[] = { [CPUID_7_1_EAX] = { 7, 1, CPUID_EAX}, [CPUID_12_EAX] = {0x00000012, 0, CPUID_EAX}, [CPUID_8000_001F_EAX] = {0x8000001f, 0, CPUID_EAX}, + [CPUID_7_1_EDX] = { 7, 1, CPUID_EDX}, };/*
Signature · 1 line
2.27.0
PATCH v2 7/8 x86: KVM: Advertise AVX-NE-CONVERT CPUID to user space
In reply to Jiaxi ChenAVX-NE-CONVERT is a new set of instructions which can convert low precision floating point like BF16/FP16 to high precision floating point FP32, and can also convert FP32 elements to BF16. This instruction allows the platform to have improved AI capabilities and better compatibility.
The bit definition:
CPUID.(EAX=7,ECX=1):EDX[bit 5]
This CPUID is exposed to user space. Besides, there is no other VMX control for this instruction.
--- arch/x86/kvm/cpuid.c | 3 ++- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +2 -1
@@ -662,7 +662,8 @@ void kvm_set_cpu_caps(void) );kvm_cpu_cap_init_scattered (CPUID_7_1_EDX , -F (AVX_VNNI_INT8 )); +F (AVX_VNNI_INT8 ) |F (AVX_NE_CONVERT ) + );kvm_cpu_cap_mask (CPUID_D_1_EAX , F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | F(XSAVES) | f_xfd
arch/x86/kvm/reverse_cpuid.h +1 -0
@@ -35,6 +35,7 @@ enum kvm_only_cpuid_leafs {/* Intel-defined sub-features, CPUID level 0x00000007:1 (EDX) */ #define X86_FEATURE_AVX_VNNI_INT8 KVM_X86_FEATURE(CPUID_7_1_EDX, 4) +#define X86_FEATURE_AVX_NE_CONVERT KVM_X86_FEATURE(CPUID_7_1_EDX, 5)struct cpuid_reg {u32 function;
Signature · 1 line
2.27.0
PATCH v2 8/8 x86: KVM: Advertise PREFETCHIT0/1 CPUID to user space
In reply to Jiaxi ChenLatest Intel platform Granite Rapids has introduced a new instruction - PREFETCHIT0/1, which moves code to memory (cache) closer to the processor depending on specific hints.
The bit definition:
CPUID.(EAX=7,ECX=1):EDX[bit 14]
This CPUID is exposed to user space. Besides, there is no other VMX control for this instruction.
--- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/reverse_cpuid.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +1 -1
@@ -662,7 +662,7 @@ void kvm_set_cpu_caps(void) );kvm_cpu_cap_init_scattered (CPUID_7_1_EDX , -F (AVX_VNNI_INT8 ) |F (AVX_NE_CONVERT ) +F (AVX_VNNI_INT8 ) |F (AVX_NE_CONVERT ) |F (PREFETCHITI ) ); kvm_cpu_cap_mask(CPUID_D_1_EAX,
arch/x86/kvm/reverse_cpuid.h +1 -0
@@ -36,6 +36,7 @@ enum kvm_only_cpuid_leafs {/* Intel-defined sub-features, CPUID level 0x00000007:1 (EDX) */ #define X86_FEATURE_AVX_VNNI_INT8 KVM_X86_FEATURE(CPUID_7_1_EDX, 4)#define X86_FEATURE_AVX_NE_CONVERT KVM_X86_FEATURE(CPUID_7_1_EDX, 5) +#define X86_FEATURE_PREFETCHITI KVM_X86_FEATURE(CPUID_7_1_EDX, 14)struct cpuid_reg {u32 function;
Signature · 1 line
2.27.0