Skip to contentSkip to conversation

Fix uio_hv_generic on systems with >4k page sizes

PATCH In review [email protected] 3 participants 13 messages May 6, 2025 – May 13, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v3 cover Fix uio_hv_generic on systems with >4k page sizes

From: Long Li <[email protected]>

UIO framework requires the device memory aligned to page boundary. Hyper-V may allocate some memory that is Hyper-V page aligned (4k) but not system page aligned.

Fix this by having Hyper-V always allocate those pages on system page boundary and expose them to user-mode.

Change in v2:
Added two more patches to the series:
"uio_hv_generic: Adjust ring size according to system page alignment" "Drivers: hv: Remove hv_free/alloc_* helpers"

Added more details in the commit message of "uio_hv_generic: Use correct size for interrupt and monitor pages"

Change in v3:
Rearranged the patch on removing hv_alloc/free* helpers Added "Drivers: hv: Use kzalloc for panic page allocation" Fixed typos.

Long Li (5):
Drivers: hv: Allocate interrupt and monitor pages aligned to system
page boundary
uio_hv_generic: Use correct size for interrupt and monitor pages
uio_hv_generic: Align ring size to system page
Drivers: hv: Use kzalloc for panic page allocation
Drivers: hv: Remove hv_alloc/free_* helpers

 drivers/hv/connection.c        | 23 ++++++++++++-----
 drivers/hv/hv_common.c         | 45 +++-------------------------------
 drivers/uio/uio_hv_generic.c   |  7 ++++--
 include/asm-generic/mshyperv.h |  4 ---
 4 files changed, 25 insertions(+), 54 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 1/5 Drivers: hv: Allocate interrupt and monitor pages aligned to system page boundary

From: Long Li <[email protected]>

There are use cases that interrupt and monitor pages are mapped to user-mode through UIO, so they need to be system page aligned. Some Hyper-V allocation APIs introduced earlier broke those requirements.

Fix this by using page allocation functions directly for interrupt and monitor pages.

Fixes ca48739e59df ("Drivers: hv: vmbus: Move Hyper-V page allocator to arch neutral code")
---
 drivers/hv/connection.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/hv/connection.c +17 -6
index 8351360bba16..be490c598785 100644
@@ -206,11 +206,20 @@ int vmbus_connect(void)
 	INIT_LIST_HEAD(&vmbus_connection.chn_list);
 	mutex_init(&vmbus_connection.channel_mutex);
 
+	/*
+	 * The following Hyper-V interrupt and monitor pages can be used by
+	 * UIO for mapping to user-space, so they should always be allocated on
+	 * system page boundaries. The system page size must be >= the Hyper-V
+	 * page size.
+	 */
+	BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE);
+
 	/*
 	 * Setup the vmbus event connection for channel interrupt
 	 * abstraction stuff
 	 */
