aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/pgtable-3level.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-x86/pgtable-3level.h')
-rw-r--r--include/asm-x86/pgtable-3level.h88
1 files changed, 37 insertions, 51 deletions
diff --git a/include/asm-x86/pgtable-3level.h b/include/asm-x86/pgtable-3level.h
index 948a33414118..a195c3e757b9 100644
--- a/include/asm-x86/pgtable-3level.h
+++ b/include/asm-x86/pgtable-3level.h
@@ -15,16 +15,18 @@
15#define pgd_ERROR(e) \ 15#define pgd_ERROR(e) \
16 printk("%s:%d: bad pgd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pgd_val(e)) 16 printk("%s:%d: bad pgd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pgd_val(e))
17 17
18#define pud_none(pud) 0
19#define pud_bad(pud) 0
20#define pud_present(pud) 1
21 18
22/* 19static inline int pud_none(pud_t pud)
23 * All present pages with !NX bit are kernel-executable: 20{
24 */ 21 return pud_val(pud) == 0;
25static inline int pte_exec_kernel(pte_t pte) 22}
23static inline int pud_bad(pud_t pud)
24{
25 return (pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER)) != 0;
26}
27static inline int pud_present(pud_t pud)
26{ 28{
27 return !(pte_val(pte) & _PAGE_NX); 29 return pud_val(pud) & _PAGE_PRESENT;
28} 30}
29 31
30/* Rules for using set_pte: the pte being assigned *must* be 32/* Rules for using set_pte: the pte being assigned *must* be
@@ -39,11 +41,6 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)
39 smp_wmb(); 41 smp_wmb();
40 ptep->pte_low = pte.pte_low; 42 ptep->pte_low = pte.pte_low;
41} 43}
42static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr,
43 pte_t *ptep , pte_t pte)
44{
45 native_set_pte(ptep, pte);
46}
47 44
48/* 45/*
49 * Since this is only called on user PTEs, and the page fault handler 46 * Since this is only called on user PTEs, and the page fault handler
@@ -71,7 +68,7 @@ static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
71} 68}
72static inline void native_set_pud(pud_t *pudp, pud_t pud) 69static inline void native_set_pud(pud_t *pudp, pud_t pud)
73{ 70{
74 *pudp = pud; 71 set_64bit((unsigned long long *)(pudp),native_pud_val(pud));
75} 72}
76 73
77/* 74/*
@@ -94,24 +91,29 @@ static inline void native_pmd_clear(pmd_t *pmd)
94 *(tmp + 1) = 0; 91 *(tmp + 1) = 0;
95} 92}
96 93
97#ifndef CONFIG_PARAVIRT 94static inline void pud_clear(pud_t *pudp)
98#define set_pte(ptep, pte) native_set_pte(ptep, pte) 95{
99#define set_pte_at(mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte) 96 set_pud(pudp, __pud(0));
100#define set_pte_present(mm, addr, ptep, pte) native_set_pte_present(mm, addr, ptep, pte) 97
101#define set_pte_atomic(ptep, pte) native_set_pte_atomic(ptep, pte) 98 /*
102#define set_pmd(pmdp, pmd) native_set_pmd(pmdp, pmd) 99 * In principle we need to do a cr3 reload here to make sure
103#define set_pud(pudp, pud) native_set_pud(pudp, pud) 100 * the processor recognizes the changed pgd. In practice, all
104#define pte_clear(mm, addr, ptep) native_pte_clear(mm, addr, ptep) 101 * the places where pud_clear() gets called are followed by
105#define pmd_clear(pmd) native_pmd_clear(pmd) 102 * full tlb flushes anyway, so we can defer the cost here.
106#endif 103 *
107 104 * Specifically:
108/* 105 *
109 * Pentium-II erratum A13: in PAE mode we explicitly have to flush 106 * mm/memory.c:free_pmd_range() - immediately after the
110 * the TLB via cr3 if the top-level pgd is changed... 107 * pud_clear() it does a pmd_free_tlb(). We change the
111 * We do not let the generic code free and clear pgd entries due to 108 * mmu_gather structure to do a full tlb flush (which has the
112 * this erratum. 109 * effect of reloading cr3) when the pagetable free is
113 */ 110 * complete.
114static inline void pud_clear (pud_t * pud) { } 111 *
112 * arch/x86/mm/hugetlbpage.c:huge_pmd_unshare() - the call to
113 * this is followed by a flush_tlb_range, which on x86 does a
114 * full tlb flush.
115 */
116}
115 117
116#define pud_page(pud) \ 118#define pud_page(pud) \
117((struct page *) __va(pud_val(pud) & PAGE_MASK)) 119((struct page *) __va(pud_val(pud) & PAGE_MASK))
@@ -155,21 +157,7 @@ static inline int pte_none(pte_t pte)
155 157
156static inline unsigned long pte_pfn(pte_t pte) 158static inline unsigned long pte_pfn(pte_t pte)
157{ 159{
158 return pte_val(pte) >> PAGE_SHIFT; 160 return (pte_val(pte) & ~_PAGE_NX) >> PAGE_SHIFT;
159}
160
161extern unsigned long long __supported_pte_mask;
162
163static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
164{
165 return __pte((((unsigned long long)page_nr << PAGE_SHIFT) |
166 pgprot_val(pgprot)) & __supported_pte_mask);
167}
168
169static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
170{
171 return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) |
172 pgprot_val(pgprot)) & __supported_pte_mask);
173} 161}
174 162
175/* 163/*
@@ -177,7 +165,7 @@ static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
177 * put the 32 bits of offset into the high part. 165 * put the 32 bits of offset into the high part.
178 */ 166 */
179#define pte_to_pgoff(pte) ((pte).pte_high) 167#define pte_to_pgoff(pte) ((pte).pte_high)
180#define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) }) 168#define pgoff_to_pte(off) ((pte_t) { { .pte_low = _PAGE_FILE, .pte_high = (off) } })
181#define PTE_FILE_MAX_BITS 32 169#define PTE_FILE_MAX_BITS 32
182 170
183/* Encode and de-code a swap entry */ 171/* Encode and de-code a swap entry */
@@ -185,8 +173,6 @@ static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
185#define __swp_offset(x) ((x).val >> 5) 173#define __swp_offset(x) ((x).val >> 5)
186#define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) << 5}) 174#define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) << 5})
187#define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high }) 175#define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high })
188#define __swp_entry_to_pte(x) ((pte_t){ 0, (x).val }) 176#define __swp_entry_to_pte(x) ((pte_t){ { .pte_high = (x).val } })
189
190#define __pmd_free_tlb(tlb, x) do { } while (0)
191 177
192#endif /* _I386_PGTABLE_3LEVEL_H */ 178#endif /* _I386_PGTABLE_3LEVEL_H */