linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: Configure NX support earlier in setup_arch
@ 2014-07-03  1:47 Stuart Hayes
  2014-07-08 22:34 ` Stuart Hayes
  0 siblings, 1 reply; 12+ messages in thread
From: Stuart Hayes @ 2014-07-03  1:47 UTC (permalink / raw)
  To: tglx, mingo, hpa, x86; +Cc: linux-kernel

A page fault can crash the kernel very early if an NX bit is set in a
page table entry, if the CPU doesn't support NX (or if NX support is
disabled in the CPU).  Move the call to x86_configure_nx() earlier
than parse_setup_data(), since that calls early_memremap().

Signed-off-by: Stuart Hayes <stuart.w.hayes@gmail.com>
---

--- linux-3.16-rc3/arch/x86/kernel/setup.c.orig	2014-07-02 12:14:50.196308719 -0400
+++ linux-3.16-rc3/arch/x86/kernel/setup.c	2014-07-02 12:11:11.240301228 -0400
@@ -940,6 +940,17 @@ void __init setup_arch(char **cmdline_p)
 
 	iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
 	setup_memory_map();
+
+	/*
+	 * x86_configure_nx() is called before parse_setup_data() to detect
+	 * whether hardware doesn't support NX (so that parse_setup_data()
+	 * can safely call early_memremap() without setting the XD bit in
+	 * the PTE, which can cause an unrecoverable page fault). It may
+	 * then be called again from within noexec_setup() during parsing
+	 * early parameters to honor the respective command line option.
+	 */
+	x86_configure_nx();
+
 	parse_setup_data();
 
 	copy_edd();
@@ -974,15 +985,6 @@ void __init setup_arch(char **cmdline_p)
 	strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
 	*cmdline_p = command_line;
 
-	/*
-	 * x86_configure_nx() is called before parse_early_param() to detect
-	 * whether hardware doesn't support NX (so that the early EHCI debug
-	 * console setup can safely call set_fixmap()). It may then be called
-	 * again from within noexec_setup() during parsing early parameters
-	 * to honor the respective command line option.
-	 */
-	x86_configure_nx();
-
 	parse_early_param();
 
 	x86_report_nx();

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-11-13 15:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-03  1:47 [PATCH] x86: Configure NX support earlier in setup_arch Stuart Hayes
2014-07-08 22:34 ` Stuart Hayes
2014-07-08 22:38   ` H. Peter Anvin
2014-07-10  0:56     ` Stuart Hayes
2014-07-14 17:22       ` Borislav Petkov
2014-07-14 17:28         ` H. Peter Anvin
2014-07-14 17:35           ` Borislav Petkov
2014-11-13  6:39         ` B_B_Singh
2014-11-13 12:30           ` Borislav Petkov
2014-11-13 13:40             ` B_B_Singh
2014-11-13 15:48             ` Thomas Gleixner
2014-11-13 12:54           ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).