aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86/pgtable.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-x86/pgtable.h')
-rw-r--r--include/asm-x86/pgtable.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 801b31f71452..97c271b2910b 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -57,7 +57,9 @@
57#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ 57#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \
58 _PAGE_DIRTY) 58 _PAGE_DIRTY)
59 59
60#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) 60/* Set of bits not changed in pte_modify */
61#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_PCD | _PAGE_PWT | \
62 _PAGE_ACCESSED | _PAGE_DIRTY)
61 63
62#define _PAGE_CACHE_MASK (_PAGE_PCD | _PAGE_PWT) 64#define _PAGE_CACHE_MASK (_PAGE_PCD | _PAGE_PWT)
63#define _PAGE_CACHE_WB (0) 65#define _PAGE_CACHE_WB (0)
@@ -288,13 +290,22 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
288 * Chop off the NX bit (if present), and add the NX portion of 290 * Chop off the NX bit (if present), and add the NX portion of
289 * the newprot (if present): 291 * the newprot (if present):
290 */ 292 */
291 val &= _PAGE_CHG_MASK & ~_PAGE_NX; 293 val &= _PAGE_CHG_MASK;
292 val |= pgprot_val(newprot) & __supported_pte_mask; 294 val |= pgprot_val(newprot) & (~_PAGE_CHG_MASK) & __supported_pte_mask;
293 295
294 return __pte(val); 296 return __pte(val);
295} 297}
296 298
297#define pte_pgprot(x) __pgprot(pte_val(x) & (0xfff | _PAGE_NX)) 299/* mprotect needs to preserve PAT bits when updating vm_page_prot */
300#define pgprot_modify pgprot_modify
301static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
302{
303 pgprotval_t preservebits = pgprot_val(oldprot) & _PAGE_CHG_MASK;
304 pgprotval_t addbits = pgprot_val(newprot);
305 return __pgprot(preservebits | addbits);
306}
307
308#define pte_pgprot(x) __pgprot(pte_val(x) & ~PTE_MASK)
298 309
299#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask) 310#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask)
300 311