aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/pgtable_64.h
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2008-01-30 07:32:58 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:32:58 -0500
commit4891645e764d2e181b834509a689fcd12e890c10 (patch)
treef347227c2d5a5b112bca8fe76b149ccc5157ef84 /include/asm-x86/pgtable_64.h
parent8405b122ad0dd75354b3bfed4de9a96514fd40cb (diff)
x86: unify paravirt pagetable accessors
Put all the defines for mapping pagetable operations to their native versions (for the non-paravirt case) into one place. Make the corresponding changes to paravirt.h. The tricky part here is that when a pagetable entry can't be updated atomically (ie, 32-bit PAE), we need special handlers for pte_clear, set_pte_atomic and set_pte_present. However, the other two modes don't need special handling for these, and can use a common set_pte(_at) path. [ mingo@elte.hu: fixes ] Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/asm-x86/pgtable_64.h')
-rw-r--r--include/asm-x86/pgtable_64.h64
1 files changed, 35 insertions, 29 deletions
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index 435e17187eb6..29fdeb8111bb 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -63,51 +63,59 @@ extern void clear_kernel_mapping(unsigned long addr, unsigned long size);
63#define pgd_none(x) (!pgd_val(x)) 63#define pgd_none(x) (!pgd_val(x))
64#define pud_none(x) (!pud_val(x)) 64#define pud_none(x) (!pud_val(x))
65 65
66static inline void set_pte(pte_t *dst, pte_t val) 66struct mm_struct;
67
68static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr,
69 pte_t *ptep)
67{ 70{
68 *dst = val; 71 *ptep = native_make_pte(0);
69} 72}
70#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
71 73
72static inline void set_pmd(pmd_t *dst, pmd_t val) 74static inline void native_set_pte(pte_t *ptep, pte_t pte)
73{ 75{
74 *dst = val; 76 *ptep = pte;
75} 77}
76 78
77static inline void set_pud(pud_t *dst, pud_t val) 79static inline pte_t native_ptep_get_and_clear(pte_t *xp)
78{ 80{
79 *dst = val; 81#ifdef CONFIG_SMP
82 return native_make_pte(xchg(&xp->pte, 0));
83#else
84 /* native_local_ptep_get_and_clear, but duplicated because of cyclic dependency */
85 pte_t ret = *xp;
86 native_pte_clear(NULL, 0, xp);
87 return ret;
88#endif
80} 89}
81 90
82static inline void pud_clear (pud_t *pud) 91static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
83{ 92{
84 set_pud(pud, __pud(0)); 93 *pmdp = pmd;
85} 94}
86 95
87static inline void set_pgd(pgd_t *dst, pgd_t val) 96static inline void native_pmd_clear(pmd_t *pmd)
88{ 97{
89 *dst = val; 98 native_set_pmd(pmd, native_make_pmd(0));
90} 99}
91 100
92static inline void pgd_clear (pgd_t * pgd) 101static inline void native_set_pud(pud_t *pudp, pud_t pud)
93{ 102{
94 set_pgd(pgd, __pgd(0)); 103 *pudp = pud;
95} 104}
96 105
97#define native_ptep_get_and_clear(xp) __pte(xchg(&(xp)->pte, 0)) 106static inline void native_pud_clear(pud_t *pud)
107{
108 native_set_pud(pud, native_make_pud(0));
109}
98 110
99struct mm_struct; 111static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
112{
113 *pgdp = pgd;
114}
100 115
101static inline pte_t native_ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full) 116static inline void native_pgd_clear(pgd_t * pgd)
102{ 117{
103 pte_t pte; 118 native_set_pgd(pgd, native_make_pgd(0));
104 if (full) {
105 pte = *ptep;
106 *ptep = __pte(0);
107 } else {
108 pte = native_ptep_get_and_clear(ptep);
109 }
110 return pte;
111} 119}
112 120
113#define pte_same(a, b) ((a).pte == (b).pte) 121#define pte_same(a, b) ((a).pte == (b).pte)
@@ -151,7 +159,6 @@ static inline unsigned long pmd_bad(pmd_t pmd)
151 159
152#define pte_none(x) (!pte_val(x)) 160#define pte_none(x) (!pte_val(x))
153#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) 161#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
154#define native_pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
155 162
156#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) /* FIXME: is this right? */ 163#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) /* FIXME: is this right? */
157#define pte_page(x) pfn_to_page(pte_pfn(x)) 164#define pte_page(x) pfn_to_page(pte_pfn(x))
@@ -196,7 +203,6 @@ static inline unsigned long pmd_bad(pmd_t pmd)
196 pmd_index(address)) 203 pmd_index(address))
197#define pmd_none(x) (!pmd_val(x)) 204#define pmd_none(x) (!pmd_val(x))
198#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 205#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
199#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
200#define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot))) 206#define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot)))
201#define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) 207#define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT)
202 208