[Xen-devel,09/24] xen/arm: Define mfn_to_page/page_to_mfn in term of __mfn_to_page/__page_to_mfn

Message ID 20170613161323.25196-10-julien.grall@arm.com
State Accepted
Commit 948066d0526cebe1ecd0c21863a9cfc1be0290a4
Headers show
Series
  • xen/arm: Extend the usage of typesafe MFN
Related show

Commit Message

Julien Grall June 13, 2017, 4:13 p.m.
This is matching the x86 side where the __* version is used if you need
to override the helpers in source files.

At the same time, move the non-underscore version at the end of the
defintion and add a comment to explain them.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/include/asm-arm/mm.h | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Stefano Stabellini June 15, 2017, 10:42 p.m. | #1
On Tue, 13 Jun 2017, Julien Grall wrote:
> This is matching the x86 side where the __* version is used if you need
> to override the helpers in source files.
> 
> At the same time, move the non-underscore version at the end of the
> defintion and add a comment to explain them.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/include/asm-arm/mm.h | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
> index f6915ad882..cc3220a6b7 100644
> --- a/xen/include/asm-arm/mm.h
> +++ b/xen/include/asm-arm/mm.h
> @@ -203,10 +203,8 @@ static inline void __iomem *ioremap_wc(paddr_t start, size_t len)
>  })
>  
>  /* Convert between machine frame numbers and page-info structures. */
> -#define mfn_to_page(mfn)  (frame_table + (pfn_to_pdx(mfn) - frametable_base_pdx))
> -#define page_to_mfn(pg)   pdx_to_pfn((unsigned long)((pg) - frame_table) + frametable_base_pdx)
> -#define __page_to_mfn(pg)  page_to_mfn(pg)
> -#define __mfn_to_page(mfn) mfn_to_page(mfn)
> +#define __mfn_to_page(mfn)  (frame_table + (pfn_to_pdx(mfn) - frametable_base_pdx))
> +#define __page_to_mfn(pg)   pdx_to_pfn((unsigned long)((pg) - frame_table) + frametable_base_pdx)
>  
>  /* Convert between machine addresses and page-info structures. */
>  #define maddr_to_page(ma) __mfn_to_page((ma) >> PAGE_SHIFT)
> @@ -264,6 +262,13 @@ static inline int gvirt_to_maddr(vaddr_t va, paddr_t *pa, unsigned int flags)
>  #define virt_to_mfn(va)   (virt_to_maddr(va) >> PAGE_SHIFT)
>  #define mfn_to_virt(mfn)  (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT))
>  
> +/*
> + * We define non-underscored wrappers for above conversion functions.
> + * These are overriden in various source files while underscored version
> + * remain intact.
> + */
> +#define mfn_to_page(mfn)    __mfn_to_page(mfn)
> +#define page_to_mfn(pg)     __page_to_mfn(pg)
>  
>  /* Convert between Xen-heap virtual addresses and page-info structures. */
>  static inline struct page_info *virt_to_page(const void *v)
> -- 
> 2.11.0
>

Patch

diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h
index f6915ad882..cc3220a6b7 100644
--- a/xen/include/asm-arm/mm.h
+++ b/xen/include/asm-arm/mm.h
@@ -203,10 +203,8 @@  static inline void __iomem *ioremap_wc(paddr_t start, size_t len)
 })
 
 /* Convert between machine frame numbers and page-info structures. */
-#define mfn_to_page(mfn)  (frame_table + (pfn_to_pdx(mfn) - frametable_base_pdx))
-#define page_to_mfn(pg)   pdx_to_pfn((unsigned long)((pg) - frame_table) + frametable_base_pdx)
-#define __page_to_mfn(pg)  page_to_mfn(pg)
-#define __mfn_to_page(mfn) mfn_to_page(mfn)
+#define __mfn_to_page(mfn)  (frame_table + (pfn_to_pdx(mfn) - frametable_base_pdx))
+#define __page_to_mfn(pg)   pdx_to_pfn((unsigned long)((pg) - frame_table) + frametable_base_pdx)
 
 /* Convert between machine addresses and page-info structures. */
 #define maddr_to_page(ma) __mfn_to_page((ma) >> PAGE_SHIFT)
@@ -264,6 +262,13 @@  static inline int gvirt_to_maddr(vaddr_t va, paddr_t *pa, unsigned int flags)
 #define virt_to_mfn(va)   (virt_to_maddr(va) >> PAGE_SHIFT)
 #define mfn_to_virt(mfn)  (maddr_to_virt((paddr_t)(mfn) << PAGE_SHIFT))
 
+/*
+ * We define non-underscored wrappers for above conversion functions.
+ * These are overriden in various source files while underscored version
+ * remain intact.
+ */
+#define mfn_to_page(mfn)    __mfn_to_page(mfn)
+#define page_to_mfn(pg)     __page_to_mfn(pg)
 
 /* Convert between Xen-heap virtual addresses and page-info structures. */
 static inline struct page_info *virt_to_page(const void *v)