-	vmbus_connection.int_page = hv_alloc_hyperv_zeroed_page();
+	vmbus_connection.int_page =
+		(void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
 	if (vmbus_connection.int_page == NULL) {
 		ret = -ENOMEM;
 		goto cleanup;
@@ -225,8 +234,8 @@ int vmbus_connect(void)
 	 * Setup the monitor notification facility. The 1st page for
 	 * parent->child and the 2nd page for child->parent
 	 */
-	vmbus_connection.monitor_pages[0] = hv_alloc_hyperv_page();
-	vmbus_connection.monitor_pages[1] = hv_alloc_hyperv_page();
+	vmbus_connection.monitor_pages[0] = (void *)__get_free_page(GFP_KERNEL);
+	vmbus_connection.monitor_pages[1] = (void *)__get_free_page(GFP_KERNEL);
 	if ((vmbus_connection.monitor_pages[0] == NULL) ||
 	    (vmbus_connection.monitor_pages[1] == NULL)) {
 		ret = -ENOMEM;
@@ -342,21 +351,23 @@ void vmbus_disconnect(void)
 		destroy_workqueue(vmbus_connection.work_queue);
 
 	if (vmbus_connection.int_page) {
-		hv_free_hyperv_page(vmbus_connection.int_page);
+		free_page((unsigned long)vmbus_connection.int_page);
 		vmbus_connection.int_page = NULL;
 	}
 
 	if (vmbus_connection.monitor_pages[0]) {
 		if (!set_memory_encrypted(
 			(unsigned long)vmbus_connection.monitor_pages[0], 1))
-			hv_free_hyperv_page(vmbus_connection.monitor_pages[0]);
+			free_page((unsigned long)
+				vmbus_connection.monitor_pages[0]);
 		vmbus_connection.monitor_pages[0] = NULL;
 	}
 
 	if (vmbus_connection.monitor_pages[1]) {
 		if (!set_memory_encrypted(
 			(unsigned long)vmbus_connection.monitor_pages[1], 1))
-			hv_free_hyperv_page(vmbus_connection.monitor_pages[1]);
+			free_page((unsigned long)
+				vmbus_connection.monitor_pages[1]);
 		vmbus_connection.monitor_pages[1] = NULL;
 	}
 }
Signature · 1 line
2.34.1
Reviewed-by on v3 1/5
#2 lore raw

RE: [Patch v3 1/5] Drivers: hv: Allocate interrupt and monitor pages aligned to system page boundary

From: [email protected] <[email protected]> Sent: Monday, May 5, 2025 5:57 PM

Quoted 80 lines

There are use cases that interrupt and monitor pages are mapped to user-mode through UIO, so they need to be system page aligned. Some Hyper-V allocation APIs introduced earlier broke those requirements.

Fix this by using page allocation functions directly for interrupt and monitor pages.

Fixes ca48739e59df ("Drivers: hv: vmbus: Move Hyper-V page allocator to arch neutral code")
---
 drivers/hv/connection.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/hv/connection.c +17 -7
index 8351360bba16..be490c598785 100644
@@ -206,11 +206,20 @@ int vmbus_connect(void)
 	INIT_LIST_HEAD(&vmbus_connection.chn_list);
 	mutex_init(&vmbus_connection.channel_mutex);
 
+	/*
+	 * The following Hyper-V interrupt and monitor pages can be used by
+	 * UIO for mapping to user-space, so they should always be allocated on
+	 * system page boundaries. The system page size must be >= the Hyper-V
+	 * page size.
+	 */
+	BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE);
+
 	/*
 	 * Setup the vmbus event connection for channel interrupt
 	 * abstraction stuff
 	 */
-	vmbus_connection.int_page = hv_alloc_hyperv_zeroed_page();
+	vmbus_connection.int_page =
+		(void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
 	if (vmbus_connection.int_page == NULL) {
 		ret = -ENOMEM;
 		goto cleanup;
@@ -225,8 +234,8 @@ int vmbus_connect(void)
 	 * Setup the monitor notification facility. The 1st page for
 	 * parent->child and the 2nd page for child->parent
 	 */
-	vmbus_connection.monitor_pages[0] = hv_alloc_hyperv_page();
-	vmbus_connection.monitor_pages[1] = hv_alloc_hyperv_page();
+	vmbus_connection.monitor_pages[0] = (void *)__get_free_page(GFP_KERNEL);
+	vmbus_connection.monitor_pages[1] = (void *)__get_free_page(GFP_KERNEL);
 	if ((vmbus_connection.monitor_pages[0] == NULL) ||
 	    (vmbus_connection.monitor_pages[1] == NULL)) {
 		ret = -ENOMEM;
@@ -342,21 +351,23 @@ void vmbus_disconnect(void)
 		destroy_workqueue(vmbus_connection.work_queue);
 
 	if (vmbus_connection.int_page) {
-		hv_free_hyperv_page(vmbus_connection.int_page);
+		free_page((unsigned long)vmbus_connection.int_page);
 		vmbus_connection.int_page = NULL;
 	}
 
 	if (vmbus_connection.monitor_pages[0]) {
 		if (!set_memory_encrypted(
 			(unsigned long)vmbus_connection.monitor_pages[0], 1))
-			hv_free_hyperv_page(vmbus_connection.monitor_pages[0]);
+			free_page((unsigned long)
+				vmbus_connection.monitor_pages[0]);
 		vmbus_connection.monitor_pages[0] = NULL;
 	}
 
 	if (vmbus_connection.monitor_pages[1]) {
 		if (!set_memory_encrypted(
 			(unsigned long)vmbus_connection.monitor_pages[1], 1))
-			hv_free_hyperv_page(vmbus_connection.monitor_pages[1]);
+			free_page((unsigned long)
+				vmbus_connection.monitor_pages[1]);
 		vmbus_connection.monitor_pages[1] = NULL;
 	}
 }
--
Quoted 2 lines

2.34.1

#3 lore raw

PATCH v3 2/5 uio_hv_generic: Use correct size for interrupt and monitor pages

In reply to [email protected]

From: Long Li <[email protected]>

Interrupt and monitor pages should be in Hyper-V page size (4k bytes). This can be different from the system page size.

This size is read and used by the user-mode program to determine the mapped data region. An example of such user-mode program is the VMBus driver in DPDK.

Fixes 95096f2fbd10 ("uio-hv-generic: new userspace i/o driver for VMBus")
---
 drivers/uio/uio_hv_generic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/uio/uio_hv_generic.c +2 -2
index 1b19b5647495..08385b04c4ab 100644
@@ -287,13 +287,13 @@ hv_uio_probe(struct hv_device *dev,
 	pdata->info.mem[INT_PAGE_MAP].name = "int_page";
 	pdata->info.mem[INT_PAGE_MAP].addr
 		= (uintptr_t)vmbus_connection.int_page;
-	pdata->info.mem[INT_PAGE_MAP].size = PAGE_SIZE;
+	pdata->info.mem[INT_PAGE_MAP].size = HV_HYP_PAGE_SIZE;
 	pdata->info.mem[INT_PAGE_MAP].memtype = UIO_MEM_LOGICAL;
 
 	pdata->info.mem[MON_PAGE_MAP].name = "monitor_page";
 	pdata->info.mem[MON_PAGE_MAP].addr
 		= (uintptr_t)vmbus_connection.monitor_pages[1];
-	pdata->info.mem[MON_PAGE_MAP].size = PAGE_SIZE;
+	pdata->info.mem[MON_PAGE_MAP].size = HV_HYP_PAGE_SIZE;
 	pdata->info.mem[MON_PAGE_MAP].memtype = UIO_MEM_LOGICAL;
 
 	if (channel->device_id == HV_NIC) {
Signature · 1 line
2.34.1
Reviewed-by on v3 2/5
#4 lore raw

RE: [Patch v3 2/5] uio_hv_generic: Use correct size for interrupt and monitor pages

From: [email protected] <[email protected]> Sent: Monday, May 5, 2025 5:57 PM

Quoted 36 lines

Interrupt and monitor pages should be in Hyper-V page size (4k bytes). This can be different from the system page size.

This size is read and used by the user-mode program to determine the mapped data region. An example of such user-mode program is the VMBus driver in DPDK.

Fixes 95096f2fbd10 ("uio-hv-generic: new userspace i/o driver for VMBus")
---
 drivers/uio/uio_hv_generic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/uio/uio_hv_generic.c +2 -3
index 1b19b5647495..08385b04c4ab 100644
@@ -287,13 +287,13 @@ hv_uio_probe(struct hv_device *dev,
 	pdata->info.mem[INT_PAGE_MAP].name = "int_page";
 	pdata->info.mem[INT_PAGE_MAP].addr
 		= (uintptr_t)vmbus_connection.int_page;
-	pdata->info.mem[INT_PAGE_MAP].size = PAGE_SIZE;
+	pdata->info.mem[INT_PAGE_MAP].size = HV_HYP_PAGE_SIZE;
 	pdata->info.mem[INT_PAGE_MAP].memtype = UIO_MEM_LOGICAL;
 
 	pdata->info.mem[MON_PAGE_MAP].name = "monitor_page";
 	pdata->info.mem[MON_PAGE_MAP].addr
 		= (uintptr_t)vmbus_connection.monitor_pages[1];
-	pdata->info.mem[MON_PAGE_MAP].size = PAGE_SIZE;
+	pdata->info.mem[MON_PAGE_MAP].size = HV_HYP_PAGE_SIZE;
 	pdata->info.mem[MON_PAGE_MAP].memtype = UIO_MEM_LOGICAL;
 
 	if (channel->device_id == HV_NIC) {
--
Quoted 2 lines

2.34.1

#5 lore raw

PATCH v3 3/5 uio_hv_generic: Align ring size to system page

In reply to [email protected]

From: Long Li <[email protected]>

Following the ring header, the ring data should align to system page boundary. Adjust the size if necessary.

Fixes 95096f2fbd10 ("uio-hv-generic: new userspace i/o driver for VMBus")
---
 drivers/uio/uio_hv_generic.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/uio/uio_hv_generic.c +3 -0
index 08385b04c4ab..cb2e7e0e1540 100644
@@ -256,6 +256,9 @@ hv_uio_probe(struct hv_device *dev,
 	if (!ring_size)
 		ring_size = SZ_2M;
 
+	/* Adjust ring size if necessary to have it page aligned */
+	ring_size = VMBUS_RING_SIZE(ring_size);
+
 	pdata = devm_kzalloc(&dev->device, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return -ENOMEM;
Signature · 1 line
2.34.1
Reviewed-by on v3 3/5
#6 lore raw

RE: [Patch v3 3/5] uio_hv_generic: Align ring size to system page

From: [email protected] <[email protected]> Sent: Monday, May 5, 2025 5:57 PM

Quoted 26 lines

Following the ring header, the ring data should align to system page boundary. Adjust the size if necessary.

Fixes 95096f2fbd10 ("uio-hv-generic: new userspace i/o driver for VMBus")
---
 drivers/uio/uio_hv_generic.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/uio/uio_hv_generic.c +3 -1
index 08385b04c4ab..cb2e7e0e1540 100644
@@ -256,6 +256,9 @@ hv_uio_probe(struct hv_device *dev,
 	if (!ring_size)
 		ring_size = SZ_2M;
 
+	/* Adjust ring size if necessary to have it page aligned */
+	ring_size = VMBUS_RING_SIZE(ring_size);
+
 	pdata = devm_kzalloc(&dev->device, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return -ENOMEM;
--
Quoted 2 lines

2.34.1

#7 lore raw

PATCH v3 4/5 Drivers: hv: Use kzalloc for panic page allocation

In reply to [email protected]

From: Long Li <[email protected]>

To prepare for removal of hv_alloc_* and hv_free* functions, use kzalloc/kfree directly for panic reporting page.

---
 drivers/hv/hv_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hv/hv_common.c +3 -3
index a7d7494feaca..a5a6250b1a12 100644
@@ -272,7 +272,7 @@ static void hv_kmsg_dump_unregister(void)
 	atomic_notifier_chain_unregister(&panic_notifier_list,
 					 &hyperv_panic_report_block);
 
-	hv_free_hyperv_page(hv_panic_page);
+	kfree(hv_panic_page);
 	hv_panic_page = NULL;
 }
 
@@ -280,7 +280,7 @@ static void hv_kmsg_dump_register(void)
 {
 	int ret;
 
-	hv_panic_page = hv_alloc_hyperv_zeroed_page();
+	hv_panic_page = kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL);
 	if (!hv_panic_page) {
 		pr_err("Hyper-V: panic message page memory allocation failed\n");
 		return;
@@ -289,7 +289,7 @@ static void hv_kmsg_dump_register(void)
 	ret = kmsg_dump_register(&hv_kmsg_dumper);
 	if (ret) {
 		pr_err("Hyper-V: kmsg dump register error 0x%x\n", ret);
-		hv_free_hyperv_page(hv_panic_page);
+		kfree(hv_panic_page);
 		hv_panic_page = NULL;
 	}
 }
Signature · 1 line
2.34.1
Reviewed-by on v3 4/5
#8 lore raw

RE: [Patch v3 4/5] Drivers: hv: Use kzalloc for panic page allocation

From: [email protected] <[email protected]> Sent: Monday, May 5, 2025 5:57 PM

Quoted 41 lines

To prepare for removal of hv_alloc_* and hv_free* functions, use kzalloc/kfree directly for panic reporting page.

---
 drivers/hv/hv_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hv/hv_common.c +3 -4
index a7d7494feaca..a5a6250b1a12 100644
@@ -272,7 +272,7 @@ static void hv_kmsg_dump_unregister(void)
 	atomic_notifier_chain_unregister(&panic_notifier_list,
 					 &hyperv_panic_report_block);
 
-	hv_free_hyperv_page(hv_panic_page);
+	kfree(hv_panic_page);
 	hv_panic_page = NULL;
 }
 
@@ -280,7 +280,7 @@ static void hv_kmsg_dump_register(void)
 {
 	int ret;
 
-	hv_panic_page = hv_alloc_hyperv_zeroed_page();
+	hv_panic_page = kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL);
 	if (!hv_panic_page) {
 		pr_err("Hyper-V: panic message page memory allocation failed\n");
 		return;
@@ -289,7 +289,7 @@ static void hv_kmsg_dump_register(void)
 	ret = kmsg_dump_register(&hv_kmsg_dumper);
 	if (ret) {
 		pr_err("Hyper-V: kmsg dump register error 0x%x\n", ret);
-		hv_free_hyperv_page(hv_panic_page);
+		kfree(hv_panic_page);
 		hv_panic_page = NULL;
 	}
 }
--
Quoted 2 lines

2.34.1

#9 lore raw

PATCH v3 5/5 Drivers: hv: Remove hv_alloc/free_* helpers

In reply to [email protected]

From: Long Li <[email protected]>

There are no users for those functions, remove them.

---
 drivers/hv/hv_common.c         | 39 ----------------------------------
 include/asm-generic/mshyperv.h |  4 ----
 2 files changed, 43 deletions(-)
drivers/hv/hv_common.c +0 -39
index a5a6250b1a12..421376cea17e 100644
@@ -105,45 +105,6 @@ void __init hv_common_free(void)
 	hv_synic_eventring_tail = NULL;
 }
 
-/*
- * Functions for allocating and freeing memory with size and
- * alignment HV_HYP_PAGE_SIZE. These functions are needed because
- * the guest page size may not be the same as the Hyper-V page
- * size. We depend upon kmalloc() aligning power-of-two size
- * allocations to the allocation size boundary, so that the
- * allocated memory appears to Hyper-V as a page of the size
- * it expects.
- */
-
-void *hv_alloc_hyperv_page(void)
-{
-	BUILD_BUG_ON(PAGE_SIZE <  HV_HYP_PAGE_SIZE);
-
-	if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
-		return (void *)__get_free_page(GFP_KERNEL);
-	else
-		return kmalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL);
-}
-EXPORT_SYMBOL_GPL(hv_alloc_hyperv_page);
-
-void *hv_alloc_hyperv_zeroed_page(void)
-{
-	if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
-		return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
-	else
-		return kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL);
-}
-EXPORT_SYMBOL_GPL(hv_alloc_hyperv_zeroed_page);
-
-void hv_free_hyperv_page(void *addr)
-{
-	if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
-		free_page((unsigned long)addr);
-	else
-		kfree(addr);
-}
-EXPORT_SYMBOL_GPL(hv_free_hyperv_page);
-
 static void *hv_panic_page;
 
 /*
include/asm-generic/mshyperv.h +0 -4
index ccccb1cbf7df..4033508fbb11 100644
@@ -236,10 +236,6 @@ int hv_common_cpu_init(unsigned int cpu);
 int hv_common_cpu_die(unsigned int cpu);
 void hv_identify_partition_type(void);
 
-void *hv_alloc_hyperv_page(void);
-void *hv_alloc_hyperv_zeroed_page(void);
-void hv_free_hyperv_page(void *addr);
-
 /**
  * hv_cpu_number_to_vp_number() - Map CPU to VP.
  * @cpu_number: CPU number in Linux terms
Signature · 1 line
2.34.1
Reviewed-by on v3 5/5
#10 lore raw

RE: [Patch v3 5/5] Drivers: hv: Remove hv_alloc/free_* helpers

From: [email protected] <[email protected]> Sent: Monday, May 5, 2025 5:57 PM

Quoted 75 lines

There are no users for those functions, remove them.

---
 drivers/hv/hv_common.c         | 39 ----------------------------------
 include/asm-generic/mshyperv.h |  4 ----
 2 files changed, 43 deletions(-)
drivers/hv/hv_common.c +0 -39
index a5a6250b1a12..421376cea17e 100644
@@ -105,45 +105,6 @@ void __init hv_common_free(void)
 	hv_synic_eventring_tail = NULL;
 }
 
-/*
- * Functions for allocating and freeing memory with size and
- * alignment HV_HYP_PAGE_SIZE. These functions are needed because
- * the guest page size may not be the same as the Hyper-V page
- * size. We depend upon kmalloc() aligning power-of-two size
- * allocations to the allocation size boundary, so that the
- * allocated memory appears to Hyper-V as a page of the size
- * it expects.
- */
-
-void *hv_alloc_hyperv_page(void)
-{
-	BUILD_BUG_ON(PAGE_SIZE <  HV_HYP_PAGE_SIZE);
-
-	if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
-		return (void *)__get_free_page(GFP_KERNEL);
-	else
-		return kmalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL);
-}
-EXPORT_SYMBOL_GPL(hv_alloc_hyperv_page);
-
-void *hv_alloc_hyperv_zeroed_page(void)
-{
-	if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
-		return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
-	else
-		return kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL);
-}
-EXPORT_SYMBOL_GPL(hv_alloc_hyperv_zeroed_page);
-
-void hv_free_hyperv_page(void *addr)
-{
-	if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
-		free_page((unsigned long)addr);
-	else
-		kfree(addr);
-}
-EXPORT_SYMBOL_GPL(hv_free_hyperv_page);
-
 static void *hv_panic_page;
 
 /*
include/asm-generic/mshyperv.h +0 -5
index ccccb1cbf7df..4033508fbb11 100644
@@ -236,10 +236,6 @@ int hv_common_cpu_init(unsigned int cpu);
 int hv_common_cpu_die(unsigned int cpu);
 void hv_identify_partition_type(void);
 
-void *hv_alloc_hyperv_page(void);
-void *hv_alloc_hyperv_zeroed_page(void);
-void hv_free_hyperv_page(void *addr);
-
 /**
  * hv_cpu_number_to_vp_number() - Map CPU to VP.
  * @cpu_number: CPU number in Linux terms
--
Quoted 2 lines

2.34.1

maintainer
#11 lore raw
In reply to [email protected]
Quoted 22 lines · On Mon, May 05, 2025 at 05:56:32PM -0700, [email protected] wrote:

From: Long Li <[email protected]>

UIO framework requires the device memory aligned to page boundary. Hyper-V may allocate some memory that is Hyper-V page aligned (4k) but not system page aligned.

Fix this by having Hyper-V always allocate those pages on system page boundary and expose them to user-mode.

Change in v2:
Added two more patches to the series:
"uio_hv_generic: Adjust ring size according to system page alignment" "Drivers: hv: Remove hv_free/alloc_* helpers"

Added more details in the commit message of "uio_hv_generic: Use correct size for interrupt and monitor pages"

Change in v3:
Rearranged the patch on removing hv_alloc/free* helpers Added "Drivers: hv: Use kzalloc for panic page allocation" Fixed typos.

Quoted 5 lines

Long Li (5):
Drivers: hv: Allocate interrupt and monitor pages aligned to system
page boundary
uio_hv_generic: Use correct size for interrupt and monitor pages
uio_hv_generic: Align ring size to system page

These patches to UIO look like small bug fixes to me.

Greg, let me know if you care enough to review them.

Given the patches surround these bug fixes, I propose to let me take them via the Hyper-V tree.

Thanks,
Wei.

Quoted 12 lines

Drivers: hv: Use kzalloc for panic page allocation
Drivers: hv: Remove hv_alloc/free_* helpers

 drivers/hv/connection.c        | 23 ++++++++++++-----
 drivers/hv/hv_common.c         | 45 +++-------------------------------
 drivers/uio/uio_hv_generic.c   |  7 ++++--
 include/asm-generic/mshyperv.h |  4 ---
 4 files changed, 25 insertions(+), 54 deletions(-)
Signature · 1 line
2.34.1
maintainer
#12 lore raw
Quoted 29 lines · Wei Liu
Quoted 22 lines · On Mon, May 05, 2025 at 05:56:32PM -0700, [email protected] wrote:

From: Long Li <[email protected]>

UIO framework requires the device memory aligned to page boundary. Hyper-V may allocate some memory that is Hyper-V page aligned (4k) but not system page aligned.

Fix this by having Hyper-V always allocate those pages on system page boundary and expose them to user-mode.

Change in v2:
Added two more patches to the series:
"uio_hv_generic: Adjust ring size according to system page alignment" "Drivers: hv: Remove hv_free/alloc_* helpers"

Added more details in the commit message of "uio_hv_generic: Use correct size for interrupt and monitor pages"

Change in v3:
Rearranged the patch on removing hv_alloc/free* helpers Added "Drivers: hv: Use kzalloc for panic page allocation" Fixed typos.

Quoted 5 lines

Long Li (5):
Drivers: hv: Allocate interrupt and monitor pages aligned to system
page boundary
uio_hv_generic: Use correct size for interrupt and monitor pages
uio_hv_generic: Align ring size to system page

Quoted 6 lines

These patches to UIO look like small bug fixes to me.

Greg, let me know if you care enough to review them.

Given the patches surround these bug fixes, I propose to let me take them via the Hyper-V tree.

Series applied to hyperv-next-staging. Thanks.