From: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
To: Michael Kelley <mhklinux@outlook.com>
Cc: "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>,
Nuno Das Neves <nunodasneves@linux.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 v7 5/7] Drivers: hv: Improve region overlap detection in partition create
Date: Wed, 3 Dec 2025 09:46:44 -0800 [thread overview]
Message-ID: <aTB3hJ94SpwEUk_r@skinsburskii.localdomain> (raw)
In-Reply-To: <SN6PR02MB41573FF177210DBC95509B09D4D8A@SN6PR02MB4157.namprd02.prod.outlook.com>
On Tue, Dec 02, 2025 at 06:39:51PM +0000, Michael Kelley wrote:
> From: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com> Sent: Tuesday, November 25, 2025 6:09 PM
> >
> > Refactor region overlap check in mshv_partition_create_region to use
> > mshv_partition_region_by_gfn for both start and end guest PFNs, replacing
> > manual iteration.
> >
> > This is a cleaner approach that leverages existing functionality to
> > accurately detect overlapping memory regions.
>
> Unfortunately, the cleaner approach doesn't work. :-( It doesn't detect a
> new region request that completely overlaps an existing region.
>
> See https://lore.kernel.org/linux-hyperv/6a5f4ed5-63ae-4760-84c9-7290aaff8bd1@linux.microsoft.com/T/#ma91254da1900de61da520acb96c0de38c43562f6.
> I couldn't see anything that prevents the scenario. Nuno created this
> patch less than a month ago: https://lore.kernel.org/linux-hyperv/1762467211-8213-2-git-send-email-nunodasneves@linux.microsoft.com/.
>
> Michael
>
I see.
I'll drop it then.
Thanks,
Stanislav
> >
> > Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
> > ---
> > drivers/hv/mshv_root_main.c | 8 ++------
> > 1 file changed, 2 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> > index 5dfb933da981..ae600b927f49 100644
> > --- a/drivers/hv/mshv_root_main.c
> > +++ b/drivers/hv/mshv_root_main.c
> > @@ -1086,13 +1086,9 @@ static int mshv_partition_create_region(struct
> > mshv_partition *partition,
> > u64 nr_pages = HVPFN_DOWN(mem->size);
> >
> > /* Reject overlapping regions */
> > - hlist_for_each_entry(rg, &partition->pt_mem_regions, hnode) {
> > - if (mem->guest_pfn + nr_pages <= rg->start_gfn ||
> > - rg->start_gfn + rg->nr_pages <= mem->guest_pfn)
> > - continue;
> > -
> > + if (mshv_partition_region_by_gfn(partition, mem->guest_pfn) ||
> > + mshv_partition_region_by_gfn(partition, mem->guest_pfn + nr_pages - 1))
> > return -EEXIST;
> > - }
> >
> > rg = mshv_region_create(mem->guest_pfn, nr_pages,
> > mem->userspace_addr, mem->flags,
> >
> >
>
next prev parent reply other threads:[~2025-12-03 17:46 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 2:08 [PATCH v7 0/7] Introduce movable pages for Hyper-V guests Stanislav Kinsburskii
2025-11-26 2:08 ` [PATCH v7 1/7] Drivers: hv: Refactor and rename memory region handling functions Stanislav Kinsburskii
2025-12-01 11:20 ` Anirudh Rayabharam
2025-11-26 2:08 ` [PATCH v7 2/7] Drivers: hv: Centralize guest memory region destruction Stanislav Kinsburskii
2025-12-01 11:12 ` Anirudh Rayabharam
2025-11-26 2:09 ` [PATCH v7 3/7] Drivers: hv: Move region management to mshv_regions.c Stanislav Kinsburskii
2025-12-01 11:06 ` Anirudh Rayabharam
2025-12-01 16:46 ` Stanislav Kinsburskii
2025-12-03 18:13 ` Nuno Das Neves
2025-12-03 18:20 ` Stanislav Kinsburskii
2025-11-26 2:09 ` [PATCH v7 4/7] Drivers: hv: Fix huge page handling in memory region traversal Stanislav Kinsburskii
2025-11-27 10:59 ` kernel test robot
2025-12-01 15:09 ` Anirudh Rayabharam
2025-12-01 18:26 ` Stanislav Kinsburskii
2025-12-03 18:50 ` Nuno Das Neves
2025-12-04 16:03 ` Michael Kelley
2025-12-04 21:08 ` Stanislav Kinsburskii
2025-12-11 17:37 ` Michael Kelley
2025-12-15 20:12 ` Stanislav Kinsburskii
2025-12-17 0:54 ` Stanislav Kinsburskii
2025-11-26 2:09 ` [PATCH v7 5/7] Drivers: hv: Improve region overlap detection in partition create Stanislav Kinsburskii
2025-12-01 15:06 ` Anirudh Rayabharam
2025-12-02 18:39 ` Michael Kelley
2025-12-03 17:46 ` Stanislav Kinsburskii [this message]
2025-12-03 18:58 ` Nuno Das Neves
2025-12-03 19:36 ` Nuno Das Neves
2025-11-26 2:09 ` [PATCH v7 6/7] Drivers: hv: Add refcount and locking to mem regions Stanislav Kinsburskii
2025-12-04 16:48 ` Michael Kelley
2025-12-04 21:23 ` Stanislav Kinsburskii
2025-11-26 2:09 ` [PATCH v7 7/7] Drivers: hv: Add support for movable memory regions Stanislav Kinsburskii
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=aTB3hJ94SpwEUk_r@skinsburskii.localdomain \
--to=skinsburskii@linux.microsoft.com \
--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=mhklinux@outlook.com \
--cc=nunodasneves@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