[PATCH] pop previous section in alternative.c

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: LKML <linux-kernel@...>
Cc: Ingo Molnar <mingo@...>, Peter Zijlstra <peterz@...>, Linus Torvalds <torvalds@...>, <akpm@...>, Rusty Russell <rusty@...>, Glauber de Oliveira Costa <gcosta@...>, Jan Beulich <jbeulich@...>, Andi Kleen <ak@...>, Thomas Gleixner <tglx@...>
Date: Wednesday, April 9, 2008 - 7:04 pm

gcc expects all toplevel assembly to return to the original section type.
The code in alteranative.c does not do this. This caused some strange bugs
in sched-devel where code would end up in the .rodata section and when
the kernel sets the NX bit on all .rodata, the kernel would crash when
executing this code.

This patch adds a .previous marker to return the code back to the
original section.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 arch/x86/kernel/alternative.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Index: linux-compile.git/arch/x86/kernel/alternative.c
===================================================================
--- linux-compile.git.orig/arch/x86/kernel/alternative.c	2008-04-09 18:55:28.000000000 -0400
+++ linux-compile.git/arch/x86/kernel/alternative.c	2008-04-09 18:55:49.000000000 -0400
@@ -65,7 +65,8 @@ __setup("noreplace-paravirt", setup_nore
    get them easily into strings. */
 asm("\t.section .rodata, \"a\"\nintelnops: "
 	GENERIC_NOP1 GENERIC_NOP2 GENERIC_NOP3 GENERIC_NOP4 GENERIC_NOP5 GENERIC_NOP6
-	GENERIC_NOP7 GENERIC_NOP8);
+	GENERIC_NOP7 GENERIC_NOP8
+    "\t.previous");
 extern const unsigned char intelnops[];
 static const unsigned char *const intel_nops[ASM_NOP_MAX+1] = {
 	NULL,
@@ -83,7 +84,8 @@ static const unsigned char *const intel_
 #ifdef K8_NOP1
 asm("\t.section .rodata, \"a\"\nk8nops: "
 	K8_NOP1 K8_NOP2 K8_NOP3 K8_NOP4 K8_NOP5 K8_NOP6
-	K8_NOP7 K8_NOP8);
+	K8_NOP7 K8_NOP8
+    "\t.previous");
 extern const unsigned char k8nops[];
 static const unsigned char *const k8_nops[ASM_NOP_MAX+1] = {
 	NULL,
@@ -101,7 +103,8 @@ static const unsigned char *const k8_nop
 #ifdef K7_NOP1
 asm("\t.section .rodata, \"a\"\nk7nops: "
 	K7_NOP1 K7_NOP2 K7_NOP3 K7_NOP4 K7_NOP5 K7_NOP6
-	K7_NOP7 K7_NOP8);
+	K7_NOP7 K7_NOP8
+    "\t.previous");
 extern const unsigned char k7nops[];
 static const unsigned char *const k7_nops[ASM_NOP_MAX+1] = {
 	NULL,
@@ -119,7 +122,8 @@ static const unsigned char *const k7_nop
 #ifdef P6_NOP1
 asm("\t.section .rodata, \"a\"\np6nops: "
 	P6_NOP1 P6_NOP2 P6_NOP3 P6_NOP4 P6_NOP5 P6_NOP6
-	P6_NOP7 P6_NOP8);
+	P6_NOP7 P6_NOP8
+    "\t.previous");
 extern const unsigned char p6nops[];
 static const unsigned char *const p6_nops[ASM_NOP_MAX+1] = {
 	NULL,

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

Messages in current thread:
[PATCH] pop previous section in alternative.c, Steven Rostedt, (Wed Apr 9, 7:04 pm)
Re: [PATCH] pop previous section in alternative.c, Steven Rostedt, (Wed Apr 9, 7:51 pm)
Re: [PATCH] pop previous section in alternative.c, Ingo Molnar, (Thu Apr 10, 3:00 am)
Re: [PATCH] pop previous section in alternative.c, H. Peter Anvin, (Wed Apr 9, 8:20 pm)
Re: [PATCH] pop previous section in alternative.c, Andi Kleen, (Thu Apr 10, 4:47 am)
Re: [PATCH] pop previous section in alternative.c, Andy Whitcroft, (Thu Apr 10, 5:46 am)
Re: [PATCH] pop previous section in alternative.c, Steven Rostedt, (Thu Apr 10, 10:11 am)
Re: [PATCH] pop previous section in alternative.c, Andi Kleen, (Thu Apr 10, 10:41 am)
Re: [PATCH] pop previous section in alternative.c, Linus Torvalds, (Thu Apr 10, 10:46 am)
Re: [PATCH] pop previous section in alternative.c, H. Peter Anvin, (Thu Apr 10, 12:10 pm)
Re: [PATCH] pop previous section in alternative.c, Andi Kleen, (Thu Apr 10, 11:05 am)
Re: [PATCH] pop previous section in alternative.c, Maciej W. Rozycki, (Sun Apr 13, 11:27 am)
Re: [PATCH] pop previous section in alternative.c, Linus Torvalds, (Thu Apr 10, 11:18 am)
Re: [PATCH] pop previous section in alternative.c, H. Peter Anvin, (Thu Apr 10, 12:07 pm)
Re: [PATCH] pop previous section in alternative.c, Steven Rostedt, (Thu Apr 10, 12:20 pm)
Re: [PATCH] pop previous section in alternative.c, H. Peter Anvin, (Thu Apr 10, 1:07 pm)
Re: [PATCH] pop previous section in alternative.c, Linus Torvalds, (Thu Apr 10, 1:36 pm)
Re: [PATCH] pop previous section in alternative.c, H. Peter Anvin, (Thu Apr 10, 1:52 pm)
Re: [PATCH] pop previous section in alternative.c, Andrew Pinski, (Thu Apr 10, 1:32 pm)
Re: [PATCH] pop previous section in alternative.c, H. Peter Anvin, (Thu Apr 10, 1:53 pm)
Re: [PATCH] pop previous section in alternative.c, Steven Rostedt, (Thu Apr 10, 10:55 am)
Re: [PATCH] pop previous section in alternative.c, Sam Ravnborg, (Thu Apr 10, 2:40 pm)
Re: [PATCH] pop previous section in alternative.c, Steven Rostedt, (Thu Apr 10, 10:43 am)