Jeremy Fitzhardinge | 3b827c1 | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 1 | #ifndef _XEN_MMU_H |
| 2 | |
| 3 | #include <linux/linkage.h> |
| 4 | #include <asm/page.h> |
| 5 | |
Mark McLoughlin | f643370 | 2008-04-02 15:36:36 +0100 | [diff] [blame] | 6 | enum pt_level { |
| 7 | PT_PGD, |
| 8 | PT_PUD, |
| 9 | PT_PMD, |
| 10 | PT_PTE |
| 11 | }; |
| 12 | |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 13 | /* |
| 14 | * Page-directory addresses above 4GB do not fit into architectural %cr3. |
| 15 | * When accessing %cr3, or equivalent field in vcpu_guest_context, guests |
| 16 | * must use the following accessor macros to pack/unpack valid MFNs. |
| 17 | * |
| 18 | * Note that Xen is using the fact that the pagetable base is always |
| 19 | * page-aligned, and putting the 12 MSB of the address into the 12 LSB |
| 20 | * of cr3. |
| 21 | */ |
| 22 | #define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20)) |
| 23 | #define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20)) |
| 24 | |
| 25 | |
Jeremy Fitzhardinge | 3b827c1 | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 26 | void set_pte_mfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags); |
| 27 | |
| 28 | void xen_set_pte(pte_t *ptep, pte_t pteval); |
| 29 | void xen_set_pte_at(struct mm_struct *mm, unsigned long addr, |
| 30 | pte_t *ptep, pte_t pteval); |
| 31 | void xen_set_pmd(pmd_t *pmdp, pmd_t pmdval); |
| 32 | |
| 33 | void xen_activate_mm(struct mm_struct *prev, struct mm_struct *next); |
| 34 | void xen_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm); |
| 35 | void xen_exit_mmap(struct mm_struct *mm); |
| 36 | |
| 37 | void xen_pgd_pin(pgd_t *pgd); |
Jeremy Fitzhardinge | f4f97b3 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 38 | //void xen_pgd_unpin(pgd_t *pgd); |
Jeremy Fitzhardinge | 3b827c1 | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 39 | |
| 40 | #ifdef CONFIG_X86_PAE |
| 41 | unsigned long long xen_pte_val(pte_t); |
| 42 | unsigned long long xen_pmd_val(pmd_t); |
| 43 | unsigned long long xen_pgd_val(pgd_t); |
| 44 | |
| 45 | pte_t xen_make_pte(unsigned long long); |
| 46 | pmd_t xen_make_pmd(unsigned long long); |
| 47 | pgd_t xen_make_pgd(unsigned long long); |
| 48 | |
| 49 | void xen_set_pte_at(struct mm_struct *mm, unsigned long addr, |
| 50 | pte_t *ptep, pte_t pteval); |
| 51 | void xen_set_pte_atomic(pte_t *ptep, pte_t pte); |
| 52 | void xen_set_pud(pud_t *ptr, pud_t val); |
| 53 | void xen_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); |
| 54 | void xen_pmd_clear(pmd_t *pmdp); |
| 55 | |
| 56 | |
| 57 | #else |
| 58 | unsigned long xen_pte_val(pte_t); |
| 59 | unsigned long xen_pmd_val(pmd_t); |
| 60 | unsigned long xen_pgd_val(pgd_t); |
| 61 | |
| 62 | pte_t xen_make_pte(unsigned long); |
| 63 | pmd_t xen_make_pmd(unsigned long); |
| 64 | pgd_t xen_make_pgd(unsigned long); |
| 65 | #endif |
| 66 | |
| 67 | #endif /* _XEN_MMU_H */ |