Re: [PATCH v3 06/12] KVM: x86: Forward VMware hypercalls to userspace

From: Zack Rusin

Date: Tue Nov 17 2026 - 16:42:41 EST


On Mon, Nov 16, 2026 at 5:27 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
> On Fri, Nov 13, 2026, David Woodhouse wrote:
> > On Fri, 2026-11-13 at 01:33 -0500, Zack Rusin wrote:
> > > > Userspace *already* needed to
> > > > know about those¹ because it can't migrate while those are pending;
> > > > it has to do at least one more run, even if it's with the immediate_exit
> > > > flag set.
> > >
> > > True, but, again afaict, that rule exists because those completions
> > > have to run, so I don't think it tells us they can be dropped.
> > >
> > > > If it's deemed clearer, I'd also be OK with an explicit
> > > > KVM_VCPUEVENT_CANCEL_HCALL which cancels *only* hypercalls. But I don't
> > > > really see the point; userspace shouldn't be getting confused when it
> > > > was actually some other kind of completion that was active anyway.
> > > >
> > > > ¹ https://lore.kernel.org/all/20250111012450.1262638-1-seanjc@xxxxxxxxxx/
> > > >
> > > > Looks something like this in my Hyper-V hcall series (except I already
> > > > shouted at the agent for stupid struct layout and made it go run pahole
> > > > on everything it's working on).
> > >
> > > FWIW, restricting cancellation to explicitly marked completions looks
> > > good to me. If Sean/Paolo prefer that, I'm happy to mark our
> > > completion cancellable and drop our exception fields.
> >
> > I posted that as
> > https://lore.kernel.org/kvm/20261113170535.79246-3-dwmw2@xxxxxxxxxxxxx/T/#u
> > and caught both Paolo and Sean here at KVM Forum and both seem OK with it
> > (although acquiescence when badgered at a conference doesn't necessarily
> > translate to applying the patch... :)
>
> Heh, you jinxed yourself.
>
> Adding something to KVM_SET_VCPU_EVENTS is complete overkill, and will create a
> confusing ABI for hypercalls versus MSR exits. For the latter, KVM lets userspace
> signal success/failure, and injects a #GP on failure.
>
> The VMware case in particular is a bit different since that case needs to inject
> a variety of faults, with a payload, but the concept is the same: give userspace
> a way to cancel/reject the hypercall/action. And that's dead simple, e.g.
>
> static int complete_vmware_hypercall_exit(struct kvm_vcpu *vcpu)
> {
> if (vcpu->run->vmware.ret)
> return 1;
>
> return kvm_skip_emulated_instruction(vcpu);
> }

That sounds good to me. In the next version I'll replace the exception
fields with ret. A non-zero ret will leave RIP at the hypercall, and
I think the userspace can queue the fault through vCPU events. For
partial progress it can pass REGS and EVENTS together on the next
KVM_RUN. I'll keep the linear-RIP check.

z

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature