x86: Don't let pgprot_modify() change the page encryption bit
[linux-2.6-microblaze.git] / arch / x86 / include / asm / pgtable.h
index 7e11866..64a03f2 100644 (file)
@@ -627,12 +627,15 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
        return __pmd(val);
 }
 
-/* mprotect needs to preserve PAT bits when updating vm_page_prot */
+/*
+ * mprotect needs to preserve PAT and encryption 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);
+       pgprotval_t addbits = pgprot_val(newprot) & ~_PAGE_CHG_MASK;
        return __pgprot(preservebits | addbits);
 }