]> git.baikalelectronics.ru Git - kernel.git/commitdiff
KVM: x86/cpuid: Clear XFD for component i if the base feature is missing
authorLike Xu <likexu@tencent.com>
Mon, 17 Jan 2022 07:45:31 +0000 (15:45 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 19 Jan 2022 17:09:25 +0000 (12:09 -0500)
According to Intel extended feature disable (XFD) spec, the sub-function i
(i > 1) of CPUID function 0DH enumerates "details for state component i.
ECX[2] enumerates support for XFD support for this state component."

If KVM does not report F(XFD) feature (e.g. due to CONFIG_X86_64),
then the corresponding XFD support for any state component i
should also be removed. Translate this dependency into KVM terms.

Fixes: de227e62fde1 ("kvm: x86: Add CPUID support for Intel AMX")
Signed-off-by: Like Xu <likexu@tencent.com>
Message-Id: <20220117074531.76925-1-likexu@tencent.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/cpuid.c

index a7c280d2113b21e3d4df1f1b37cffe41691bf078..3902c28fb6cb7c1f260d0e4651913d4735671178 100644 (file)
@@ -936,6 +936,9 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
                                --array->nent;
                                continue;
                        }
+
+                       if (!kvm_cpu_cap_has(X86_FEATURE_XFD))
+                               entry->ecx &= ~BIT_ULL(2);
                        entry->edx = 0;
                }
                break;