On Thu, Feb 19, 2026 at 06:47:01AM +0000, Wei Liu wrote:
> On Fri, Feb 06, 2026 at 06:54:55PM +0000, Michael Kelley wrote:
> > From: Stanislav Kinsburskii <[email protected]> Sent: 
> > Thursday, February 5, 2026 10:42 AM
> > > To: [email protected]; [email protected]; [email protected];
> > > [email protected]; [email protected]
> > > Cc: [email protected]; [email protected]
> > > 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 <[email protected]>
> > > ---
> > >  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.
> 

I'll sumbit a follow-up patch.

Thanks,
Stanislav

> 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 via email to