]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
xen/x86: mm: Introduce {G, M}FN <-> {G, M}ADDR helpers
authorJulien Grall <julien.grall@arm.com>
Tue, 12 Sep 2017 10:03:07 +0000 (11:03 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 12 Sep 2017 10:29:40 +0000 (11:29 +0100)
The new wrappers will add more safety when converting an address to a
frame number (either machine or guest). They are already existing for
Arm and could be useful in common code.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
xen/include/asm-x86/page.h

index cde5c6b89b8b4ef84631d824e1894821ce632113..45ca742678627f7f5b5a389fc1e8a4b63a8c7766 100644 (file)
@@ -250,6 +250,10 @@ void copy_page_sse2(void *, const void *);
 /* Convert between frame number and address formats.  */
 #define __pfn_to_paddr(pfn) ((paddr_t)(pfn) << PAGE_SHIFT)
 #define __paddr_to_pfn(pa)  ((unsigned long)((pa) >> PAGE_SHIFT))
+#define gfn_to_gaddr(gfn)   __pfn_to_paddr(gfn_x(gfn))
+#define gaddr_to_gfn(ga)    _gfn(__paddr_to_pfn(ga))
+#define mfn_to_maddr(mfn)   __pfn_to_paddr(mfn_x(mfn))
+#define maddr_to_mfn(ma)    _mfn(__paddr_to_pfn(ma))
 
 /*
  * We define non-underscored wrappers for above conversion functions. These are