mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Kelley <mhklinux@outlook.com>
To: Mukesh R <mrathor@linux.microsoft.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "haiyangz@microsoft.com" <haiyangz@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	"decui@microsoft.com" <decui@microsoft.com>
Subject: RE: [PATCH] mshv: Handle completions on repeat hypercall failures
Date: Sat, 21 Nov 2026 23:30:23 +0000	[thread overview]
Message-ID: <MN2PR02MB686354DA3595E40B457C130DD4472@MN2PR02MB6863.namprd02.prod.outlook.com> (raw)
In-Reply-To: <20261120020858.3597446-1-mrathor@linux.microsoft.com>

From: Mukesh R <mrathor@linux.microsoft.com> Sent: Thursday, November 19, 2026 6:09 PM
> 
> When a repeat hypercall fails, it could still have completed some of the
> entries requested. Fix places where completions are not checked in case
> of repeat hypercall failures. Also, add error prints in couple places
> with correct partial completion counts when repeat hypercall fails.
> 
> Signed-off-by: Mukesh R <mrathor@linux.microsoft.com>

Reviewed-by:  Michael Kelley <mhklinux@outlook.com>

> ---
>  drivers/hv/mshv_common.c       | 17 +++++++++++++----
>  drivers/hv/mshv_root_hv_call.c | 15 +++++++++------
>  2 files changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/hv/mshv_common.c b/drivers/hv/mshv_common.c
> index 63f09bb5136e..580248a490ac 100644
> --- a/drivers/hv/mshv_common.c
> +++ b/drivers/hv/mshv_common.c
> @@ -56,8 +56,6 @@ int hv_call_get_vp_registers(u32 vp_index, u64 partition_id, u16 count,
> 
>  		status = hv_do_rep_hypercall(HVCALL_GET_VP_REGISTERS, rep_count,
>  					     0, input_page, output_page);
> -		if (!hv_result_success(status))
> -			break;
> 
>  		completed = hv_repcomp(status);
>  		for (i = 0; i < completed; ++i)
> @@ -65,6 +63,13 @@ int hv_call_get_vp_registers(u32 vp_index, u64 partition_id, u16 count,
> 
>  		registers += completed;
>  		remaining -= completed;
> +
> +		if (!hv_result_success(status)) {
> +			pr_err("%s: count:%d comp:%d rem:%ld st:0x%llx\n",
> +			       __func__, count, completed, remaining, status);
> +			break;
> +		}
> +
>  	}
>  	local_irq_restore(flags);
> 
> @@ -99,12 +104,16 @@ int hv_call_set_vp_registers(u32 vp_index, u64 partition_id, u16 count,
> 
>  		status = hv_do_rep_hypercall(HVCALL_SET_VP_REGISTERS, rep_count,
>  					     0, input_page, NULL);
> -		if (!hv_result_success(status))
> -			break;
> 
>  		completed = hv_repcomp(status);
>  		registers += completed;
>  		remaining -= completed;
> +
> +		if (!hv_result_success(status)) {
> +			pr_err("%s: count:%d comp:%d rem:%ld st:0x%llx\n",
> +			       __func__, count, completed, remaining, status);
> +			break;
> +		}
>  	}
> 
>  	local_irq_restore(flags);
> diff --git a/drivers/hv/mshv_root_hv_call.c b/drivers/hv/mshv_root_hv_call.c
> index e761addda50e..6261686c3638 100644
> --- a/drivers/hv/mshv_root_hv_call.c
> +++ b/drivers/hv/mshv_root_hv_call.c
> @@ -239,6 +239,7 @@ static int hv_do_map_gpa_hcall(u64 partition_id, u64 gfn, u64 page_struct_count,
>  		local_irq_restore(irq_flags);
> 
>  		completed = hv_repcomp(status);
> +		done += completed;
> 
>  		if (hv_result_needs_memory(status)) {
>  			ret = hv_deposit_memory(partition_id, status);
> @@ -246,11 +247,13 @@ static int hv_do_map_gpa_hcall(u64 partition_id, u64 gfn, u64 page_struct_count,
>  				break;
> 
>  		} else if (!hv_result_success(status)) {
> +			pr_err("%s: failed to map pages at gfn %#llx: done %u/%llu, flags=%#x, status=%#llx (%s)\n",
> +			       __func__, gfn, done, page_count, flags, status,
> +			       hv_result_to_string(hv_result(status)));
> +
>  			ret = hv_result_to_errno(status);
>  			break;
>  		}
> -
> -		done += completed;
>  	}
> 
>  	if (ret && done) {
> @@ -358,18 +361,18 @@ int hv_call_get_gpa_access_states(u64 partition_id, u32 count, u64 gpa_base_pfn,
> 
>  		status = hv_do_rep_hypercall(HVCALL_GET_GPA_PAGES_ACCESS_STATES, rep_count,
>  					     0, input_page, output_page);
> -		if (!hv_result_success(status)) {
> -			local_irq_restore(flags);
> -			break;
> -		}
>  		completed = hv_repcomp(status);
>  		for (i = 0; i < completed; ++i)
>  			states[i].as_uint8 = output_page[i].as_uint8;
> 
>  		local_irq_restore(flags);
> +
>  		states += completed;
>  		*written_total += completed;
>  		remaining -= completed;
> +
> +		if (!hv_result_success(status))
> +			break;
>  	}
> 
>  	return hv_result_to_errno(status);
> --
> 2.51.2.vfs.0.1
> 


      reply	other threads:[~2026-11-21 23:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  2:08 Mukesh R
2026-11-21 23:30 ` Michael Kelley [this message]

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=MN2PR02MB686354DA3595E40B457C130DD4472@MN2PR02MB6863.namprd02.prod.outlook.com \
    --to=mhklinux@outlook.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mrathor@linux.microsoft.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®