[PATCH] mshv: remove page order restriction to enable 1G hugepage support

Anirudh Rayabharam (Microsoft) posted 1 patch 2 months ago
drivers/hv/mshv_regions.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
[PATCH] mshv: remove page order restriction to enable 1G hugepage support
Posted by Anirudh Rayabharam (Microsoft) 2 months ago
The hypervisor's map GPA hypercall handles large pages intelligently,
combining 2M pages into 1G mappings when alignment allows.

Remove the PMD_ORDER check in mshv_chunk_stride() so that 1G hugepages
and other large page orders are passed through as 2M-aligned chunks,
letting the hypervisor promote them to 1G mappings automatically.

Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
---
 drivers/hv/mshv_regions.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/hv/mshv_regions.c b/drivers/hv/mshv_regions.c
index fdffd4f002f6..5f617a96d97a 100644
--- a/drivers/hv/mshv_regions.c
+++ b/drivers/hv/mshv_regions.c
@@ -29,7 +29,7 @@
  * Uses huge page stride if the backing page is huge and the guest mapping
  * is properly aligned; otherwise falls back to single page stride.
  *
- * Return: Stride in pages, or -EINVAL if page order is unsupported.
+ * Return: Stride in pages.
  */
 static int mshv_chunk_stride(struct page *page,
 			     u64 gfn, u64 page_count)
@@ -47,9 +47,6 @@ static int mshv_chunk_stride(struct page *page,
 		return 1;
 
 	page_order = folio_order(page_folio(page));
-	/* The hypervisor only supports 2M huge page */
-	if (page_order != PMD_ORDER)
-		return -EINVAL;
 
 	return 1 << page_order;
 }

---
base-commit: cd9f2e7d6e5b1837ef40b96e300fa28b73ab5a77
change-id: 20260416-huge_1g-e44461393c8f

Best regards,
-- 
Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
Re: [PATCH] mshv: remove page order restriction to enable 1G hugepage support
Posted by Stanislav Kinsburskii 1 month, 3 weeks ago
On Thu, Apr 16, 2026 at 01:37:15PM +0000, Anirudh Rayabharam (Microsoft) wrote:
> The hypervisor's map GPA hypercall handles large pages intelligently,
> combining 2M pages into 1G mappings when alignment allows.
> 
> Remove the PMD_ORDER check in mshv_chunk_stride() so that 1G hugepages
> and other large page orders are passed through as 2M-aligned chunks,
> letting the hypervisor promote them to 1G mappings automatically.
> 
> Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
> ---
>  drivers/hv/mshv_regions.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/hv/mshv_regions.c b/drivers/hv/mshv_regions.c
> index fdffd4f002f6..5f617a96d97a 100644
> --- a/drivers/hv/mshv_regions.c
> +++ b/drivers/hv/mshv_regions.c
> @@ -29,7 +29,7 @@
>   * Uses huge page stride if the backing page is huge and the guest mapping
>   * is properly aligned; otherwise falls back to single page stride.
>   *
> - * Return: Stride in pages, or -EINVAL if page order is unsupported.
> + * Return: Stride in pages.
>   */
>  static int mshv_chunk_stride(struct page *page,
>  			     u64 gfn, u64 page_count)

Nit: the return type of the function should now become unsigned.

Reviewed-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>

> @@ -47,9 +47,6 @@ static int mshv_chunk_stride(struct page *page,
>  		return 1;
>  
>  	page_order = folio_order(page_folio(page));
> -	/* The hypervisor only supports 2M huge page */
> -	if (page_order != PMD_ORDER)
> -		return -EINVAL;
>  
>  	return 1 << page_order;
>  }
> 
> ---
> base-commit: cd9f2e7d6e5b1837ef40b96e300fa28b73ab5a77
> change-id: 20260416-huge_1g-e44461393c8f
> 
> Best regards,
> -- 
> Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
>
Re: [PATCH] mshv: remove page order restriction to enable 1G hugepage support
Posted by Anirudh Rayabharam 1 month, 2 weeks ago
On Mon, Apr 20, 2026 at 09:56:28AM -0700, Stanislav Kinsburskii wrote:
> On Thu, Apr 16, 2026 at 01:37:15PM +0000, Anirudh Rayabharam (Microsoft) wrote:
> > The hypervisor's map GPA hypercall handles large pages intelligently,
> > combining 2M pages into 1G mappings when alignment allows.
> > 
> > Remove the PMD_ORDER check in mshv_chunk_stride() so that 1G hugepages
> > and other large page orders are passed through as 2M-aligned chunks,
> > letting the hypervisor promote them to 1G mappings automatically.
> > 
> > Signed-off-by: Anirudh Rayabharam (Microsoft) <anirudh@anirudhrb.com>
> > ---
> >  drivers/hv/mshv_regions.c | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> > 
> > diff --git a/drivers/hv/mshv_regions.c b/drivers/hv/mshv_regions.c
> > index fdffd4f002f6..5f617a96d97a 100644
> > --- a/drivers/hv/mshv_regions.c
> > +++ b/drivers/hv/mshv_regions.c
> > @@ -29,7 +29,7 @@
> >   * Uses huge page stride if the backing page is huge and the guest mapping
> >   * is properly aligned; otherwise falls back to single page stride.
> >   *
> > - * Return: Stride in pages, or -EINVAL if page order is unsupported.
> > + * Return: Stride in pages.
> >   */
> >  static int mshv_chunk_stride(struct page *page,
> >  			     u64 gfn, u64 page_count)
> 
> Nit: the return type of the function should now become unsigned.

Thanks I'll prepare a v2 with this and also look into Sashiko's comments
on this patch.

Thanks,
Anirudh.