Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 96746
b: refs/heads/master
c: 1c12c4c
h: refs/heads/master
v: v3
  • Loading branch information
Venki Pallipadi authored and Linus Torvalds committed May 15, 2008
1 parent 16ffa26 commit 4e356f3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 44c81433e8b05dbc85985d939046f10f95901184
refs/heads/master: 1c12c4cf9411eb130b245fa8d0fbbaf989477c7b
16 changes: 13 additions & 3 deletions trunk/include/asm-x86/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \
_PAGE_DIRTY)

#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_PCD | _PAGE_PWT | \
_PAGE_ACCESSED | _PAGE_DIRTY)

#define _PAGE_CACHE_MASK (_PAGE_PCD | _PAGE_PWT)
#define _PAGE_CACHE_WB (0)
Expand Down Expand Up @@ -288,12 +289,21 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
* Chop off the NX bit (if present), and add the NX portion of
* the newprot (if present):
*/
val &= _PAGE_CHG_MASK & ~_PAGE_NX;
val |= pgprot_val(newprot) & __supported_pte_mask;
val &= _PAGE_CHG_MASK;
val |= pgprot_val(newprot) & (~_PAGE_CHG_MASK) & __supported_pte_mask;

return __pte(val);
}

/* mprotect needs to preserve PAT bits when updating vm_page_prot */
#define pgprot_modify pgprot_modify
static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
{
pgprotval_t preservebits = pgprot_val(oldprot) & _PAGE_CHG_MASK;
pgprotval_t addbits = pgprot_val(newprot);
return __pgprot(preservebits | addbits);
}

#define pte_pgprot(x) __pgprot(pte_val(x) & (0xfff | _PAGE_NX))

#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask)
Expand Down
11 changes: 10 additions & 1 deletion trunk/mm/mprotect.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>

#ifndef pgprot_modify
static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
{
return newprot;
}
#endif

static void change_pte_range(struct mm_struct *mm, pmd_t *pmd,
unsigned long addr, unsigned long end, pgprot_t newprot,
int dirty_accountable)
Expand Down Expand Up @@ -192,7 +199,9 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
* held in write mode.
*/
vma->vm_flags = newflags;
vma->vm_page_prot = vm_get_page_prot(newflags);
vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
vm_get_page_prot(newflags));

if (vma_wants_writenotify(vma)) {
vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
dirty_accountable = 1;
Expand Down

0 comments on commit 4e356f3

Please sign in to comment.