lkml.org 
[lkml]   [2008]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] x86: make nx_enabled conditional on CONFIG_X86_PAE
From
Date
nx_enabled can only be set to non-zero when CONFIG_X86_PAE is
set. The only use not currently inside a CONFIG_X86_PAE block
is the definition, the declaration and a conditional unlikely
test in fault_32.c (is_prefetch).

When !CONFIG_X86_PAE, is_prefetch always returns 0 immediately
as nx_enabled is always 0.

When CONFIG_X86_PAE, the test is preserved, but the test against
the cpu model and stepping is deleted, this may not be correct.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
Ingo, further to your nx vs !nx comment, had this lying around,
needs testing, only affects the CONFIG_X86_PAE case.
arch/x86/mm/fault_32.c | 17 ++++++++---------
arch/x86/mm/fault_64.c | 17 ++++++++---------
arch/x86/mm/init_32.c | 4 +---
include/asm-x86/page_32.h | 2 ++
4 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/arch/x86/mm/fault_32.c b/arch/x86/mm/fault_32.c
index 0bd2417..049c3bb 100644
--- a/arch/x86/mm/fault_32.c
+++ b/arch/x86/mm/fault_32.c
@@ -81,16 +81,15 @@ static int is_prefetch(struct pt_regs *regs, unsigned long addr,
unsigned char *max_instr;

#ifdef CONFIG_X86_32
- if (unlikely(boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
- boot_cpu_data.x86 >= 6)) {
- /* Catch an obscure case of prefetch inside an NX page. */
- if (nx_enabled && (error_code & PF_INSTR))
- return 0;
- } else {
+# ifdef CONFIG_X86_PAE
+ /* If it was a exec fault on NX page, ignore */
+ if (nx_enabled && (error_code & PF_INSTR))
return 0;
- }
-#else
- /* If it was a exec fault ignore */
+# else
+ return 0;
+# endif
+#else /* CONFIG_X86_64 */
+ /* If it was a exec fault on NX page, ignore */
if (error_code & PF_INSTR)
return 0;
#endif
diff --git a/arch/x86/mm/fault_64.c b/arch/x86/mm/fault_64.c
index ccbb8e3..33e8ced 100644
--- a/arch/x86/mm/fault_64.c
+++ b/arch/x86/mm/fault_64.c
@@ -84,16 +84,15 @@ static int is_prefetch(struct pt_regs *regs, unsigned long addr,
unsigned char *max_instr;

#ifdef CONFIG_X86_32
- if (unlikely(boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
- boot_cpu_data.x86 >= 6)) {
- /* Catch an obscure case of prefetch inside an NX page. */
- if (nx_enabled && (error_code & PF_INSTR))
- return 0;
- } else {
+# ifdef CONFIG_X86_PAE
+ /* If it was a exec fault on NX page, ignore */
+ if (nx_enabled && (error_code & PF_INSTR))
return 0;
- }
-#else
- /* If it was a exec fault ignore */
+# else
+ return 0;
+# endif
+#else /* CONFIG_X86_64 */
+ /* If it was a exec fault on NX page, ignore */
if (error_code & PF_INSTR)
return 0;
#endif
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 358d3b9..317cf5d 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -478,13 +478,11 @@ void zap_low_mappings (void)
flush_tlb_all();
}

-int nx_enabled = 0;
-
pteval_t __supported_pte_mask __read_mostly = ~_PAGE_NX;
EXPORT_SYMBOL_GPL(__supported_pte_mask);

#ifdef CONFIG_X86_PAE
-
+int nx_enabled = 0;
static int disable_nx __initdata = 0;

/*
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
index 11c4b39..251f972 100644
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -65,7 +65,9 @@ typedef pte_t boot_pte_t;
#define pfn_valid(pfn) ((pfn) < max_mapnr)
#endif /* CONFIG_FLATMEM */

+#ifdef CONFIG_X86_PAE
extern int nx_enabled;
+#endif

/*
* This much address space is reserved for vmalloc() and iomap()
--
1.5.4.rc3.1118.gf6754c




\
 
 \ /
  Last update: 2008-01-22 22:15    [W:0.212 / U:0.352 seconds]
©2003-2014 Jasper Spaans. Advertise on this site