summaryrefslogtreecommitdiff
path: root/include/linux/hyperv.h
diff options
context:
space:
mode:
authorBoqun Feng <boqun.feng@gmail.com>2020-09-16 11:48:12 +0800
committerWei Liu <wei.liu@kernel.org>2020-09-28 08:55:13 +0000
commit106dee08408118c5b50387817e74419436e8b651 (patch)
tree8582a63e1fd0344afdffe56b86a2ff9eddd85bbc /include/linux/hyperv.h
parentbca6b91dfdd4347d8fe0bb97377dda0cacd51d82 (diff)
hv: hyperv.h: Introduce some hvpfn helper functions
When a guest communicate with the hypervisor, it must use HV_HYP_PAGE to calculate PFN, so introduce a few hvpfn helper functions as the counterpart of the page helper functions. This is the preparation for supporting guest whose PAGE_SIZE is not 4k. Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Link: https://lore.kernel.org/r/20200916034817.30282-7-boqun.feng@gmail.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
Diffstat (limited to 'include/linux/hyperv.h')
-rw-r--r--include/linux/hyperv.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 83456dc181a8..1ce131f29f3b 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1691,4 +1691,9 @@ static inline unsigned long virt_to_hvpfn(void *addr)
return paddr >> HV_HYP_PAGE_SHIFT;
}
+#define NR_HV_HYP_PAGES_IN_PAGE (PAGE_SIZE / HV_HYP_PAGE_SIZE)
+#define offset_in_hvpage(ptr) ((unsigned long)(ptr) & ~HV_HYP_PAGE_MASK)
+#define HVPFN_UP(x) (((x) + HV_HYP_PAGE_SIZE-1) >> HV_HYP_PAGE_SHIFT)
+#define page_to_hvpfn(page) (page_to_pfn(page) * NR_HV_HYP_PAGES_IN_PAGE)
+
#endif /* _HYPERV_H */