RE: [PATCH V1 2/2] Drivers: hv: Fix bugs and issues around repeat hypercall
From: Vitaly Kuznetsov
Date: Mon Nov 16 2026 - 11:53:51 EST
Michael Kelley <mhklinux@xxxxxxxxxxx> writes:
...
>>
>> - do {
>
> Dropped the looping behavior here may be much more significant
> than just "streamlining" as described in the commit message. The looping
> behavior was included when rep hypercalls were originally added in
> commit 806c89273bab in kernel 4.14, long before any SNP/TDX/CCA
> functionality was added. So it was present for "normal" VMs doing
> hypercalls on x86/x64 the normal way. The looping ensured that
> rep hypercalls could not return with no errors but with the completed
> rep count less than the requested rep count.
>
> However, in my mind it *is* debatable whether that scenario could
> ever occur. The Hyper-V TLFS describes "Hypercall Continuation" [1]
> as essentially transparent to the caller. If a rep hypercall stops
> processing reps because of hitting the 50 microsecond time limit,
> it should restart and continue with the next set of reps without
> the caller having to loop. Commit 806c89273bab mentions
> hypercall continuation, but does not describe why the explicit
> looping was added or how that aligns with the TLFS statements.
> Vitaly -- it was a long time ago, but do you have any recollection?
>
> Have you gotten an explicit assurance from the Hyper-V team
> that the transparent hypercall continuation really does work,
> and the explicit looping has all along been unnecessary? This
> assurance would be needed back to and including Windows
> Server 2016, which is now the oldest Hyper-V version supported
> by Linux. Also note that the rep hypercall code is architecture
> independent, so the transparent hypercall continuation would
> also need to work on arm64 when the hypercall is invoked via
> the standard path of using the HVC instruction (the TLFS doesn't
> cover arm64, so this is unclear).
>
> If you have such assurance, then I'm good with the removal of
> the looping. But please make the removal a separate patch, with
> sufficient discussion in the commit message to justify why it's OK
> to do the removal (including that evidently the original commit
> misinterpreted how continuation worked). And instead of looping,
> perhaps do a sanity check that the completed rep count matches
> the requested rep count.
>
> Without such assurance, I think the looping needs to stay. Callers
> are not prepared for a rep hypercall to return with no errors, but
> with the completed rep count less than the requested rep count.
>
> [1] https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/hypercall-interface#hypercall-continuation
>
It's been almost a decade since the looping behavior was added, it is
very possible that I was using WS2012 for development back then. The
commit says that the feature was required for HvFlushVirtualAddressList;
I don't have any evidence left but I'm pretty sure 'incomplete' returns
were observed. It is, of course, possible that I only observed them in
synthetic testing when stuffing hypercall input to the maximum by some
random data.
Overall, I agree with the proposal: keep the looping unless we get an
explicit assurance from the host team that it can be dropped.
--
Vitaly