mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nuno Das Neves <nunodasneves@linux.microsoft.com>
To: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>,
	kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
	decui@microsoft.com
Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 4/5] Drivers: hv: Ensure large page GPA mapping is PMD-aligned
Date: Fri, 10 Oct 2025 16:07:40 -0700	[thread overview]
Message-ID: <c84cb93c-7248-4f56-8b16-9b1c6b481a64@linux.microsoft.com> (raw)
In-Reply-To: <175976319301.16834.18430498559434584549.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net>

On 10/6/2025 8:06 AM, Stanislav Kinsburskii wrote:
> With the upcoming introduction of movable pages, a region doesn't guarantee
> always having large pages mapped. Both mapping on fault and unmapping
> during PTE invalidation may not be 2M-aligned, while the hypervisor
> requires both the GFN and page count to be 2M-aligned to use the large page
> flag.
> 
> Update the logic for large page mapping in mshv_region_remap_pages() to
> require both page_offset and page_count to be PMD-aligned.
> 
> Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
> ---
>  drivers/hv/mshv_root_main.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hv/mshv_root_main.c b/drivers/hv/mshv_root_main.c
> index b61bef6b9c132..cb462495f34b5 100644
> --- a/drivers/hv/mshv_root_main.c
> +++ b/drivers/hv/mshv_root_main.c
> @@ -34,6 +34,8 @@
>  #include "mshv.h"
>  #include "mshv_root.h"
>  
> +#define VALUE_PMD_ALIGNED(c)			(!((c) & (PTRS_PER_PMD - 1)))
> +
>  MODULE_AUTHOR("Microsoft");
>  MODULE_LICENSE("GPL");
>  MODULE_DESCRIPTION("Microsoft Hyper-V root partition VMM interface /dev/mshv");
> @@ -1100,7 +1102,9 @@ mshv_region_remap_pages(struct mshv_mem_region *region, u32 map_flags,
>  	if (page_offset + page_count > region->nr_pages)
>  		return -EINVAL;
>  
> -	if (region->flags.large_pages)
> +	if (region->flags.large_pages &&
> +	    VALUE_PMD_ALIGNED(page_offset) &&
> +	    VALUE_PMD_ALIGNED(page_count))
>  		map_flags |= HV_MAP_GPA_LARGE_PAGE;
>  
>  	/* ask the hypervisor to map guest ram */
> 
> 

Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>

  reply	other threads:[~2025-10-10 23:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-06 15:06 [PATCH v4 0/5] Introduce movable pages for Hyper-V guests Stanislav Kinsburskii
2025-10-06 15:06 ` [PATCH v4 1/5] Drivers: hv: Refactor and rename memory region handling functions Stanislav Kinsburskii
2025-10-10 22:49   ` Nuno Das Neves
2025-10-06 15:06 ` [PATCH v4 2/5] Drivers: hv: Centralize guest memory region destruction Stanislav Kinsburskii
2025-10-10 22:54   ` Nuno Das Neves
2025-10-06 15:06 ` [PATCH v4 3/5] Drivers: hv: Batch GPA unmap operations to improve large region performance Stanislav Kinsburskii
2025-10-06 17:09   ` Michael Kelley
2025-10-06 23:32     ` Stanislav Kinsburskii
2025-10-07  0:02       ` Michael Kelley
2025-10-10 23:06   ` Nuno Das Neves
2025-10-06 15:06 ` [PATCH v4 4/5] Drivers: hv: Ensure large page GPA mapping is PMD-aligned Stanislav Kinsburskii
2025-10-10 23:07   ` Nuno Das Neves [this message]
2025-10-06 15:06 ` [PATCH v4 5/5] Drivers: hv: Add support for movable memory regions Stanislav Kinsburskii
2025-10-10 17:48   ` kernel test robot
2025-10-11  1:12   ` kernel test robot

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=c84cb93c-7248-4f56-8b16-9b1c6b481a64@linux.microsoft.com \
    --to=nunodasneves@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=skinsburskii@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®