On 28/04/2026 21:12, David Woodhouse wrote:
From: David Woodhouse <[email protected]>

Commit 3617c0ee7decb ("KVM: x86/xen: Only write Xen hypercall page for
guest writes to MSR") blocked host-initiated writes from triggering the
Xen hypercall page setup, to fix an SRCU usage violation when the
hypercall MSR index collides with a real MSR written during vCPU reset.

However, some VMMs legitimately need to trigger hypercall page setup
from host context. For example, a VMM may intercept the guest's MSR
write to track an epoch (for kexec/crash recovery), and then replay the
write as a host-initiated KVM_SET_MSRS to populate the hypercall page.
The host_initiated check breaks this use case.

Add KVM_XEN_VCPU_ATTR_TYPE_WRITE_HYPERCALL_PAGE as a new vcpu attribute
that explicitly invokes kvm_xen_write_hypercall_page() under proper
locking. This gives userspace a safe interface to trigger hypercall page
setup without going through the MSR write path, preserving the
host_initiated defence in depth while restoring the lost functionality.

Fixes: 3617c0ee7dec ("KVM: x86/xen: Only write Xen hypercall page for guest writes 
to MSR")
Signed-off-by: David Woodhouse <[email protected]>
---
  Documentation/virt/kvm/api.rst                | 11 +++
  arch/x86/include/uapi/asm/kvm.h               |  3 +
  arch/x86/kvm/x86.c                            |  3 +-
  arch/x86/kvm/xen.c                            |  7 ++
  .../selftests/kvm/x86/xen_vmcall_test.c       | 96 +++++++++++++++++++
  5 files changed, 119 insertions(+), 1 deletion(-)

Reviewed-by: Paul Durrant <[email protected]>


Reply via email to