public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Update Xen-specific CPUID leaves during mangling
@ 2025-01-22 16:16 Fred Griffoul
  2025-01-22 17:16 ` Vitaly Kuznetsov
  0 siblings, 1 reply; 11+ messages in thread
From: Fred Griffoul @ 2025-01-22 16:16 UTC (permalink / raw)
  To: kvm
  Cc: Fred Griffoul, Sean Christopherson, Paolo Bonzini,
	Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, David Woodhouse, Paul Durrant, Vitaly Kuznetsov,
	linux-kernel

Previous commit ee3a5f9e3d9b ("KVM: x86: Do runtime CPUID update before
updating vcpu->arch.cpuid_entries") implemented CPUID data mangling in
KVM_SET_CPUID2 support before verifying that no changes occur on running
vCPUs. However, it overlooked the CPUID leaves that are modified by
KVM's Xen emulation.

Fix this by calling a Xen update function when mangling CPUID data.

Fixes: ee3a5f9e3d9b ("KVM: x86: Do runtime CPUID update before updating vcpu->arch.cpuid_entries")
Signed-off-by: Fred Griffoul <fgriffo@amazon.co.uk>
---
 arch/x86/kvm/cpuid.c | 1 +
 arch/x86/kvm/xen.c   | 5 +++++
 arch/x86/kvm/xen.h   | 5 +++++
 3 files changed, 11 insertions(+)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index edef30359c19..432d8e9e1bab 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -212,6 +212,7 @@ static int kvm_cpuid_check_equal(struct kvm_vcpu *vcpu, struct kvm_cpuid_entry2
 	 */
 	kvm_update_cpuid_runtime(vcpu);
 	kvm_apply_cpuid_pv_features_quirk(vcpu);
+	kvm_xen_update_cpuid_runtime(vcpu);
 
 	if (nent != vcpu->arch.cpuid_nent)
 		return -EINVAL;
diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c
index a909b817b9c0..219f9a9a92be 100644
--- a/arch/x86/kvm/xen.c
+++ b/arch/x86/kvm/xen.c
@@ -2270,6 +2270,11 @@ void kvm_xen_update_tsc_info(struct kvm_vcpu *vcpu)
 		entry->eax = vcpu->arch.hw_tsc_khz;
 }
 
+void kvm_xen_update_cpuid_runtime(struct kvm_vcpu *vcpu)
+{
+	kvm_xen_update_tsc_info(vcpu);
+}
+
 void kvm_xen_init_vm(struct kvm *kvm)
 {
 	mutex_init(&kvm->arch.xen.xen_lock);
diff --git a/arch/x86/kvm/xen.h b/arch/x86/kvm/xen.h
index f5841d9000ae..d3182b0ab7e3 100644
--- a/arch/x86/kvm/xen.h
+++ b/arch/x86/kvm/xen.h
@@ -36,6 +36,7 @@ int kvm_xen_setup_evtchn(struct kvm *kvm,
 			 struct kvm_kernel_irq_routing_entry *e,
 			 const struct kvm_irq_routing_entry *ue);
 void kvm_xen_update_tsc_info(struct kvm_vcpu *vcpu);
+void kvm_xen_update_cpuid_runtime(struct kvm_vcpu *vcpu);
 
 static inline void kvm_xen_sw_enable_lapic(struct kvm_vcpu *vcpu)
 {
@@ -160,6 +161,10 @@ static inline bool kvm_xen_timer_enabled(struct kvm_vcpu *vcpu)
 static inline void kvm_xen_update_tsc_info(struct kvm_vcpu *vcpu)
 {
 }
+
+static inline void kvm_xen_update_cpuid_runtime(struct kvm_vcpu *vcpu)
+{
+}
 #endif
 
 int kvm_xen_hypercall(struct kvm_vcpu *vcpu);
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-01-23 16:44 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22 16:16 [PATCH] KVM: x86: Update Xen-specific CPUID leaves during mangling Fred Griffoul
2025-01-22 17:16 ` Vitaly Kuznetsov
2025-01-22 17:19   ` Paul Durrant
2025-01-22 17:44     ` Vitaly Kuznetsov
2025-01-22 18:53       ` David Woodhouse
2025-01-22 22:00         ` Sean Christopherson
2025-01-23 12:35           ` Vitaly Kuznetsov
2025-01-23 16:44             ` David Woodhouse
2025-01-23  1:13   ` Sean Christopherson
2025-01-23 13:24     ` Vitaly Kuznetsov
2025-01-23 15:33       ` Griffoul, Fred

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox