]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86: Advertise AVX10_VNNI_INT CPUID to userspace
authorZhao Liu <zhao1.liu@intel.com>
Thu, 20 Nov 2025 05:07:20 +0000 (13:07 +0800)
committerSean Christopherson <seanjc@google.com>
Fri, 23 Jan 2026 18:00:02 +0000 (10:00 -0800)
Define and advertise AVX10_VNNI_INT CPUID to userspace when it's supported
by the host.

AVX10_VNNI_INT (0x24.0x1.ECX[bit 2]) is a discrete feature bit
introduced on Intel Diamond Rapids, which enumerates the support for
EVEX VPDP* instructions for INT8/INT16 [*].

Since this feature has no actual kernel usages, define it as a KVM-only
feature in reverse_cpuid.h.

Advertise new CPUID subleaf 0x24.0x1 with AVX10_VNNI_INT bit to
userspace for guest use. It's safe since no additional enabling work
is needed in the host kernel.

[*]: Intel Advanced Vector Extensions 10.2 Architecture Specification
     (rev 5.0).

Tested-by: Xudong Hao <xudong.hao@intel.com>
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Link: https://patch.msgid.link/20251120050720.931449-5-zhao1.liu@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/cpuid.c
arch/x86/kvm/reverse_cpuid.h

index c1859c65453f06d26efd163518e367a95539afe2..80fd7ca69c87337bb192e74a52abf9b8d4902256 100644 (file)
@@ -777,6 +777,7 @@ enum kvm_only_cpuid_leafs {
        CPUID_8000_0021_ECX,
        CPUID_7_1_ECX,
        CPUID_1E_1_EAX,
+       CPUID_24_1_ECX,
        NR_KVM_CPU_CAPS,
 
        NKVMCAPINTS = NR_KVM_CPU_CAPS - NCAPINTS,
index ecb4ca9af78899608ca8c94dac45e23263345e48..0172b7ef2ba405893857fc155600f4f5adb848a2 100644 (file)
@@ -1084,6 +1084,10 @@ void kvm_set_cpu_caps(void)
                F(AVX10_512),
        );
 
+       kvm_cpu_cap_init(CPUID_24_1_ECX,
+               F(AVX10_VNNI_INT),
+       );
+
        kvm_cpu_cap_init(CPUID_8000_0001_ECX,
                F(LAHF_LM),
                F(CMP_LEGACY),
@@ -1661,6 +1665,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
                        break;
                }
 
+               max_idx = entry->eax = min(entry->eax, 1u);
                /*
                 * The AVX10 version is encoded in EBX[7:0].  Note, the version
                 * is guaranteed to be >=1 if AVX10 is supported.  Note #2, the
@@ -1670,9 +1675,20 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
                cpuid_entry_override(entry, CPUID_24_0_EBX);
                entry->ebx |= avx10_version;
 
-               entry->eax = 0;
                entry->ecx = 0;
                entry->edx = 0;
+
+               /* KVM only supports up to 0x24.0x1, capped above via min(). */
+               if (max_idx >= 1) {
+                       entry = do_host_cpuid(array, function, 1);
+                       if (!entry)
+                               goto out;
+
+                       cpuid_entry_override(entry, CPUID_24_1_ECX);
+                       entry->eax = 0;
+                       entry->ebx = 0;
+                       entry->edx = 0;
+               }
                break;
        }
        case KVM_CPUID_SIGNATURE: {
index 7dc4200a26f19505be5c47be9759f25f4e89fac9..657f5f743ed97549ba6437cf5f2a8d9964e79029 100644 (file)
@@ -63,6 +63,9 @@
 #define X86_FEATURE_AVX10_256          KVM_X86_FEATURE(CPUID_24_0_EBX, 17)
 #define X86_FEATURE_AVX10_512          KVM_X86_FEATURE(CPUID_24_0_EBX, 18)
 
+/* Intel-defined sub-features, CPUID level 0x00000024:1 (ECX) */
+#define X86_FEATURE_AVX10_VNNI_INT     KVM_X86_FEATURE(CPUID_24_1_ECX, 2)
+
 /* CPUID level 0x80000007 (EDX). */
 #define KVM_X86_FEATURE_CONSTANT_TSC   KVM_X86_FEATURE(CPUID_8000_0007_EDX, 8)
 
@@ -105,6 +108,7 @@ static const struct cpuid_reg reverse_cpuid[] = {
        [CPUID_8000_0021_ECX] = {0x80000021, 0, CPUID_ECX},
        [CPUID_7_1_ECX]       = {         7, 1, CPUID_ECX},
        [CPUID_1E_1_EAX]      = {      0x1e, 1, CPUID_EAX},
+       [CPUID_24_1_ECX]      = {      0x24, 1, CPUID_ECX},
 };
 
 /*