All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harvey Harrison <harvey.harrison@gmail.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	"Ian Campbell" <ijc@hellion.org.uk>,
	"Mika Penttilä" <mika.penttila@kolumbus.fi>,
	linux-kernel@vger.kernel.org,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: [PATCH] x86: make nx_enabled conditional on CONFIG_X86_PAE
Date: Tue, 22 Jan 2008 13:00:11 -0800	[thread overview]
Message-ID: <1201035611.16972.61.camel@brick> (raw)
In-Reply-To: <20080122203611.GA12892@elte.hu>

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




  parent reply	other threads:[~2008-01-22 21:00 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-19 16:08 [PATCH] x86/voyager: Switch voyager memory detection to early_ioremap Ian Campbell
2008-01-19 16:08 ` [PATCH] x86: Construct 32 bit boot time page tables in native format Ian Campbell
2008-01-19 23:07   ` Andi Kleen
2008-01-19 23:50     ` H. Peter Anvin
2008-01-20 16:44     ` Ian Campbell
2008-01-20 17:39       ` Andi Kleen
2008-01-20 18:48         ` H. Peter Anvin
2008-01-20 18:55           ` Andi Kleen
2008-01-20 18:54             ` H. Peter Anvin
2008-01-22 10:05           ` Ingo Molnar
2008-01-22 16:23             ` H. Peter Anvin
2008-01-20 18:30   ` Mika Penttilä
2008-01-21 21:23     ` Ian Campbell
2008-01-21 21:38       ` H. Peter Anvin
2008-01-21 21:46         ` Ian Campbell
2008-01-22  2:16           ` H. Peter Anvin
2008-01-22 17:36             ` Ian Campbell
2008-01-22 18:23               ` H. Peter Anvin
2008-01-22 19:48                 ` Ian Campbell
2008-01-22 20:00                   ` H. Peter Anvin
2008-01-22 20:36                     ` Ingo Molnar
2008-01-22 20:43                       ` H. Peter Anvin
2008-01-22 20:45                         ` Ingo Molnar
2008-01-22 20:52                       ` Ian Campbell
2008-01-22 21:00                         ` H. Peter Anvin
2008-01-22 22:21                           ` Ian Campbell
2008-01-22 21:00                       ` Harvey Harrison [this message]
2008-01-22 21:04                         ` [PATCH] x86: make nx_enabled conditional on CONFIG_X86_PAE Ingo Molnar
2008-01-22 21:35                           ` Harvey Harrison
2008-01-22 21:07                         ` Harvey Harrison
     [not found]                         ` <p73odbdlyiu.fsf@crumb.suse.de>
2008-01-23 11:21                           ` Harvey Harrison
2008-01-23 20:52                       ` [PATCH] x86: Construct 32 bit boot time page tables in native format Ian Campbell
2008-01-24  1:06                         ` Jeremy Fitzhardinge
2008-01-24  9:39                           ` Ian Campbell
2008-01-24 22:06                             ` H. Peter Anvin
2008-01-24 22:35                               ` Jeremy Fitzhardinge
2008-01-24 22:39                                 ` H. Peter Anvin
2008-01-24 22:58                                   ` Jeremy Fitzhardinge
2008-01-24 23:08                                     ` H. Peter Anvin
2008-01-24 23:40                                       ` Jeremy Fitzhardinge
2008-01-24 23:44                                         ` H. Peter Anvin
2008-01-24 23:51                                           ` Jeremy Fitzhardinge
2008-01-25  0:02                                             ` H. Peter Anvin
2008-01-25  0:11                                               ` Jeremy Fitzhardinge
2008-01-25  0:15                                                 ` H. Peter Anvin
2008-01-25  0:31                                                   ` Jeremy Fitzhardinge
2008-01-25  0:37                                                     ` H. Peter Anvin
2008-01-25  2:56                                                       ` Eric W. Biederman
2008-01-25  4:41                                                         ` Jeremy Fitzhardinge
2008-01-25 11:07                                                           ` Eric W. Biederman
2008-01-24 23:51                                         ` H. Peter Anvin
2008-01-25  0:20                                           ` Pavel Machek
2008-01-25  0:27                                             ` H. Peter Anvin
2008-01-25  0:46                                               ` Rafael J. Wysocki
2008-01-25  1:08                                                 ` H. Peter Anvin
2008-01-25  2:16                                               ` Eric W. Biederman
2008-01-25  2:25                                                 ` H. Peter Anvin
2008-01-25  7:49                                               ` Pavel Machek
2008-01-25 22:02                                                 ` Rafael J. Wysocki
2008-01-25 22:11                                                   ` Pavel Machek
2008-01-28 15:00                                                   ` Ingo Molnar
2008-01-28 15:25                                                     ` Rafael J. Wysocki
2008-01-28 19:40                                                       ` Pavel Machek
2008-01-28 19:51                                                         ` H. Peter Anvin
2008-01-28 20:03                                                           ` Jeremy Fitzhardinge
2008-01-28 20:06                                                             ` H. Peter Anvin
2008-01-28 20:28                                                               ` Rafael J. Wysocki
2008-01-28 20:26                                                         ` Rafael J. Wysocki
2008-01-28 20:31                                                           ` H. Peter Anvin
2008-01-28 20:59                                                             ` Rafael J. Wysocki
2008-01-28 20:44                                                           ` Jeremy Fitzhardinge
2008-01-28 20:50                                                             ` Rafael J. Wysocki
2008-01-28 21:28                                                               ` H. Peter Anvin
2008-01-28 22:02                                                                 ` Rafael J. Wysocki
2008-01-28 16:12                                                     ` Ingo Molnar
2008-01-28 17:02                                                       ` Rafael J. Wysocki
2008-02-01 13:51                                                         ` Ingo Molnar
2008-02-01 14:28                                                           ` Rafael J. Wysocki
2008-02-01 14:54                                                             ` Ingo Molnar
2008-02-01 22:55                                                               ` Len Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1201035611.16972.61.camel@brick \
    --to=harvey.harrison@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=hpa@zytor.com \
    --cc=ijc@hellion.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.penttila@kolumbus.fi \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.