Skip to content

Commit 999ad14

Browse files
mhklinuxliuw
authored andcommitted
x86/hyperv: Add comments about hv_vpset and var size hypercall input args
Current code varies in how the size of the variable size input header for hypercalls is calculated when the input contains struct hv_vpset. Surprisingly, this variation is correct, as different hypercalls make different choices for what portion of struct hv_vpset is treated as part of the variable size input header. The Hyper-V TLFS is silent on these details, but the behavior has been confirmed with Hyper-V developers. To avoid future confusion about these differences, add comments to struct hv_vpset, and to hypercall call sites with input that contains a struct hv_vpset. The comments describe the overall situation and the calculation that should be used at each particular call site. No functional change as only comments are updated. Signed-off-by: Michael Kelley <mhklinux@outlook.com> Link: https://lore.kernel.org/r/20250318214919.958953-1-mhklinux@outlook.com Signed-off-by: Wei Liu <wei.liu@kernel.org> Message-ID: <20250318214919.958953-1-mhklinux@outlook.com>
1 parent 621191d commit 999ad14

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

arch/x86/hyperv/hv_apic.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ static bool __send_ipi_mask_ex(const struct cpumask *mask, int vector,
145145
ipi_arg->vp_set.format = HV_GENERIC_SET_ALL;
146146
}
147147

148+
/*
149+
* For this hypercall, Hyper-V treats the valid_bank_mask field
150+
* of ipi_arg->vp_set as part of the fixed size input header.
151+
* So the variable input header size is equal to nr_bank.
152+
*/
148153
status = hv_do_rep_hypercall(HVCALL_SEND_IPI_EX, 0, nr_bank,
149154
ipi_arg, NULL);
150155

arch/x86/hyperv/mmu.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ static u64 hyperv_flush_tlb_others_ex(const struct cpumask *cpus,
205205
/*
206206
* We can flush not more than max_gvas with one hypercall. Flush the
207207
* whole address space if we were asked to do more.
208+
*
209+
* For these hypercalls, Hyper-V treats the valid_bank_mask field
210+
* of flush->hv_vp_set as part of the fixed size input header.
211+
* So the variable input header size is equal to nr_bank.
208212
*/
209213
max_gvas =
210214
(PAGE_SIZE - sizeof(*flush) - nr_bank *

include/hyperv/hvgdk_mini.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,14 @@ union hv_reference_tsc_msr {
205205
/* The number of vCPUs in one sparse bank */
206206
#define HV_VCPUS_PER_SPARSE_BANK (64)
207207

208-
/* Some of Hyper-V structs do not use hv_vpset where linux uses them */
208+
/*
209+
* Some of Hyper-V structs do not use hv_vpset where linux uses them.
210+
*
211+
* struct hv_vpset is usually used as part of hypercall input. The portion
212+
* that counts as "fixed size input header" vs. "variable size input header"
213+
* varies per hypercall. See comments at relevant hypercall call sites as to
214+
* how the "valid_bank_mask" field should be accounted.
215+
*/
209216
struct hv_vpset { /* HV_VP_SET */
210217
u64 format;
211218
u64 valid_bank_mask;

0 commit comments

Comments
 (0)