x86: KVM: Advertise AVX-IFMA CPUID to user space
authorJiaxi Chen <jiaxi.chen@linux.intel.com>
Fri, 25 Nov 2022 12:58:42 +0000 (20:58 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 28 Nov 2022 18:33:28 +0000 (13:33 -0500)
AVX-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]

AVX-IFMA is on an expected-dense CPUID leaf and some other bits on this
leaf have kernel usages. Given that, define this feature bit like
X86_FEATURE_<name> in kernel. Considering AVX-IFMA itself has no truly
kernel usages and /proc/cpuinfo has too much unreadable flags, hide this
one in /proc/cpuinfo.

Advertise AVX-IFMA to KVM userspace. This is safe because there are no
new VMX controls or additional host enabling required for guests to use
this feature.

Signed-off-by: Jiaxi Chen <jiaxi.chen@linux.intel.com>
Acked-by: Borislav Petkov <bp@suse.de>
Message-Id: <20221125125845.1182922-6-jiaxi.chen@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/cpufeatures.h
arch/x86/kvm/cpuid.c

index 20059dc..1419c4e 100644 (file)
 #define X86_FEATURE_AVX512_BF16                (12*32+ 5) /* AVX512 BFLOAT16 instructions */
 #define X86_FEATURE_CMPCCXADD           (12*32+ 7) /* "" CMPccXADD instructions */
 #define X86_FEATURE_AMX_FP16           (12*32+21) /* "" AMX fp16 Support */
+#define X86_FEATURE_AVX_IFMA            (12*32+23) /* "" Support for VPMADD52[H,L]UQ */
 
 /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
 #define X86_FEATURE_CLZERO             (13*32+ 0) /* CLZERO instruction */
index 6360075..5dfc0d0 100644 (file)
@@ -663,7 +663,8 @@ void kvm_set_cpu_caps(void)
                kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL_SSBD);
 
        kvm_cpu_cap_mask(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,