]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
Introduce more pagetable helpers
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 19 Jul 2016 15:05:23 +0000 (16:05 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 19 Jul 2016 15:09:51 +0000 (16:09 +0100)
Symbolic constants for expressing pte flags in a short way, and helpers to
construct a pagetable entry from a frame and flags.

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

index 9241525523497153003947d097cbccb29e43610b..3a7f1eb486642c177e03a097d0b0e823838202d4 100644 (file)
 #define _PAGE_PSE_PAT           0x1000
 #define _PAGE_NX                (_AC(1, ULL) << 63)
 
+/* Shortened flags for use with PF_SYM(). */
+#define _PAGE_P                 _PAGE_PRESENT
+#define _PAGE_U                 _PAGE_USER
+#define _PAGE_A                 _PAGE_ACCESSED
+#define _PAGE_D                 _PAGE_DIRTY
+
 #if CONFIG_PAGING_LEVELS == 2 /* PSE Paging */
 
 #define PTE_SIZE  PSE_PTE_SIZE
@@ -145,6 +151,16 @@ static inline paddr_t pte_to_paddr(intpte_t pte)
     return pte & PADDR_MASK & PAGE_MASK;
 }
 
+static inline intpte_t pte_from_paddr(paddr_t paddr, uint64_t flags)
+{
+    return paddr | flags;
+}
+
+static inline intpte_t pte_from_gfn(unsigned long gfn, uint64_t flags)
+{
+    return pte_from_paddr((paddr_t)gfn << PAGE_SHIFT, flags);
+}
+
 #endif /* CONFIG_PAGING_LEVELS > 0 */
 
 #ifdef CONFIG_HVM
index cb9d9b2648e5e1db36161525b0fe33e9b550c781..e8be085fa676468d32b580fd632a98ac70a77e05 100644 (file)
 #define EXC_EC_SYM(exc, ...) \
     SEL_EC_SYM(((X86_EXC_ ## exc) << 3), IDT, ##__VA_ARGS__)
 
+/**
+ * Create pagetable entry flags based on mnemonics.
+ *
+ * @param ... Partial _PAGE_ tokens.
+ *
+ * Example usage:
+ * - PF_SYM(AD, U, RW, P)
+ *   - Accessed, Dirty, User, Writeable, Present.
+ */
+#define PF_SYM(...) TOK_OR(_PAGE_, ##__VA_ARGS__)
+
 #endif /* XTF_X86_SYMBOLIC_CONST_H */
 
 /*