19702785aSThomas Gleixner #ifndef _XEN_MMU_H 29702785aSThomas Gleixner 39702785aSThomas Gleixner #include <linux/linkage.h> 49702785aSThomas Gleixner #include <asm/page.h> 59702785aSThomas Gleixner 6f6433706SMark McLoughlin enum pt_level { 7f6433706SMark McLoughlin PT_PGD, 8f6433706SMark McLoughlin PT_PUD, 9f6433706SMark McLoughlin PT_PMD, 10f6433706SMark McLoughlin PT_PTE 11f6433706SMark McLoughlin }; 12f6433706SMark McLoughlin 139702785aSThomas Gleixner /* 149702785aSThomas Gleixner * Page-directory addresses above 4GB do not fit into architectural %cr3. 159702785aSThomas Gleixner * When accessing %cr3, or equivalent field in vcpu_guest_context, guests 169702785aSThomas Gleixner * must use the following accessor macros to pack/unpack valid MFNs. 179702785aSThomas Gleixner * 189702785aSThomas Gleixner * Note that Xen is using the fact that the pagetable base is always 199702785aSThomas Gleixner * page-aligned, and putting the 12 MSB of the address into the 12 LSB 209702785aSThomas Gleixner * of cr3. 219702785aSThomas Gleixner */ 229702785aSThomas Gleixner #define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20)) 239702785aSThomas Gleixner #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20)) 249702785aSThomas Gleixner 259702785aSThomas Gleixner 269702785aSThomas Gleixner void set_pte_mfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags); 279702785aSThomas Gleixner 289702785aSThomas Gleixner void xen_set_pte(pte_t *ptep, pte_t pteval); 299702785aSThomas Gleixner void xen_set_pte_at(struct mm_struct *mm, unsigned long addr, 309702785aSThomas Gleixner pte_t *ptep, pte_t pteval); 319702785aSThomas Gleixner void xen_set_pmd(pmd_t *pmdp, pmd_t pmdval); 329702785aSThomas Gleixner 339702785aSThomas Gleixner void xen_activate_mm(struct mm_struct *prev, struct mm_struct *next); 349702785aSThomas Gleixner void xen_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm); 359702785aSThomas Gleixner void xen_exit_mmap(struct mm_struct *mm); 369702785aSThomas Gleixner 379702785aSThomas Gleixner void xen_pgd_pin(pgd_t *pgd); 389702785aSThomas Gleixner //void xen_pgd_unpin(pgd_t *pgd); 399702785aSThomas Gleixner 409702785aSThomas Gleixner #ifdef CONFIG_X86_PAE 419702785aSThomas Gleixner unsigned long long xen_pte_val(pte_t); 429702785aSThomas Gleixner unsigned long long xen_pmd_val(pmd_t); 439702785aSThomas Gleixner unsigned long long xen_pgd_val(pgd_t); 449702785aSThomas Gleixner 459702785aSThomas Gleixner pte_t xen_make_pte(unsigned long long); 469702785aSThomas Gleixner pmd_t xen_make_pmd(unsigned long long); 479702785aSThomas Gleixner pgd_t xen_make_pgd(unsigned long long); 489702785aSThomas Gleixner 499702785aSThomas Gleixner void xen_set_pte_at(struct mm_struct *mm, unsigned long addr, 509702785aSThomas Gleixner pte_t *ptep, pte_t pteval); 519702785aSThomas Gleixner void xen_set_pte_atomic(pte_t *ptep, pte_t pte); 529702785aSThomas Gleixner void xen_set_pud(pud_t *ptr, pud_t val); 539702785aSThomas Gleixner void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 549702785aSThomas Gleixner void xen_pmd_clear(pmd_t *pmdp); 559702785aSThomas Gleixner 569702785aSThomas Gleixner 579702785aSThomas Gleixner #else 589702785aSThomas Gleixner unsigned long xen_pte_val(pte_t); 599702785aSThomas Gleixner unsigned long xen_pmd_val(pmd_t); 609702785aSThomas Gleixner unsigned long xen_pgd_val(pgd_t); 619702785aSThomas Gleixner 629702785aSThomas Gleixner pte_t xen_make_pte(unsigned long); 639702785aSThomas Gleixner pmd_t xen_make_pmd(unsigned long); 649702785aSThomas Gleixner pgd_t xen_make_pgd(unsigned long); 659702785aSThomas Gleixner #endif 669702785aSThomas Gleixner 679702785aSThomas Gleixner #endif /* _XEN_MMU_H */ 68