linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Drivers: hv: Remove dependencies on guest page size
@ 2019-07-30  9:49 Himadri Pandya
  2019-07-30  9:49 ` [PATCH 1/2] x86: hv: Add function to allocate zeroed page for Hyper-V Himadri Pandya
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Himadri Pandya @ 2019-07-30  9:49 UTC (permalink / raw)
  To: mikelley, kys, haiyangz, sthemmin, sashal, tglx, mingo, bp, hpa
  Cc: x86, linux-hyperv, linux-kernel, Himadri Pandya

Hyper-V assumes page size to be 4KB. This might not be the case on ARM64
architecture. The first patch in this patchset introduces a hyer-v
specific function for allocating a zeroed page which can have a
different implementation on ARM64 to address the issue of different
guest and host page sizes. The second patch removes dependencies on
guest page size in vmbus by using hyper-v specific page symbol and
functions. 

Himadri Pandya (2):
  x86: hv: Add function to allocate zeroed page for Hyper-V
  Drivers: hv: vmbus: Remove dependencies on guest page size

 arch/x86/hyperv/hv_init.c       |  8 ++++++++
 arch/x86/include/asm/mshyperv.h |  1 +
 drivers/hv/connection.c         | 14 +++++++-------
 drivers/hv/vmbus_drv.c          |  6 +++---
 4 files changed, 19 insertions(+), 10 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] x86: hv: Add function to allocate zeroed page for Hyper-V
  2019-07-30  9:49 [PATCH 0/2] Drivers: hv: Remove dependencies on guest page size Himadri Pandya
@ 2019-07-30  9:49 ` Himadri Pandya
  2019-07-30  9:49 ` [PATCH 2/2] Drivers: hv: vmbus: Remove dependencies on guest page size Himadri Pandya
       [not found] ` <DM5PR21MB01377F433CD767AF5E917EA6D7B80@DM5PR21MB0137.namprd21.prod.outlook.com>
  2 siblings, 0 replies; 4+ messages in thread
From: Himadri Pandya @ 2019-07-30  9:49 UTC (permalink / raw)
  To: mikelley, kys, haiyangz, sthemmin, sashal, tglx, mingo, bp, hpa
  Cc: x86, linux-hyperv, linux-kernel, Himadri Pandya

Hyper-V assumes page size to be 4K. While this assumption holds true on
x86 architecture, it might not  be true for ARM64 architecture. Hence
define hyper-v specific function to allocate a zeroed page which can
have a different implementation on ARM64 architecture to handle the
conflict between hyper-v's assumed page size and actual guest page size.

Signed-off-by: Himadri Pandya <himadri18.07@gmail.com>
---
 arch/x86/hyperv/hv_init.c       | 8 ++++++++
 arch/x86/include/asm/mshyperv.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index d314cf1e15fd..2d0b9b2bddf7 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -45,6 +45,14 @@ void *hv_alloc_hyperv_page(void)
 }
 EXPORT_SYMBOL_GPL(hv_alloc_hyperv_page);
 
+void *hv_alloc_hyperv_zeroed_page(void)
+{
+        BUILD_BUG_ON(PAGE_SIZE != HV_HYP_PAGE_SIZE);
+
+        return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
+}
+EXPORT_SYMBOL_GPL(hv_alloc_hyperv_zeroed_page);
+
 void hv_free_hyperv_page(unsigned long addr)
 {
 	free_page(addr);
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index f4138aeb4280..6b79515abb82 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -219,6 +219,7 @@ static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu)
 void __init hyperv_init(void);
 void hyperv_setup_mmu_ops(void);
 void *hv_alloc_hyperv_page(void);
