[PATCH] x86: make nx_enabled conditional on CONFIG_X86_PAE

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Harvey Harrison
Date: Tuesday, January 22, 2008 - 2:00 pm

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



--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] x86: make nx_enabled conditional on CONFIG_X86_PAE, Harvey Harrison, (Tue Jan 22, 2:00 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Jeremy Fitzhardinge, (Wed Jan 23, 6:06 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Jeremy Fitzhardinge, (Thu Jan 24, 3:35 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Jeremy Fitzhardinge, (Thu Jan 24, 3:58 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Jeremy Fitzhardinge, (Thu Jan 24, 4:40 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Jeremy Fitzhardinge, (Thu Jan 24, 4:51 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Jeremy Fitzhardinge, (Thu Jan 24, 5:11 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Jeremy Fitzhardinge, (Thu Jan 24, 5:31 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Rafael J. Wysocki, (Thu Jan 24, 5:46 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Eric W. Biederman, (Thu Jan 24, 7:16 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Eric W. Biederman, (Thu Jan 24, 7:56 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Jeremy Fitzhardinge, (Thu Jan 24, 9:41 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Eric W. Biederman, (Fri Jan 25, 4:07 am)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Rafael J. Wysocki, (Fri Jan 25, 3:02 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Rafael J. Wysocki, (Mon Jan 28, 8:25 am)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Rafael J. Wysocki, (Mon Jan 28, 10:02 am)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Jeremy Fitzhardinge, (Mon Jan 28, 1:03 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Rafael J. Wysocki, (Mon Jan 28, 1:26 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Rafael J. Wysocki, (Mon Jan 28, 1:28 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Jeremy Fitzhardinge, (Mon Jan 28, 1:44 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Rafael J. Wysocki, (Mon Jan 28, 1:50 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Rafael J. Wysocki, (Mon Jan 28, 1:59 pm)
Re: [PATCH] x86: Construct 32 bit boot time page tables in ..., Rafael J. Wysocki, (Mon Jan 28, 3:02 pm)