Message ID | de0437379dfab11e431a23c8ce41a29234c06cbf.camel@infradead.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | KVM: x86/xen: Only write Xen hypercall page for guest writes to MSR | expand |
On Thu, 06 Feb 2025 19:14:19 +0000, David Woodhouse wrote: > The Xen hypercall page MSR is write-only. When the guest writes an address > to the MSR, the hypervisor populates the referenced page with hypercall > functions. > > There is no reason for the host ever to write to the MSR, and it isn't > even readable. > > [...] Applied to kvm-x86 xen, thanks! I'll post v2 of my series on top. [1/1] KVM: x86/xen: Only write Xen hypercall page for guest writes to MSR https://github.com/kvm-x86/linux/commit/3617c0ee7dec -- https://github.com/kvm-x86/linux/tree/next
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6d4a6734b2d6..f1ecba788d0a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3733,7 +3733,13 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) u32 msr = msr_info->index; u64 data = msr_info->data; - if (msr && msr == vcpu->kvm->arch.xen_hvm_config.msr) + /* + * Do not allow host-initiated writes to trigger the Xen hypercall + * page setup; it could incur locking paths which are not expected + * if userspace sets the MSR in an unusual location. + */ + if (msr && msr == vcpu->kvm->arch.xen_hvm_config.msr && + !msr_info->host_initiated) return kvm_xen_write_hypercall_page(vcpu, data); switch (msr) {