diff mbox series

[v2,4/7] kvm: x86: Extract kvm_mwait_update_cpuid() from kvm_update_cpuid_runtime()

Message ID 1603271410-71343-5-git-send-email-robert.hu@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Split kvm_update_cpuid_runtime() | expand

Commit Message

Robert Hoo Oct. 21, 2020, 9:10 a.m. UTC
And let kvm_set_msr_common() call kvm_mwait_update_cpuid() instead of whole
kvm_update_cpuid_runtime().

Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
---
 arch/x86/kvm/cpuid.c | 5 +++++
 arch/x86/kvm/cpuid.h | 1 +
 arch/x86/kvm/x86.c   | 3 ++-
 3 files changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 18cd27a..556c018 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -88,6 +88,11 @@  void kvm_osxsave_update_cpuid(struct kvm_vcpu *vcpu, bool set)
 		guest_cpuid_change(vcpu, 1, 0, X86_FEATURE_OSXSAVE, set);
 }
 
+void kvm_mwait_update_cpuid(struct kvm_vcpu *vcpu, bool set)
+{
+	guest_cpuid_change(vcpu, 1, 0, X86_FEATURE_MWAIT, set);
+}
+
 void kvm_apic_base_update_cpuid(struct kvm_vcpu *vcpu, bool set)
 {
 	guest_cpuid_change(vcpu, 1, 0, X86_FEATURE_APIC, set);
diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h
index 98ea431..7eabb44 100644
--- a/arch/x86/kvm/cpuid.h
+++ b/arch/x86/kvm/cpuid.h
@@ -12,6 +12,7 @@ 
 void kvm_osxsave_update_cpuid(struct kvm_vcpu *vcpu, bool set);
 void kvm_pke_update_cpuid(struct kvm_vcpu *vcpu, bool set);
 void kvm_apic_base_update_cpuid(struct kvm_vcpu *vcpu, bool set);
+void kvm_mwait_update_cpuid(struct kvm_vcpu *vcpu, bool set);
 void kvm_xcr0_update_cpuid(struct kvm_vcpu *vcpu);
 
 void kvm_update_cpuid_runtime(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 5e9a51d..0d3cb34 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2936,8 +2936,9 @@  int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 		    ((vcpu->arch.ia32_misc_enable_msr ^ data) & MSR_IA32_MISC_ENABLE_MWAIT)) {
 			if (!guest_cpuid_has(vcpu, X86_FEATURE_XMM3))
 				return 1;
+			kvm_mwait_update_cpuid(vcpu, !!(data & MSR_IA32_MISC_ENABLE_MWAIT));
+
 			vcpu->arch.ia32_misc_enable_msr = data;
-			kvm_update_cpuid_runtime(vcpu);
 		} else {
 			vcpu->arch.ia32_misc_enable_msr = data;
 		}