Thread (24 messages) 24 messages, 3 authors, 2020-07-23

[RFC 06/11] hv: hyperv.h: Introduce some hvpfn helper functions

From: Boqun Feng <hidden>
Date: 2020-07-21 01:42:44
Also in: linux-input, linux-scsi, lkml, netdev
Subsystem: hyper-v/azure core and drivers, the rest · Maintainers: "K. Y. Srinivasan", Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li, Linus Torvalds

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 <redacted>
---
 include/linux/hyperv.h | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index eda8e5f9a49d..b34d94b1f659 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1703,4 +1703,8 @@ static inline unsigned long virt_to_hvpfn(void *addr)
 	return  paddr >> HV_HYP_PAGE_SHIFT;
 }
 
+#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) << PAGE_SHIFT) >> HV_HYP_PAGE_SHIFT)
+
 #endif /* _HYPERV_H */
-- 
2.27.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help