Skip to content

Commit 963180a

Browse files
committed
KVM: x86: Avoid double CPUID lookup when updating MWAIT at runtime
Move the handling of X86_FEATURE_MWAIT during CPUID runtime updates to utilize the lookup done for other CPUID.0x1 features. No functional change intended. Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Link: https://lore.kernel.org/r/20241128013424.4096668-46-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent e592ec6 commit 963180a

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

arch/x86/kvm/cpuid.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu)
304304

305305
cpuid_entry_change(best, X86_FEATURE_APIC,
306306
vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE);
307+
308+
if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT))
309+
cpuid_entry_change(best, X86_FEATURE_MWAIT,
310+
vcpu->arch.ia32_misc_enable_msr &
311+
MSR_IA32_MISC_ENABLE_MWAIT);
307312
}
308313

309314
best = kvm_find_cpuid_entry_index(vcpu, 7, 0);
@@ -319,14 +324,6 @@ void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu)
319324
if (best && (cpuid_entry_has(best, X86_FEATURE_XSAVES) ||
320325
cpuid_entry_has(best, X86_FEATURE_XSAVEC)))
321326
best->ebx = xstate_required_size(vcpu->arch.xcr0, true);
322-
323-
if (!kvm_check_has_quirk(vcpu->kvm, KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT)) {
324-
best = kvm_find_cpuid_entry(vcpu, 0x1);
325-
if (best)
326-
cpuid_entry_change(best, X86_FEATURE_MWAIT,
327-
vcpu->arch.ia32_misc_enable_msr &
328-
MSR_IA32_MISC_ENABLE_MWAIT);
329-
}
330327
}
331328
EXPORT_SYMBOL_GPL(kvm_update_cpuid_runtime);
332329

0 commit comments

Comments
 (0)