All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mukesh R <mrathor@linux.microsoft.com>
To: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
	mhkelley58@gmail.com, kameroncarr@linux.microsoft.com
Subject: [PATCH 2/3] Drivers: hv: Create REP_COUNT define
Date: Thu,  3 Dec 2026 18:58:35 -0800	[thread overview]
Message-ID: <20261204025836.3855312-3-mrathor@linux.microsoft.com> (raw)
In-Reply-To: <20261204025836.3855312-1-mrathor@linux.microsoft.com>

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@linux.microsoft.com>
---
 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


  parent reply	other threads:[~2026-12-04  2:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  2:58 [PATCH 0/3] Handle timeouts for x86 CVMs Mukesh R
2026-12-04  2:58 ` [PATCH 1/3] Drivers: hv: Rename HV_STATUS_TIME_OUT Mukesh R
2026-12-04  2:58 ` Mukesh R [this message]
2026-12-04  3:13   ` [PATCH 2/3] Drivers: hv: Create REP_COUNT define sashiko-bot
2026-12-04  2:58 ` [PATCH 3/3] x86/hyperv: Handle hypercall timeouts on hw confidential VMs Mukesh R
2026-12-04  3:16   ` sashiko-bot
2026-12-05  0:00     ` Mukesh R
2026-12-05  8:21   ` vdso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261204025836.3855312-3-mrathor@linux.microsoft.com \
    --to=mrathor@linux.microsoft.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kameroncarr@linux.microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhkelley58@gmail.com \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.