public inbox for linux-hyperv@vger.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu@kernel.org>
To: Michael Kelley <mhklinux@outlook.com>
Cc: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>,
	"kys@microsoft.com" <kys@microsoft.com>,
	"haiyangz@microsoft.com" <haiyangz@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	"decui@microsoft.com" <decui@microsoft.com>,
	"longli@microsoft.com" <longli@microsoft.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 4/4] mshv: Handle insufficient root memory hypervisor statuses
Date: Thu, 19 Feb 2026 06:47:01 +0000	[thread overview]
Message-ID: <20260219064701.GQ2236050@liuwe-devbox-debian-v2.local> (raw)
In-Reply-To: <SN6PR02MB4157F28C4F4CEFB886CF949ED466A@SN6PR02MB4157.namprd02.prod.outlook.com>

On Fri, Feb 06, 2026 at 06:54:55PM +0000, Michael Kelley wrote:
> From: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> Sent: Thursday, February 5, 2026 10:42 AM
> > To: kys@microsoft.com; haiyangz@microsoft.com; wei.liu@kernel.org;
> > decui@microsoft.com; longli@microsoft.com
> > Cc: linux-hyperv@vger.kernel.org; linux-kernel@vger.kernel.org
> > Subject: [PATCH v3 4/4] mshv: Handle insufficient root memory hypervisor statuses
> > 
> > When creating guest partition objects, the hypervisor may fail to
> > allocate root partition pages and return an insufficient memory status.
> > In this case, deposit memory using the root partition ID instead.
> > 
> > Note: This error should never occur in a guest of L1VH partition context.
> > 
> > Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
> > ---
> >  drivers/hv/hv_common.c      |    2 +
> >  drivers/hv/hv_proc.c        |   14 ++++++++++
> >  include/hyperv/hvgdk_mini.h |   58 ++++++++++++++++++++++---------------------
> >  3 files changed, 46 insertions(+), 28 deletions(-)
> > 
> > diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
> > index f20596276662..6b67ac616789 100644
> > --- a/drivers/hv/hv_common.c
> > +++ b/drivers/hv/hv_common.c
> > @@ -794,6 +794,8 @@ static const struct hv_status_info hv_status_infos[] = {
> >  	_STATUS_INFO(HV_STATUS_PROPERTY_VALUE_OUT_OF_RANGE,	-EIO),
> >  	_STATUS_INFO(HV_STATUS_INSUFFICIENT_MEMORY,		-ENOMEM),
> >  	_STATUS_INFO(HV_STATUS_INSUFFICIENT_CONTIGUOUS_MEMORY,	-ENOMEM),
> > +	_STATUS_INFO(HV_STATUS_INSUFFICIENT_ROOT_MEMORY,	-ENOMEM),
> > +	_STATUS_INFO(HV_STATUS_INSUFFICIENT_CONTIGUOUS_ROOT_MEMORY, 	-ENOMEM),
> >  	_STATUS_INFO(HV_STATUS_INVALID_PARTITION_ID,		-EINVAL),
> >  	_STATUS_INFO(HV_STATUS_INVALID_VP_INDEX,		-EINVAL),
> >  	_STATUS_INFO(HV_STATUS_NOT_FOUND,			-EIO),
> > diff --git a/drivers/hv/hv_proc.c b/drivers/hv/hv_proc.c
> > index 181f6d02bce3..5f4fd9c3231c 100644
> > --- a/drivers/hv/hv_proc.c
> > +++ b/drivers/hv/hv_proc.c
> > @@ -121,6 +121,18 @@ int hv_deposit_memory_node(int node, u64 partition_id,
> >  	case HV_STATUS_INSUFFICIENT_CONTIGUOUS_MEMORY:
> >  		num_pages = HV_MAX_CONTIGUOUS_ALLOCATION_PAGES;
> >  		break;
> > +
> > +	case HV_STATUS_INSUFFICIENT_CONTIGUOUS_ROOT_MEMORY:
> > +		num_pages = HV_MAX_CONTIGUOUS_ALLOCATION_PAGES;
> > +		fallthrough;
> > +	case HV_STATUS_INSUFFICIENT_ROOT_MEMORY:
> > +		if (!hv_root_partition()) {
> > +			hv_status_err(hv_status, "Unexpected root memory deposit\n");
> > +			return -ENOMEM;
> > +		}
> > +		partition_id = HV_PARTITION_ID_SELF;
> > +		break;
> > +
> 
> Per the discussion in v1 of this patch set, if the number of pages that should be
> deposited in a particular situation is different from what this function provides,
> the fallback is to use hv_call_deposit_pages() directly. From what I see, there's
> only one such fallback case after a hypercall failure -- in hv_do_map_gpa_hcall().
> The other uses of hv_call_deposit_pages() are initial deposits when creating a
> VP or partition.
> 
> But if hv_call_deposit_pages() is used directly, the logic added here to detect
> insufficient root memory and deposit to HV_PARTITION_ID_SELF isn't applied.
> So if the hypercall in hv_do_map_gpa_hcall() fails with insufficient root
> memory, the deposit is done to the wrong partition ID. If that case can
> actually happen, then some additional logic is needed in
> hv_do_map_gpa_hcall() to handle it. Or there needs to be a fallback
> function that contains the logic.

Stanislav, how about this comment? Please submit a follow-up patch if
necessary.

Wei

> 
> Other than that, everything else in this patch set looks good to me.
> 
> Michael
> 
> >  	default:
> >  		hv_status_err(hv_status, "Unexpected!\n");
> >  		return -ENOMEM;

  reply	other threads:[~2026-02-19  6:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05 18:42 [PATCH v3 0/4] Improve Hyper-V memory deposit error handling Stanislav Kinsburskii
2026-02-05 18:42 ` [PATCH v3 1/4] mshv: Introduce hv_result_needs_memory() helper function Stanislav Kinsburskii
2026-02-05 18:42 ` [PATCH v3 2/4] mshv: Introduce hv_deposit_memory helper functions Stanislav Kinsburskii
2026-02-05 18:42 ` [PATCH v3 3/4] mshv: Handle insufficient contiguous memory hypervisor status Stanislav Kinsburskii
2026-02-05 18:42 ` [PATCH v3 4/4] mshv: Handle insufficient root memory hypervisor statuses Stanislav Kinsburskii
2026-02-06  5:56   ` Anirudh Rayabharam
2026-02-06 17:02     ` Stanislav Kinsburskii
2026-02-19  6:44     ` Wei Liu
2026-02-06 18:54   ` Michael Kelley
2026-02-19  6:47     ` Wei Liu [this message]
2026-02-19 21:46       ` Stanislav Kinsburskii
2026-02-19  6:49 ` [PATCH v3 0/4] Improve Hyper-V memory deposit error handling Wei Liu

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=20260219064701.GQ2236050@liuwe-devbox-debian-v2.local \
    --to=wei.liu@kernel.org \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=mhklinux@outlook.com \
    --cc=skinsburskii@linux.microsoft.com \
    /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