Re: [PATCH v2 0/4] KVM: x86: hyper-v: Forward unimplemented hypercalls to userspace

From: David Woodhouse

Date: Fri Nov 13 2026 - 15:57:44 EST


On 13 November 2026 10:10:40 GMT-07:00, Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>On Fri, Nov 13, 2026, David Woodhouse wrote:
>> From: David Woodhouse <dwmw@xxxxxxxxxxxx>
>>
>> KVM implements a fixed set of Hyper-V hypercalls and fails every other
>> code with HV_STATUS_INVALID_HYPERCALL_CODE. A VMM that wants to
>> implement more of the TLFS, such as the VSM hypercalls Windows uses for
>> Virtualization Based Security, never sees them.
>>
>> This series adds KVM_CAP_HYPERV_FORWARD_HCALL. As with KVM_CAP_XEN_HVM
>> and KVM_CAP_EXIT_HYPERCALL, KVM_CHECK_EXTENSION returns a bitmask of
>> features and KVM_ENABLE_CAP takes the subset to enable, rejecting any
>> bit the kernel does not report. The first feature,
>> KVM_HYPERV_HCALL_FORWARD_UNKNOWN, sends the hypercalls KVM does not
>> implement, and extended hypercalls in fast form, out through the
>> existing KVM_EXIT_HYPERV_HCALL exit, whose format does not change at
>> all.
>
>I'm not a fan of fowarding unknown hypercalls. It seems like it would be quite
>easy to end up with a mess where it's difficult for KVM to implement "native"
>support without breaking userspace.
>
>How much code (and ongoing churn) would it be to add an allowlist of hypercalls
>to forward to userspace? And then obviously require userspace to configure its
>forwarding "intercepts".

I'm following the model we used for Xen support, where the default assumption is that we do everything in userspace, then accelerate only what's absolutely necessary in the kernel.

Userspace can opt *in* to having the kernel support certain hypercalls, and later patches waiting in the wings already add the in-kernel VTL switching enabled via a bitmask when enabling the capability.