Jeremy Fitzhardinge | 6c38665 | 2008-01-30 13:32:55 +0100 | [diff] [blame] | 1 | #ifndef _ASM_X86_PGTABLE_H |
| 2 | #define _ASM_X86_PGTABLE_H |
| 3 | |
| 4 | #define USER_PTRS_PER_PGD ((TASK_SIZE-1)/PGDIR_SIZE+1) |
| 5 | #define FIRST_USER_ADDRESS 0 |
| 6 | |
| 7 | #define _PAGE_BIT_PRESENT 0 |
| 8 | #define _PAGE_BIT_RW 1 |
| 9 | #define _PAGE_BIT_USER 2 |
| 10 | #define _PAGE_BIT_PWT 3 |
| 11 | #define _PAGE_BIT_PCD 4 |
| 12 | #define _PAGE_BIT_ACCESSED 5 |
| 13 | #define _PAGE_BIT_DIRTY 6 |
| 14 | #define _PAGE_BIT_FILE 6 |
| 15 | #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */ |
| 16 | #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */ |
| 17 | #define _PAGE_BIT_UNUSED1 9 /* available for programmer */ |
| 18 | #define _PAGE_BIT_UNUSED2 10 |
| 19 | #define _PAGE_BIT_UNUSED3 11 |
| 20 | #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */ |
| 21 | |
Jeremy Fitzhardinge | f291923 | 2008-01-30 13:32:59 +0100 | [diff] [blame] | 22 | /* |
| 23 | * Note: we use _AC(1, L) instead of _AC(1, UL) so that we get a |
| 24 | * sign-extended value on 32-bit with all 1's in the upper word, |
| 25 | * which preserves the upper pte values on 64-bit ptes: |
| 26 | */ |
Ingo Molnar | 61f38226 | 2008-01-30 13:32:55 +0100 | [diff] [blame] | 27 | #define _PAGE_PRESENT (_AC(1, L)<<_PAGE_BIT_PRESENT) |
| 28 | #define _PAGE_RW (_AC(1, L)<<_PAGE_BIT_RW) |
| 29 | #define _PAGE_USER (_AC(1, L)<<_PAGE_BIT_USER) |
| 30 | #define _PAGE_PWT (_AC(1, L)<<_PAGE_BIT_PWT) |
| 31 | #define _PAGE_PCD (_AC(1, L)<<_PAGE_BIT_PCD) |
| 32 | #define _PAGE_ACCESSED (_AC(1, L)<<_PAGE_BIT_ACCESSED) |
| 33 | #define _PAGE_DIRTY (_AC(1, L)<<_PAGE_BIT_DIRTY) |
| 34 | #define _PAGE_PSE (_AC(1, L)<<_PAGE_BIT_PSE) /* 2MB page */ |
| 35 | #define _PAGE_GLOBAL (_AC(1, L)<<_PAGE_BIT_GLOBAL) /* Global TLB entry */ |
| 36 | #define _PAGE_UNUSED1 (_AC(1, L)<<_PAGE_BIT_UNUSED1) |
| 37 | #define _PAGE_UNUSED2 (_AC(1, L)<<_PAGE_BIT_UNUSED2) |
| 38 | #define _PAGE_UNUSED3 (_AC(1, L)<<_PAGE_BIT_UNUSED3) |
Jeremy Fitzhardinge | 6c38665 | 2008-01-30 13:32:55 +0100 | [diff] [blame] | 39 | |
| 40 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) |
| 41 | #define _PAGE_NX (_AC(1, ULL) << _PAGE_BIT_NX) |
| 42 | #else |
| 43 | #define _PAGE_NX 0 |
| 44 | #endif |
| 45 | |
| 46 | /* If _PAGE_PRESENT is clear, we use these: */ |
| 47 | #define _PAGE_FILE _PAGE_DIRTY /* nonlinear file mapping, saved PTE; unset:swap */ |
| 48 | #define _PAGE_PROTNONE _PAGE_PSE /* if the user mapped it with PROT_NONE; |
| 49 | pte_present gives true */ |
| 50 | |
| 51 | #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) |
| 52 | #define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) |
| 53 | |
| 54 | #define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) |
| 55 | |
| 56 | #define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED) |
| 57 | #define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) |
| 58 | |
| 59 | #define PAGE_SHARED_EXEC __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED) |
| 60 | #define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) |
| 61 | #define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) |
| 62 | #define PAGE_COPY PAGE_COPY_NOEXEC |
| 63 | #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX) |
| 64 | #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED) |
| 65 | |
| 66 | #ifdef CONFIG_X86_32 |
| 67 | #define _PAGE_KERNEL_EXEC \ |
| 68 | (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) |
| 69 | #define _PAGE_KERNEL (_PAGE_KERNEL_EXEC | _PAGE_NX) |
| 70 | |
| 71 | #ifndef __ASSEMBLY__ |
Andi Kleen | c93c82b | 2008-01-30 13:33:50 +0100 | [diff] [blame] | 72 | extern pteval_t __PAGE_KERNEL, __PAGE_KERNEL_EXEC; |
Jeremy Fitzhardinge | 6c38665 | 2008-01-30 13:32:55 +0100 | [diff] [blame] | 73 | #endif /* __ASSEMBLY__ */ |
| 74 | #else |
| 75 | #define __PAGE_KERNEL_EXEC \ |
| 76 | (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) |
| 77 | #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX) |
| 78 | #endif |
| 79 | |
| 80 | #define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW) |
| 81 | #define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW) |
| 82 | #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT) |
| 83 | #define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER) |
| 84 | #define __PAGE_KERNEL_VSYSCALL_NOCACHE (__PAGE_KERNEL_VSYSCALL | _PAGE_PCD | _PAGE_PWT) |
| 85 | #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE) |
| 86 | #define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE) |
| 87 | |
| 88 | #ifdef CONFIG_X86_32 |
| 89 | # define MAKE_GLOBAL(x) __pgprot((x)) |
| 90 | #else |
| 91 | # define MAKE_GLOBAL(x) __pgprot((x) | _PAGE_GLOBAL) |
| 92 | #endif |
| 93 | |
| 94 | #define PAGE_KERNEL MAKE_GLOBAL(__PAGE_KERNEL) |
| 95 | #define PAGE_KERNEL_RO MAKE_GLOBAL(__PAGE_KERNEL_RO) |
| 96 | #define PAGE_KERNEL_EXEC MAKE_GLOBAL(__PAGE_KERNEL_EXEC) |
| 97 | #define PAGE_KERNEL_RX MAKE_GLOBAL(__PAGE_KERNEL_RX) |
| 98 | #define PAGE_KERNEL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_NOCACHE) |
| 99 | #define PAGE_KERNEL_LARGE MAKE_GLOBAL(__PAGE_KERNEL_LARGE) |
| 100 | #define PAGE_KERNEL_LARGE_EXEC MAKE_GLOBAL(__PAGE_KERNEL_LARGE_EXEC) |
| 101 | #define PAGE_KERNEL_VSYSCALL MAKE_GLOBAL(__PAGE_KERNEL_VSYSCALL) |
| 102 | #define PAGE_KERNEL_VSYSCALL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_VSYSCALL_NOCACHE) |
| 103 | |
| 104 | /* xwr */ |
| 105 | #define __P000 PAGE_NONE |
| 106 | #define __P001 PAGE_READONLY |
| 107 | #define __P010 PAGE_COPY |
| 108 | #define __P011 PAGE_COPY |
| 109 | #define __P100 PAGE_READONLY_EXEC |
| 110 | #define __P101 PAGE_READONLY_EXEC |
| 111 | #define __P110 PAGE_COPY_EXEC |
| 112 | #define __P111 PAGE_COPY_EXEC |
| 113 | |
| 114 | #define __S000 PAGE_NONE |
| 115 | #define __S001 PAGE_READONLY |
| 116 | #define __S010 PAGE_SHARED |
| 117 | #define __S011 PAGE_SHARED |
| 118 | #define __S100 PAGE_READONLY_EXEC |
| 119 | #define __S101 PAGE_READONLY_EXEC |
| 120 | #define __S110 PAGE_SHARED_EXEC |
| 121 | #define __S111 PAGE_SHARED_EXEC |
| 122 | |
Jeremy Fitzhardinge | 4614139 | 2008-01-30 13:32:56 +0100 | [diff] [blame] | 123 | #ifndef __ASSEMBLY__ |
Jeremy Fitzhardinge | 195466d | 2008-01-30 13:32:58 +0100 | [diff] [blame] | 124 | |
Jeremy Fitzhardinge | 4614139 | 2008-01-30 13:32:56 +0100 | [diff] [blame] | 125 | /* |
Jeremy Fitzhardinge | 8405b12 | 2008-01-30 13:32:58 +0100 | [diff] [blame] | 126 | * ZERO_PAGE is a global shared page that is always zero: used |
| 127 | * for zero-mapped memory areas etc.. |
| 128 | */ |
| 129 | extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)]; |
| 130 | #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) |
| 131 | |
| 132 | |
| 133 | /* |
Jeremy Fitzhardinge | 4614139 | 2008-01-30 13:32:56 +0100 | [diff] [blame] | 134 | * The following only work if pte_present() is true. |
| 135 | * Undefined behaviour if not.. |
| 136 | */ |
| 137 | static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } |
| 138 | static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } |
| 139 | static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; } |
| 140 | static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } |
| 141 | static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_PSE; } |
Andi Kleen | a5a5dc3 | 2008-01-30 13:33:42 +0100 | [diff] [blame] | 142 | static inline int pte_global(pte_t pte) { return pte_val(pte) & _PAGE_GLOBAL; } |
Andi Kleen | 4c3c4b4 | 2008-01-30 13:33:42 +0100 | [diff] [blame] | 143 | static inline int pte_exec(pte_t pte) { return !(pte_val(pte) & _PAGE_NX); } |
Jeremy Fitzhardinge | 4614139 | 2008-01-30 13:32:56 +0100 | [diff] [blame] | 144 | |
| 145 | static inline int pmd_large(pmd_t pte) { |
| 146 | return (pmd_val(pte) & (_PAGE_PSE|_PAGE_PRESENT)) == |
| 147 | (_PAGE_PSE|_PAGE_PRESENT); |
| 148 | } |
| 149 | |
Andi Kleen | aaa0e89 | 2008-01-30 13:33:51 +0100 | [diff] [blame] | 150 | static inline pte_t pte_mkclean(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_DIRTY); } |
| 151 | static inline pte_t pte_mkold(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_ACCESSED); } |
| 152 | static inline pte_t pte_wrprotect(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_RW); } |
| 153 | static inline pte_t pte_mkexec(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_NX); } |
Jeremy Fitzhardinge | 4614139 | 2008-01-30 13:32:56 +0100 | [diff] [blame] | 154 | static inline pte_t pte_mkdirty(pte_t pte) { return __pte(pte_val(pte) | _PAGE_DIRTY); } |
| 155 | static inline pte_t pte_mkyoung(pte_t pte) { return __pte(pte_val(pte) | _PAGE_ACCESSED); } |
| 156 | static inline pte_t pte_mkwrite(pte_t pte) { return __pte(pte_val(pte) | _PAGE_RW); } |
| 157 | static inline pte_t pte_mkhuge(pte_t pte) { return __pte(pte_val(pte) | _PAGE_PSE); } |
Andi Kleen | aaa0e89 | 2008-01-30 13:33:51 +0100 | [diff] [blame] | 158 | static inline pte_t pte_clrhuge(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_PSE); } |
Andi Kleen | a5a5dc3 | 2008-01-30 13:33:42 +0100 | [diff] [blame] | 159 | static inline pte_t pte_mkglobal(pte_t pte) { return __pte(pte_val(pte) | _PAGE_GLOBAL); } |
Andi Kleen | aaa0e89 | 2008-01-30 13:33:51 +0100 | [diff] [blame] | 160 | static inline pte_t pte_clrglobal(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_GLOBAL); } |
Jeremy Fitzhardinge | 4614139 | 2008-01-30 13:32:56 +0100 | [diff] [blame] | 161 | |
Jeremy Fitzhardinge | 6fdc05d | 2008-01-30 13:32:57 +0100 | [diff] [blame] | 162 | extern pteval_t __supported_pte_mask; |
| 163 | |
| 164 | static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) |
| 165 | { |
| 166 | return __pte((((phys_addr_t)page_nr << PAGE_SHIFT) | |
| 167 | pgprot_val(pgprot)) & __supported_pte_mask); |
| 168 | } |
| 169 | |
| 170 | static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) |
| 171 | { |
| 172 | return __pmd((((phys_addr_t)page_nr << PAGE_SHIFT) | |
| 173 | pgprot_val(pgprot)) & __supported_pte_mask); |
| 174 | } |
| 175 | |
Ingo Molnar | 3847231 | 2008-01-30 13:32:57 +0100 | [diff] [blame] | 176 | static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) |
| 177 | { |
| 178 | pteval_t val = pte_val(pte); |
| 179 | |
| 180 | /* |
| 181 | * Chop off the NX bit (if present), and add the NX portion of |
| 182 | * the newprot (if present): |
| 183 | */ |
| 184 | val &= _PAGE_CHG_MASK & ~_PAGE_NX; |
| 185 | val |= pgprot_val(newprot) & __supported_pte_mask; |
| 186 | |
| 187 | return __pte(val); |
| 188 | } |
| 189 | |
Andi Kleen | c6ca18e | 2008-01-30 13:33:51 +0100 | [diff] [blame] | 190 | #define pte_pgprot(x) __pgprot(pte_val(x) & (0xfff | _PAGE_NX)) |
| 191 | |
Andi Kleen | 1e8e23b | 2008-01-30 13:33:53 +0100 | [diff] [blame^] | 192 | #define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask) |
| 193 | |
Jeremy Fitzhardinge | 4891645 | 2008-01-30 13:32:58 +0100 | [diff] [blame] | 194 | #ifdef CONFIG_PARAVIRT |
| 195 | #include <asm/paravirt.h> |
| 196 | #else /* !CONFIG_PARAVIRT */ |
| 197 | #define set_pte(ptep, pte) native_set_pte(ptep, pte) |
| 198 | #define set_pte_at(mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte) |
| 199 | |
| 200 | #define set_pte_present(mm, addr, ptep, pte) \ |
| 201 | native_set_pte_present(mm, addr, ptep, pte) |
| 202 | #define set_pte_atomic(ptep, pte) \ |
| 203 | native_set_pte_atomic(ptep, pte) |
| 204 | |
| 205 | #define set_pmd(pmdp, pmd) native_set_pmd(pmdp, pmd) |
| 206 | |
| 207 | #ifndef __PAGETABLE_PUD_FOLDED |
| 208 | #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd) |
| 209 | #define pgd_clear(pgd) native_pgd_clear(pgd) |
| 210 | #endif |
| 211 | |
| 212 | #ifndef set_pud |
| 213 | # define set_pud(pudp, pud) native_set_pud(pudp, pud) |
| 214 | #endif |
| 215 | |
| 216 | #ifndef __PAGETABLE_PMD_FOLDED |
| 217 | #define pud_clear(pud) native_pud_clear(pud) |
| 218 | #endif |
| 219 | |
| 220 | #define pte_clear(mm, addr, ptep) native_pte_clear(mm, addr, ptep) |
| 221 | #define pmd_clear(pmd) native_pmd_clear(pmd) |
| 222 | |
| 223 | #define pte_update(mm, addr, ptep) do { } while (0) |
| 224 | #define pte_update_defer(mm, addr, ptep) do { } while (0) |
| 225 | #endif /* CONFIG_PARAVIRT */ |
| 226 | |
Jeremy Fitzhardinge | 4614139 | 2008-01-30 13:32:56 +0100 | [diff] [blame] | 227 | #endif /* __ASSEMBLY__ */ |
| 228 | |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 229 | #ifdef CONFIG_X86_32 |
| 230 | # include "pgtable_32.h" |
| 231 | #else |
| 232 | # include "pgtable_64.h" |
| 233 | #endif |
Jeremy Fitzhardinge | 6c38665 | 2008-01-30 13:32:55 +0100 | [diff] [blame] | 234 | |
Jeremy Fitzhardinge | 195466d | 2008-01-30 13:32:58 +0100 | [diff] [blame] | 235 | #ifndef __ASSEMBLY__ |
| 236 | |
Jeremy Fitzhardinge | 4891645 | 2008-01-30 13:32:58 +0100 | [diff] [blame] | 237 | /* local pte updates need not use xchg for locking */ |
| 238 | static inline pte_t native_local_ptep_get_and_clear(pte_t *ptep) |
| 239 | { |
| 240 | pte_t res = *ptep; |
| 241 | |
| 242 | /* Pure native function needs no input for mm, addr */ |
| 243 | native_pte_clear(NULL, 0, ptep); |
| 244 | return res; |
| 245 | } |
| 246 | |
| 247 | static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr, |
| 248 | pte_t *ptep , pte_t pte) |
| 249 | { |
| 250 | native_set_pte(ptep, pte); |
| 251 | } |
| 252 | |
Jeremy Fitzhardinge | 195466d | 2008-01-30 13:32:58 +0100 | [diff] [blame] | 253 | #ifndef CONFIG_PARAVIRT |
| 254 | /* |
| 255 | * Rules for using pte_update - it must be called after any PTE update which |
| 256 | * has not been done using the set_pte / clear_pte interfaces. It is used by |
| 257 | * shadow mode hypervisors to resynchronize the shadow page tables. Kernel PTE |
| 258 | * updates should either be sets, clears, or set_pte_atomic for P->P |
| 259 | * transitions, which means this hook should only be called for user PTEs. |
| 260 | * This hook implies a P->P protection or access change has taken place, which |
| 261 | * requires a subsequent TLB flush. The notification can optionally be delayed |
| 262 | * until the TLB flush event by using the pte_update_defer form of the |
| 263 | * interface, but care must be taken to assure that the flush happens while |
| 264 | * still holding the same page table lock so that the shadow and primary pages |
| 265 | * do not become out of sync on SMP. |
| 266 | */ |
| 267 | #define pte_update(mm, addr, ptep) do { } while (0) |
| 268 | #define pte_update_defer(mm, addr, ptep) do { } while (0) |
| 269 | #endif |
| 270 | |
Jeremy Fitzhardinge | 195466d | 2008-01-30 13:32:58 +0100 | [diff] [blame] | 271 | /* |
| 272 | * We only update the dirty/accessed state if we set |
| 273 | * the dirty bit by hand in the kernel, since the hardware |
| 274 | * will do the accessed bit for us, and we don't want to |
| 275 | * race with other CPU's that might be updating the dirty |
| 276 | * bit at the same time. |
| 277 | */ |
| 278 | #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS |
| 279 | #define ptep_set_access_flags(vma, address, ptep, entry, dirty) \ |
| 280 | ({ \ |
| 281 | int __changed = !pte_same(*(ptep), entry); \ |
| 282 | if (__changed && dirty) { \ |
| 283 | *ptep = entry; \ |
| 284 | pte_update_defer((vma)->vm_mm, (address), (ptep)); \ |
| 285 | flush_tlb_page(vma, address); \ |
| 286 | } \ |
| 287 | __changed; \ |
| 288 | }) |
| 289 | |
| 290 | #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG |
| 291 | #define ptep_test_and_clear_young(vma, addr, ptep) ({ \ |
| 292 | int __ret = 0; \ |
| 293 | if (pte_young(*(ptep))) \ |
| 294 | __ret = test_and_clear_bit(_PAGE_BIT_ACCESSED, \ |
| 295 | &(ptep)->pte); \ |
| 296 | if (__ret) \ |
| 297 | pte_update((vma)->vm_mm, addr, ptep); \ |
| 298 | __ret; \ |
| 299 | }) |
| 300 | |
| 301 | #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH |
| 302 | #define ptep_clear_flush_young(vma, address, ptep) \ |
| 303 | ({ \ |
| 304 | int __young; \ |
| 305 | __young = ptep_test_and_clear_young((vma), (address), (ptep)); \ |
| 306 | if (__young) \ |
| 307 | flush_tlb_page(vma, address); \ |
| 308 | __young; \ |
| 309 | }) |
| 310 | |
| 311 | #define __HAVE_ARCH_PTEP_GET_AND_CLEAR |
| 312 | static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) |
| 313 | { |
| 314 | pte_t pte = native_ptep_get_and_clear(ptep); |
| 315 | pte_update(mm, addr, ptep); |
| 316 | return pte; |
| 317 | } |
| 318 | |
| 319 | #define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL |
| 320 | static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full) |
| 321 | { |
| 322 | pte_t pte; |
| 323 | if (full) { |
| 324 | /* |
| 325 | * Full address destruction in progress; paravirt does not |
| 326 | * care about updates and native needs no locking |
| 327 | */ |
| 328 | pte = native_local_ptep_get_and_clear(ptep); |
| 329 | } else { |
| 330 | pte = ptep_get_and_clear(mm, addr, ptep); |
| 331 | } |
| 332 | return pte; |
| 333 | } |
| 334 | |
| 335 | #define __HAVE_ARCH_PTEP_SET_WRPROTECT |
| 336 | static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) |
| 337 | { |
Jeremy Fitzhardinge | d8d8982 | 2008-01-30 13:32:58 +0100 | [diff] [blame] | 338 | clear_bit(_PAGE_BIT_RW, (unsigned long *)&ptep->pte); |
Jeremy Fitzhardinge | 195466d | 2008-01-30 13:32:58 +0100 | [diff] [blame] | 339 | pte_update(mm, addr, ptep); |
| 340 | } |
| 341 | |
Jeremy Fitzhardinge | 195466d | 2008-01-30 13:32:58 +0100 | [diff] [blame] | 342 | #include <asm-generic/pgtable.h> |
| 343 | #endif /* __ASSEMBLY__ */ |
| 344 | |
Jeremy Fitzhardinge | 6c38665 | 2008-01-30 13:32:55 +0100 | [diff] [blame] | 345 | #endif /* _ASM_X86_PGTABLE_H */ |