+void *hv_alloc_hyperv_zeroed_page(void);
 void hv_free_hyperv_page(unsigned long addr);
 void hyperv_reenlightenment_intr(struct pt_regs *regs);
 void set_hv_tscchange_cb(void (*cb)(void));
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Drivers: hv: vmbus: Remove dependencies on guest page size
  2019-07-30  9:49 [PATCH 0/2] Drivers: hv: Remove dependencies on guest page size Himadri Pandya
  2019-07-30  9:49 ` [PATCH 1/2] x86: hv: Add function to allocate zeroed page for Hyper-V Himadri Pandya
@ 2019-07-30  9:49 ` Himadri Pandya
       [not found] ` <DM5PR21MB01377F433CD767AF5E917EA6D7B80@DM5PR21MB0137.namprd21.prod.outlook.com>
  2 siblings, 0 replies; 4+ messages in thread
From: Himadri Pandya @ 2019-07-30  9:49 UTC (permalink / raw)
  To: mikelley, kys, haiyangz, sthemmin, sashal, tglx, mingo, bp, hpa
  Cc: x86, linux-hyperv, linux-kernel, Himadri Pandya

Hyper-V assumes page size to be 4K. This might not be the case for ARM64
architecture. Hence use hyper-v page size and page allocation function
to avoid conflicts between different host and guest page size on ARM64.

Signed-off-by: Himadri Pandya <himadri18.07@gmail.com>
---
 drivers/hv/connection.c | 14 +++++++-------
 drivers/hv/vmbus_drv.c  |  6 +++---
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c
index 09829e15d4a0..dcb8f6a8c08c 100644
--- a/drivers/hv/connection.c
+++ b/drivers/hv/connection.c
@@ -202,7 +202,7 @@ int vmbus_connect(void)
 	 * abstraction stuff
 	 */
 	vmbus_connection.int_page =
-	(void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO, 0);
+	(void *)hv_alloc_hyperv_zeroed_page();
 	if (vmbus_connection.int_page == NULL) {
 		ret = -ENOMEM;
 		goto cleanup;
@@ -211,14 +211,14 @@ int vmbus_connect(void)
 	vmbus_connection.recv_int_page = vmbus_connection.int_page;
 	vmbus_connection.send_int_page =
 		(void *)((unsigned long)vmbus_connection.int_page +
-			(PAGE_SIZE >> 1));
+			(HV_HYP_PAGE_SIZE >> 1));
 
 	/*
 	 * Setup the monitor notification facility. The 1st page for
 	 * parent->child and the 2nd page for child->parent
 	 */
-	vmbus_connection.monitor_pages[0] = (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
-	vmbus_connection.monitor_pages[1] = (void *)__get_free_pages((GFP_KERNEL|__GFP_ZERO), 0);
+	vmbus_connection.monitor_pages[0] = (void *)hv_alloc_hyperv_zeroed_page();
+	vmbus_connection.monitor_pages[1] = (void *)hv_alloc_hyperv_zeroed_page();
 	if ((vmbus_connection.monitor_pages[0] == NULL) ||
 	    (vmbus_connection.monitor_pages[1] == NULL)) {
 		ret = -ENOMEM;
@@ -291,12 +291,12 @@ void vmbus_disconnect(void)
 		destroy_workqueue(vmbus_connection.work_queue);
 
 	if (vmbus_connection.int_page) {
-		free_pages((unsigned long)vmbus_connection.int_page, 0);
+		hv_free_hyperv_page((unsigned long)vmbus_connection.int_page);
 		vmbus_connection.int_page = NULL;
 	}
 
-	free_pages((unsigned long)vmbus_connection.monitor_pages[0], 0);
-	free_pages((unsigned long)vmbus_connection.monitor_pages[1], 0);
+	hv_free_hyperv_page((unsigned long)vmbus_connection.monitor_pages[0]);
+	hv_free_hyperv_page((unsigned long)vmbus_connection.monitor_pages[1]);
 	vmbus_connection.monitor_pages[0] = NULL;
 	vmbus_connection.monitor_pages[1] = NULL;
 }
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index ebd35fc35290..2ee388a23c8f 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -1186,7 +1186,7 @@ static void hv_kmsg_dump(struct kmsg_dumper *dumper,
 	 * Write dump contents to the page. No need to synchronize; panic should
 	 * be single-threaded.
 	 */
-	kmsg_dump_get_buffer(dumper, true, hv_panic_page, PAGE_SIZE,
+	kmsg_dump_get_buffer(dumper, true, hv_panic_page, HV_HYP_PAGE_SIZE,
 			     &bytes_written);
 	if (bytes_written)
 		hyperv_report_panic_msg(panic_pa, bytes_written);
@@ -1290,7 +1290,7 @@ static int vmbus_bus_init(void)
 		 */
 		hv_get_crash_ctl(hyperv_crash_ctl);
 		if (hyperv_crash_ctl & HV_CRASH_CTL_CRASH_NOTIFY_MSG) {
-			hv_panic_page = (void *)get_zeroed_page(GFP_KERNEL);
+			hv_panic_page = (void *)hv_alloc_hyperv_zeroed_page();
 			if (hv_panic_page) {
 				ret = kmsg_dump_register(&hv_kmsg_dumper);
 				if (ret)
@@ -1319,7 +1319,7 @@ static int vmbus_bus_init(void)
 	hv_remove_vmbus_irq();
 
 	bus_unregister(&hv_bus);
-	free_page((unsigned long)hv_panic_page);
+	hv_free_hyperv_page((unsigned long)hv_panic_page);
 	unregister_sysctl_table(hv_ctl_table_hdr);
 	hv_ctl_table_hdr = NULL;
 	return ret;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Drivers: hv: Remove dependencies on guest page size
       [not found] ` <DM5PR21MB01377F433CD767AF5E917EA6D7B80@DM5PR21MB0137.namprd21.prod.outlook.com>
