]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
Introduce more memory management helpers
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 19 Jul 2016 12:36:27 +0000 (13:36 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 19 Jul 2016 15:08:12 +0000 (16:08 +0100)
These are still simply, relying on identity mappings and state provided by the
domain builder for PV guests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
include/arch/x86/mm.h

index dfdab219568f887b977cb01e42bef8800a9261a9..d2a65d04e0f774caf60a8d968e005727d45e95e2 100644 (file)
@@ -24,9 +24,15 @@ static inline void *pfn_to_virt(unsigned long pfn)
     return (void *)(pfn << PAGE_SHIFT);
 }
 
+static inline unsigned long virt_to_pfn(const void *va)
+{
+    return ((unsigned long)va) >> PAGE_SHIFT;
+}
+
 #if defined(CONFIG_PV)
 
 #define m2p ((unsigned long *)MACH2PHYS_VIRT_START)
+extern struct start_info *start_info;
 
 static inline void *mfn_to_virt(unsigned long mfn)
 {
@@ -38,6 +44,18 @@ static inline void *maddr_to_virt(uint64_t maddr)
     return mfn_to_virt(maddr >> PAGE_SHIFT) + (maddr & ~PAGE_MASK);
 }
 
+static inline unsigned long pfn_to_mfn(unsigned long pfn)
+{
+    unsigned long *p2m = _p(start_info->mfn_list);
+
+    return p2m[pfn];
+}
+
+static inline unsigned long virt_to_mfn(const void *va)
+{
+    return pfn_to_mfn(virt_to_pfn(va));
+}
+
 #undef m2p
 
 #endif /* CONFIG_PV */