x86: clean up differences between 64-bit and 32-bit
authorIngo Molnar <mingo@elte.hu>
Wed, 30 Jan 2008 12:34:03 +0000 (13:34 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 30 Jan 2008 12:34:03 +0000 (13:34 +0100)
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/mm/pageattr_64.c

index 139795029fb631cf3f907d39cbc0349e08b1df6b..60cfb687f97cb4117dd47b90ba9f000fc4625d96 100644 (file)
@@ -126,30 +126,36 @@ out_unlock:
 static int
 __change_page_attr(unsigned long address, struct page *page, pgprot_t prot)
 {
-       pgprot_t ref_prot2, oldprot;
        struct page *kpte_page;
        int level, err = 0;
        pte_t *kpte;
 
+       BUG_ON(PageHighMem(page));
+
 repeat:
        kpte = lookup_address(address, &level);
        if (!kpte)
                return 0;
 
        kpte_page = virt_to_page(kpte);
-       oldprot = pte_pgprot(*kpte);
        BUG_ON(PageLRU(kpte_page));
        BUG_ON(PageCompound(kpte_page));
-       prot = canon_pgprot(prot);
+
+       /*
+        * Better fail early if someone sets the kernel text to NX.
+        * Does not cover __inittext
+        */
+       BUG_ON(address >= (unsigned long)&_text &&
+               address < (unsigned long)&_etext &&
+              (pgprot_val(prot) & _PAGE_NX));
 
        if (level == 4) {
-               set_pte_atomic(kpte, mk_pte(page, prot));
+               set_pte_atomic(kpte, mk_pte(page, canon_pgprot(prot)));
        } else {
                err = split_large_page(kpte, address);
                if (!err)
                        goto repeat;
        }
-
        return err;
 }