]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
Add helpers to fold and unfold a pv32pae guest cr3
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 30 Aug 2016 16:29:51 +0000 (17:29 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 30 Aug 2016 16:30:38 +0000 (17:30 +0100)
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
include/xen/arch-x86/xen-x86_32.h

index efe41341294ad4c3dfc03d33d50efeb8c037f08c..8ac5d2c48543de5cf7db956e4b8cfd0335ecad7f 100644 (file)
 
 #define __HYPERVISOR_VIRT_START_PAE 0xF5800000UL
 
+#ifndef __ASSEMBLY__
+
+/*
+ * Page-directory addresses above 4GB do not fit into architectural %cr3.
+ * When accessing %cr3, or equivalent field in vcpu_guest_context, guests
+ * must use the following accessor macros to pack/unpack valid MFNs.
+ */
+static inline unsigned int xen_pfn_to_cr3(unsigned int pfn)
+{
+    return pfn << 12 | pfn >> 20;
+}
+
+static inline unsigned int xen_cr3_to_pfn(unsigned int cr3)
+{
+    return cr3 >> 12 | cr3 << 20;
+}
+
+#endif /* __ASSEMBLY__ */
+
 #endif /* XEN_PUBLIC_ARCH_X86_XEN_X86_32_H */
 
 /*