x86: KVM: Advertise CPUID of new Intel platform
v3 cover x86: KVM: Advertise CPUID of new Intel platform
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
v3:
- Remain CPUID_8000_001F_EAX in the last leaf of cpuid_leaf[]
- Replace CPUID_7_1_EAX with CPUID_LNX_5, waiting for future new CPUIDs
v2:
https://lore.kernel.org/all/[email protected]/
- 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 (7):
x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only
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 | 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 | 11 ++++++++--- arch/x86/kvm/reverse_cpuid.h | 15 +++++++++++++++ 6 files changed, 25 insertions(+), 14 deletions(-)
base-commit: 30a0b95b1335e12efef89dd78518ed3e4a71a763
Signature · 1 line
2.27.0
PATCH v3 1/7 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_LNX_5 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, 8 insertions(+), 12 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_LNX_5 ,CPUID_8000_0008_EBX ,CPUID_6_EAX , CPUID_8000_000A_EDX,
arch/x86/include/asm/cpufeatures.h +1 -3
@@ -305,9 +305,7 @@#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 */ +/* Linux-defined mapping, word 12 */ /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0)/* CLZERO instruction */
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
Re: [PATCH v3 1/7] x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only leaf
Quoted 11 lines · Jiaxi Chen
cpuid_leaf[12]
CPUID_7_1_EAXhas 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_LNX_5so future feature can pick it. This basically reverts:
Quoted 5 lines
- commit
b85a0425d805("Enumerate AVX Vector Neural Network
instructions")
- commitb302e4b176d0("x86/cpufeatures: Enumerate the new AVX512
BFLOAT16 instructions")
- commit1085a6b585d7("KVM: ExposeAVX_VNNIinstruction to guset")
FYI, LAM support has been queued in tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=aa387b1b1e666cacffc0b7ac7e0949a68013b2d9
It adds
+#define X86_FEATURE_LAM (12*32+26) /* Linear Address Masking */
and conflict with this patch.
Seen from the ISE, there are more bits defined in CPUID_7_1_EAX. And I believe Intel will define more and it's likely some of them will be used by kernel just like LAM.
Quoted 103 lines
Signed-off-by Jiaxi Chen <[email protected]>--- 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, 8 insertions(+), 12 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_LNX_5 ,CPUID_8000_0008_EBX ,CPUID_6_EAX , CPUID_8000_000A_EDX,arch/x86/include/asm/cpufeatures.h +1
-3@@ -305,9 +305,7 @@#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 */ +/* Linux-defined mapping, word 12 */ /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ #define X86_FEATURE_CLZERO (13*32+ 0)/* CLZERO instruction */ 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;
Sean Christopherson
maintainerRe: [PATCH v3 1/7] x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only leaf
Quoted 22 lines · Xiaoyao Li
Quoted 11 lines · Jiaxi Chen
cpuid_leaf[12]
CPUID_7_1_EAXhas 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_LNX_5so future feature can pick it. This basically reverts:Quoted 5 lines
- commit
b85a0425d805("Enumerate AVX Vector Neural Network
instructions")
- commitb302e4b176d0("x86/cpufeatures: Enumerate the new AVX512
BFLOAT16 instructions")
- commit1085a6b585d7("KVM: ExposeAVX_VNNIinstruction to guset")FYI, LAM support has been queued in tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=aa387b1b1e666cacffc0b7ac7e0949a68013b2d9
It adds
Quoted 7 lines
+#define
X86_FEATURE_LAM(12*32+26) /* Linear Address Masking */and conflict with this patch.
Seen from the ISE, there are more bits defined in
CPUID_7_1_EAX. And I believe Intel will define more and it's likely some of them will be used by kernel just like LAM.
Heh, are any of the bits you believe Intel will add publicly documented? :-)
LAM could be scattered, but if more bits are expected that's probably a waste of time and effort.
Thanks for the heads up!
Borislav Petkov
maintainerRe: [PATCH v3 1/7] x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only leaf
Quoted 4 lines · Sean Christopherson
Heh, are any of the bits you believe Intel will add publicly documented? :-)
LAM could be scattered, but if more bits are expected that's probably a waste of time and effort.
I'm being told the bigger part of that word is going to be used for either kernel or KVM bits so we might as well use it the "normal" way instead of doing KVM-only or scattered bits after all.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v3 1/7] x86: KVM: Move existing x86 CPUID leaf [CPUID_7_1_EAX] to kvm-only leaf
Quoted 12 lines · Borislav Petkov
Quoted 4 lines · Sean Christopherson
Heh, are any of the bits you believe Intel will add publicly documented? :-)
LAM could be scattered, but if more bits are expected that's probably a waste of time and effort.
I'm being told the bigger part of that word is going to be used for either kernel or KVM bits so we might as well use it the "normal" way instead of doing KVM-only or scattered bits after all.
Thx.
Intel published ISE spec
[https://cdrdv2.intel.com/v1/dl/getContent/671368] has documented 11 instructions for this leaf CPUID.7.1.EAX by now. Given that more bits are going to be defined, I will enable these bits in the patch series as v1 did and will not move them to kvm-only leaves.
By the way, Boris, what about CPUID.7.1.EDX, whether bigger part of it is expected to be used? In intel ISE, 3 bits are defined for this word. For now, I think put them in kvm-only subleaves as this patch series did is a better choice. What's your opinion?
Signature · 2 lines
Regards, Jiaxi
PATCH v3 2/7 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 v3 3/7 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 v3 4/7 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 v3 5/7 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 v3 6/7 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 v3 7/7 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