[PATCH 2/3] Drivers: hv: Create REP_COUNT define

From: Mukesh R

Date: Thu Dec 03 2026 - 21:58:59 EST


When a repeat hypercall completes, it returns completions as part of
the status in bits 43-32, and HV_HYPERCALL_REP_COMP_MASK is used to
extract and examine it. When issuing a hypercall, the actual repeat
count is part of the input struct at same bits. However, the same
COMP_MASK is used to set it. This maybe confusing for anyone reading
the code. Add HV_HYPERCALL_REP_COUNT_MASK and use it for counts
instead of REP_COMP.

Signed-off-by: Mukesh R <mrathor@xxxxxxxxxxxxxxxxxxx>
---
arch/x86/kvm/hyperv.c | 2 +-
include/asm-generic/mshyperv.h | 2 +-
include/hyperv/hvgdk_mini.h | 8 ++++++--
3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 5d2e3617c952..ce40bb48016b 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -2579,7 +2579,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
hc.code = hc.param & 0xffff;
hc.var_cnt = (hc.param & HV_HYPERCALL_VARHEAD_MASK) >> HV_HYPERCALL_VARHEAD_OFFSET;
hc.fast = !!(hc.param & HV_HYPERCALL_FAST_BIT);
- hc.rep_cnt = (hc.param >> HV_HYPERCALL_REP_COMP_OFFSET) & 0xfff;
+ hc.rep_cnt = (hc.param >> HV_HYPERCALL_REP_COUNT_OFFSET) & 0xfff;
hc.rep_idx = (hc.param >> HV_HYPERCALL_REP_START_OFFSET) & 0xfff;
hc.rep = !!(hc.rep_cnt || hc.rep_idx);

diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index b9157ac8731c..9d4b4d1cdac3 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -143,7 +143,7 @@ static inline u64 hv_do_rep_hypercall_ex(u16 code, u16 rep_count,
u16 rep_comp;

control |= (u64)varhead_size << HV_HYPERCALL_VARHEAD_OFFSET;
- control |= (u64)rep_count << HV_HYPERCALL_REP_COMP_OFFSET;
+ control |= (u64)rep_count << HV_HYPERCALL_REP_COUNT_OFFSET;
control |= (u64)rep_start << HV_HYPERCALL_REP_START_OFFSET;

do {
diff --git a/include/hyperv/hvgdk_mini.h b/include/hyperv/hvgdk_mini.h
index bec4e633e381..160d0813e598 100644
--- a/include/hyperv/hvgdk_mini.h
+++ b/include/hyperv/hvgdk_mini.h
@@ -521,9 +521,9 @@ union hv_vp_assist_msr_contents { /* HV_REGISTER_VP_ASSIST_PAGE */
#define HV_HYPERCALL_VARHEAD_MASK GENMASK_ULL(26, 17)
#define HV_HYPERCALL_RSVD0_MASK GENMASK_ULL(31, 27)
#define HV_HYPERCALL_NESTED BIT_ULL(31)
-#define HV_HYPERCALL_REP_COMP_OFFSET 32
#define HV_HYPERCALL_REP_COMP_1 BIT_ULL(32)
-#define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32)
+#define HV_HYPERCALL_REP_COUNT_OFFSET 32
+#define HV_HYPERCALL_REP_COUNT_MASK GENMASK_ULL(43, 32)
#define HV_HYPERCALL_RSVD1_MASK GENMASK_ULL(47, 44)
#define HV_HYPERCALL_REP_START_OFFSET 48
#define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48)
@@ -532,6 +532,10 @@ union hv_vp_assist_msr_contents { /* HV_REGISTER_VP_ASSIST_PAGE */
HV_HYPERCALL_RSVD1_MASK | \
HV_HYPERCALL_RSVD2_MASK)

+/* Hypercall output status */
+#define HV_HYPERCALL_REP_COMP_OFFSET 32
+#define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32)
+
/* HvFlushGuestPhysicalAddressSpace hypercalls */
struct hv_guest_mapping_flush {
u64 address_space;
--
2.51.2.vfs.0.1