public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Andrew Morton <akpm@osdl.org>, Andi Kleen <ak@suse.de>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH 2.6.18-rc3-mm2] KPROBE_ENTRY ends up putting code into .fixup
Date: Tue, 08 Aug 2006 18:18:38 -0700	[thread overview]
Message-ID: <44D937EE.1020404@goop.org> (raw)

KPROBE_ENTRY does a .section .kprobes.text, and expects its users to
do a .previous at the end of the function.

Unfortunately, if any code within the function switches sections, for
example .fixup, then the .previous ends up putting all subsequent code
into .fixup.  Worse, any subsequent .fixup code gets intermingled with
the code its supposed to be fixing (which is also in .fixup).  It's
surprising this didn't cause more havok.

The fix is to use .pushsection/.popsection, so this stuff nests
properly.  A further cleanup would be to get rid of all
.section/.previous pairs, since they're inherently fragile.

Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>

diff -r 30f9dfcdff81 arch/i386/kernel/entry.S
--- a/arch/i386/kernel/entry.S	Mon Aug 07 16:08:33 2006 -0700
+++ b/arch/i386/kernel/entry.S	Tue Aug 08 17:40:03 2006 -0700
@@ -646,7 +646,7 @@ error_code:
 	call *%edi
 	jmp ret_from_exception
 	CFI_ENDPROC
-.previous
+.popsection
 
 ENTRY(coprocessor_error)
 	RING0_INT_FRAME
@@ -722,7 +722,7 @@ debug_stack_correct:
 	call do_debug
 	jmp ret_from_exception
 	CFI_ENDPROC
-.previous
+.popsection
 
 /*
  * NMI is doubly nasty. It can happen _while_ we're handling
@@ -819,7 +819,7 @@ KPROBE_ENTRY(int3)
 	call do_int3
 	jmp ret_from_exception
 	CFI_ENDPROC
-.previous
+.popsection
 
 ENTRY(overflow)
 	RING0_INT_FRAME
@@ -884,7 +884,7 @@ KPROBE_ENTRY(general_protection)
 	CFI_ADJUST_CFA_OFFSET 4
 	jmp error_code
 	CFI_ENDPROC
-.previous
+.popsection
 
 ENTRY(alignment_check)
 	RING0_EC_FRAME
diff -r 30f9dfcdff81 arch/x86_64/kernel/entry.S
--- a/arch/x86_64/kernel/entry.S	Mon Aug 07 16:08:33 2006 -0700
+++ b/arch/x86_64/kernel/entry.S	Tue Aug 08 17:41:13 2006 -0700
@@ -904,7 +904,7 @@ error_kernelspace:
         je   error_swapgs
 	jmp  error_sti
 END(error_entry)
-	.previous
+	.popsection
 	
        /* Reload gs selector with exception handling */
        /* edi:  new selector */ 
@@ -1024,7 +1024,7 @@ KPROBE_ENTRY(page_fault)
 KPROBE_ENTRY(page_fault)
 	errorentry do_page_fault
 END(page_fault)
-	.previous
+	.popsection
 
 ENTRY(coprocessor_error)
 	zeroentry do_coprocessor_error
@@ -1046,7 +1046,7 @@ KPROBE_ENTRY(debug)
 	paranoidentry do_debug, DEBUG_STACK
 	paranoidexit
 END(debug)
-	.previous
+	.popsection
 
 	/* runs on exception stack */	
 KPROBE_ENTRY(nmi)
@@ -1061,7 +1061,7 @@ KPROBE_ENTRY(nmi)
  	CFI_ENDPROC
 #endif
 END(nmi)
-	.previous
+	.popsection
 
 KPROBE_ENTRY(int3)
  	INTR_FRAME
@@ -1071,7 +1071,7 @@ KPROBE_ENTRY(int3)
  	jmp paranoid_exit1
  	CFI_ENDPROC
 END(int3)
-	.previous
+	.popsection
 
 ENTRY(overflow)
 	zeroentry do_overflow
@@ -1120,7 +1120,7 @@ KPROBE_ENTRY(general_protection)
 KPROBE_ENTRY(general_protection)
 	errorentry do_general_protection
 END(general_protection)
-	.previous
+	.popsection
 
 ENTRY(alignment_check)
 	errorentry do_alignment_check
diff -r 30f9dfcdff81 include/linux/linkage.h
--- a/include/linux/linkage.h	Mon Aug 07 16:08:33 2006 -0700
+++ b/include/linux/linkage.h	Tue Aug 08 17:41:23 2006 -0700
@@ -35,7 +35,7 @@
 #endif
 
 #define KPROBE_ENTRY(name) \
-  .section .kprobes.text, "ax"; \
+  .pushsection .kprobes.text, "ax"; \
   ENTRY(name)
 
 #ifndef END


             reply	other threads:[~2006-08-09  1:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-09  1:18 Jeremy Fitzhardinge [this message]
2006-08-09  2:13 ` [PATCH 2.6.18-rc3-mm2] KPROBE_ENTRY ends up putting code into .fixup Andi Kleen

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=44D937EE.1020404@goop.org \
    --to=jeremy@goop.org \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox