Re: [PATCH] KVM: hyper-v: Add new exit reason HYPERV_OVERLAY

From: Paolo Bonzini
Date: Fri Apr 23 2021 - 06:15:12 EST


On 23/04/21 11:58, Alexander Graf wrote:
In theory userspace doesn't know how KVM wishes to implement the
hypercall page, especially if Xen hypercalls are enabled as well.

I'm not sure I agree with that sentiment :). User space is the one that sets the xen compat mode. All we need to do is declare the ORing as part of the KVM ABI. Which we effectively are doing already, because it's part of the ABI to the guest, no?

Good point. But it may change in the future based on KVM_ENABLE_CAP or whatever, and duplicating code between userspace and kernel is ugly. We already have too many unwritten conventions around CPUID, MSRs, get/set state ioctls, etc.

That said, this definitely tilts the balance against adding an ioctl to write the hypercall page contents. Userspace can either use the KVM_SET_MSR or assemble it on its own, and one of the two should be okay.

Paolo


But userspace has two plausible ways to get the page contents:

1) add a ioctl to write the hypercall page contents to an arbitrary
userspace address

2) after userspace updates the memslots to add the overlay page at the
right place, use KVM_SET_MSR from userspace (which won't be filtered
because it's host initiated)

The second has the advantage of not needing any new code at all, but
it's a bit more ugly.

The more of all of that hyper-v code we can have live in user space, the happier I am :).