]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: x86: Ignore cpuid faulting in SMM
authorJim Mattson <jmattson@google.com>
Tue, 10 Feb 2026 23:45:42 +0000 (15:45 -0800)
committerSean Christopherson <seanjc@google.com>
Tue, 3 Mar 2026 00:01:44 +0000 (16:01 -0800)
The Intel Virtualization Technology FlexMigration Application Note says,
"When CPUID faulting is enabled, all executions of the CPUID instruction
outside system-management mode (SMM) cause a general-protection exception
(#GP(0)) if the current privilege level (CPL) is greater than 0."

Always allow the execution of CPUID in SMM.

Fixes: db2336a80489 ("KVM: x86: virtualize cpuid faulting")
Signed-off-by: Jim Mattson <jmattson@google.com>
Link: https://patch.msgid.link/20260210234613.1383279-1-jmattson@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/cpuid.c
arch/x86/kvm/emulate.c

index d2486506a8086bd31128faef8bc8320fa24bbaa7..baf9a2860d985ee24c4eae9a73431b8878190712 100644 (file)
@@ -2157,7 +2157,8 @@ int kvm_emulate_cpuid(struct kvm_vcpu *vcpu)
 {
        u32 eax, ebx, ecx, edx;
 
-       if (cpuid_fault_enabled(vcpu) && !kvm_require_cpl(vcpu, 0))
+       if (!is_smm(vcpu) && cpuid_fault_enabled(vcpu) &&
+           !kvm_require_cpl(vcpu, 0))
                return 1;
 
        eax = kvm_rax_read(vcpu);
index 20ed588015f12b5969f30adcadd4e947c44b7899..500711c6f06931dc7a6bdf66bb57cc59241388ad 100644 (file)
@@ -3583,10 +3583,10 @@ static int em_cpuid(struct x86_emulate_ctxt *ctxt)
        u64 msr = 0;
 
        ctxt->ops->get_msr(ctxt, MSR_MISC_FEATURES_ENABLES, &msr);
-       if (msr & MSR_MISC_FEATURES_ENABLES_CPUID_FAULT &&
-           ctxt->ops->cpl(ctxt)) {
+       if (!ctxt->ops->is_smm(ctxt) &&
+           (msr & MSR_MISC_FEATURES_ENABLES_CPUID_FAULT) &&
+           ctxt->ops->cpl(ctxt))
                return emulate_gp(ctxt, 0);
-       }
 
        eax = reg_read(ctxt, VCPU_REGS_RAX);
        ecx = reg_read(ctxt, VCPU_REGS_RCX);