aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2008-01-30 07:33:42 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:33:42 -0500
commit4c3c4b4513a361cc6ac5ee8677695260c4f0f25f (patch)
tree3a56ada5131a85fff2bb37841d822d098b92f68c
parente66a95127dc4273d3573eb03657991f7bbd5dca3 (diff)
x86: clean up pte_exec
- Rename it to pte_exec() from pte_exec_kernel(). There is nothing kernel specific in there. - Move it into the common file because _PAGE_NX is 0 on !PAE and then pte_exec() will be always evaluate to true. Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/mm/fault_32.c2
-rw-r--r--arch/x86/mm/init_32.c2
-rw-r--r--include/asm-x86/pgtable-2level.h8
-rw-r--r--include/asm-x86/pgtable-3level.h8
-rw-r--r--include/asm-x86/pgtable.h1
5 files changed, 3 insertions, 18 deletions
diff --git a/arch/x86/mm/fault_32.c b/arch/x86/mm/fault_32.c
index 41c31968a74c..f7972ae7da07 100644
--- a/arch/x86/mm/fault_32.c
+++ b/arch/x86/mm/fault_32.c
@@ -615,7 +615,7 @@ no_context:
615 if (error_code & PF_INSTR) { 615 if (error_code & PF_INSTR) {
616 pte_t *pte = lookup_address(address); 616 pte_t *pte = lookup_address(address);
617 617
618 if (pte && pte_present(*pte) && !pte_exec_kernel(*pte)) 618 if (pte && pte_present(*pte) && !pte_exec(*pte))
619 printk(KERN_CRIT "kernel tried to execute " 619 printk(KERN_CRIT "kernel tried to execute "
620 "NX-protected page - exploit attempt? " 620 "NX-protected page - exploit attempt? "
621 "(uid: %d)\n", current->uid); 621 "(uid: %d)\n", current->uid);
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 724a5eff6f34..5080646da771 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -542,7 +542,7 @@ int __init set_kernel_exec(unsigned long vaddr, int enable)
542 pte = lookup_address(vaddr); 542 pte = lookup_address(vaddr);
543 BUG_ON(!pte); 543 BUG_ON(!pte);
544 544
545 if (!pte_exec_kernel(*pte)) 545 if (!pte_exec(*pte))
546 ret = 0; 546 ret = 0;
547 547
548 if (enable) 548 if (enable)
diff --git a/include/asm-x86/pgtable-2level.h b/include/asm-x86/pgtable-2level.h
index ce486bdbbbb7..701404fab308 100644
--- a/include/asm-x86/pgtable-2level.h
+++ b/include/asm-x86/pgtable-2level.h
@@ -56,14 +56,6 @@ static inline pte_t native_ptep_get_and_clear(pte_t *xp)
56#define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT) 56#define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT)
57 57
58/* 58/*
59 * All present pages are kernel-executable:
60 */
61static inline int pte_exec_kernel(pte_t pte)
62{
63 return 1;
64}
65
66/*
67 * Bits 0, 6 and 7 are taken, split up the 29 bits of offset 59 * Bits 0, 6 and 7 are taken, split up the 29 bits of offset
68 * into this range: 60 * into this range:
69 */ 61 */
diff --git a/include/asm-x86/pgtable-3level.h b/include/asm-x86/pgtable-3level.h
index 62bb06575d5a..62a1ffbc8784 100644
--- a/include/asm-x86/pgtable-3level.h
+++ b/include/asm-x86/pgtable-3level.h
@@ -19,14 +19,6 @@
19#define pud_bad(pud) 0 19#define pud_bad(pud) 0
20#define pud_present(pud) 1 20#define pud_present(pud) 1
21 21
22/*
23 * All present pages with !NX bit are kernel-executable:
24 */
25static inline int pte_exec_kernel(pte_t pte)
26{
27 return !(pte_val(pte) & _PAGE_NX);
28}
29
30/* Rules for using set_pte: the pte being assigned *must* be 22/* Rules for using set_pte: the pte being assigned *must* be
31 * either not present or in a state where the hardware will 23 * either not present or in a state where the hardware will
32 * not attempt to update the pte. In places where this is 24 * not attempt to update the pte. In places where this is
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 75a656e6b3f8..2f3d90807efb 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -139,6 +139,7 @@ static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;
139static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; } 139static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; }
140static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; } 140static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
141static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_PSE; } 141static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_PSE; }
142static inline int pte_exec(pte_t pte) { return !(pte_val(pte) & _PAGE_NX); }
142 143
143static inline int pmd_large(pmd_t pte) { 144static inline int pmd_large(pmd_t pte) {
144 return (pmd_val(pte) & (_PAGE_PSE|_PAGE_PRESENT)) == 145 return (pmd_val(pte) & (_PAGE_PSE|_PAGE_PRESENT)) ==