@ 2019-10-04 15:41   ` Sasha Levin
  0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2019-10-04 15:41 UTC (permalink / raw)
  To: Michael Kelley
  Cc: Himadri Pandya, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	tglx, mingo, bp, hpa, x86, linux-hyperv, linux-kernel,
	himadri18.07

On Wed, Sep 04, 2019 at 11:41:43PM +0000, Michael Kelley wrote:
>From: Himadri Pandya <himadrispandya@gmail.com>
>>
>> Hyper-V assumes page size to be 4KB. This might not be the case on ARM64
>> architecture. The first patch in this patchset introduces a hyer-v
>> specific function for allocating a zeroed page which can have a
>> different implementation on ARM64 to address the issue of different
>> guest and host page sizes. The second patch removes dependencies on
>> guest page size in vmbus by using hyper-v specific page symbol and
>> functions.
>>
>> Himadri Pandya (2):
>>   x86: hv: Add function to allocate zeroed page for Hyper-V
>>   Drivers: hv: vmbus: Remove dependencies on guest page size
>>
>>  arch/x86/hyperv/hv_init.c       |  8 ++++++++
>>  arch/x86/include/asm/mshyperv.h |  1 +
>>  drivers/hv/connection.c         | 14 +++++++-------
>>  drivers/hv/vmbus_drv.c          |  6 +++---
>>  4 files changed, 19 insertions(+), 10 deletions(-)
>>
>> --
>> 2.17.1
>
>Thomas -- can you pick up this patch in the x86/hyperv branch of your
>tip tree along with the other patches to fix wrong page size assumptions?

I'll take it through the hyper-v tree, there's a bunch of similar work
queued up there already.

--
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-04 15:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-30  9:49 [PATCH 0/2] Drivers: hv: Remove dependencies on guest page size Himadri Pandya
2019-07-30  9:49 ` [PATCH 1/2] x86: hv: Add function to allocate zeroed page for Hyper-V Himadri Pandya
2019-07-30  9:49 ` [PATCH 2/2] Drivers: hv: vmbus: Remove dependencies on guest page size Himadri Pandya
     [not found] ` <DM5PR21MB01377F433CD767AF5E917EA6D7B80@DM5PR21MB0137.namprd21.prod.outlook.com>
2019-10-04 15:41   ` [PATCH 0/2] Drivers: hv: " Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).