Re: [PATCH v3 06/12] KVM: x86: Forward VMware hypercalls to userspace
From: David Woodhouse
Date: Mon Nov 16 2026 - 18:57:05 EST
On 16 November 2026 22:27:28 GMT, 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.
Yeah, none of us had really had the time to consider it deeply.
For VMware and Huper-V I do believe we need to raise the fault *on* the instruction, not after it. But that's achievable.
I had also added a third user of the same cancellation today — we need to intercept certain control register writes and need to raise various exceptions for those too.
WIP of that at
https://git.infradead.org/users/dwmw2/linux.git/shortlog/refs/heads/vsm3/regwr-filter-v5
I think I would still prefer to use KVM_SET_VCPU_EVENTS rather than shoe-horning the same facility into the return part of various different kvm_run exit structs. But I won't fight for KVM_SET_VCPU_EVENTS to do the cancellation. How about we just give each of the exit types a way to indicate whether to advance the RIP because the instruction is completing) or not (because the instruction is faulting)?
>If the exception is communicated through some other means, then (a) that needs
>to be explained in detail, and (b) we should be able to use the same appraoch,
>just with new "ret" field or whatever in kvm_hyperv_exit.u.hcall.
I do think it is a full 64-bit return value *or* an exception. My friend did originally abuse bit 63 of the return value and I may have thrown my toys out of the pram at it a little bit... they can type fast, but my God they are stupid sometimes.