x86: hv: Add function to allocate zeroed page for Hyper-V
authorHimadri Pandya <himadrispandya@gmail.com>
Tue, 30 Jul 2019 09:49:43 +0000 (09:49 +0000)
committerSasha Levin <sashal@kernel.org>
Fri, 22 Nov 2019 01:10:45 +0000 (20:10 -0500)
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>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/hyperv/hv_init.c
arch/x86/include/asm/mshyperv.h

index 2db3972c0e0ff047621cb6ab173e34ec914e257b..b2daf0ebdb19d2d749c81e7bc0a762b0eb11b720 100644 (file)
@@ -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);
index f4138aeb428086ba9d1352f1dc21f3d1ba312094..6b79515abb82373af6f30c1297de88a3ddbdeb41 100644 (file)
@@ -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));