diff mbox series

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

Message ID 20200910143455.109293-7-boqun.feng@gmail.com
State Superseded
Headers show
Series Hyper-V: Support PAGE_SIZE larger than 4K | expand

Commit Message

Boqun Feng Sept. 10, 2020, 2:34 p.m. UTC
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>
---
 include/linux/hyperv.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Michael Kelley Sept. 12, 2020, 7:33 p.m. UTC | #1
From: Boqun Feng <boqun.feng@gmail.com> Sent: Thursday, September 10, 2020 7:35 AM
> 
> 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>
> ---
>  include/linux/hyperv.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 

Reviewed-by: Michael Kelley <mikelley@microsoft.com>
diff mbox series

Patch

diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 6f4831212979..00c09d2ff9ad 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1687,4 +1687,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 */