The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ftrace: Make ftrace_test_p6nop disassembler-friendly
@ 2008-10-10  2:19 Anders Kaseorg
  2008-10-10  8:54 ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Anders Kaseorg @ 2008-10-10  2:19 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Steven Rostedt, linux-kernel

Commit 4c3dc21b136f8cb4b72afee16c3ba7e961656c0b in tip introduced the
5-byte NOP ftrace_test_p6nop:
  jmp . + 5
  .byte 0x00, 0x00, 0x00
This is not friendly to disassemblers because an odd number of 0x00s
ends in the middle of an instruction boundary.  This changes the 0x00s
to 1-byte NOPs (0x90).

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 222507e..d073d98 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -132,7 +132,9 @@ int __init ftrace_dyn_arch_init(void *data)
 		".section .text, \"ax\"\n"
 		"ftrace_test_jmp:"
 		"jmp ftrace_test_p6nop\n"
-		".byte 0x00,0x00,0x00\n"  /* 2 byte jmp + 3 bytes */
+		"nop\n"
+		"nop\n"
+		"nop\n"  /* 2 byte jmp + 3 bytes */
 		"ftrace_test_p6nop:"
 		P6_NOP5
 		"jmp 1f\n"
@@ -161,7 +163,7 @@ int __init ftrace_dyn_arch_init(void *data)
 		ftrace_nop = (unsigned long *)ftrace_test_nop5;
 		break;
 	case 2:
-		pr_info("ftrace: converting mcount calls to jmp 1f\n");
+		pr_info("ftrace: converting mcount calls to jmp . + 5\n");
 		ftrace_nop = (unsigned long *)ftrace_test_jmp;
 		break;
 	}

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

* Re: [PATCH] ftrace: Make ftrace_test_p6nop disassembler-friendly
  2008-10-10  2:19 [PATCH] ftrace: Make ftrace_test_p6nop disassembler-friendly Anders Kaseorg
@ 2008-10-10  8:54 ` Ingo Molnar
  2008-10-10 13:27   ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2008-10-10  8:54 UTC (permalink / raw)
  To: Anders Kaseorg; +Cc: Steven Rostedt, linux-kernel, H. Peter Anvin


* Anders Kaseorg <andersk@MIT.EDU> wrote:

> Commit 4c3dc21b136f8cb4b72afee16c3ba7e961656c0b in tip introduced the
> 5-byte NOP ftrace_test_p6nop:
>   jmp . + 5
>   .byte 0x00, 0x00, 0x00
> This is not friendly to disassemblers because an odd number of 0x00s
> ends in the middle of an instruction boundary.  This changes the 0x00s
> to 1-byte NOPs (0x90).
> 
> Signed-off-by: Anders Kaseorg <andersk@mit.edu>

applied to tip/tracing/ftrace, good spotting Anders!

Steve, any objections?

	Ingo

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

* Re: [PATCH] ftrace: Make ftrace_test_p6nop disassembler-friendly
  2008-10-10  8:54 ` Ingo Molnar
@ 2008-10-10 13:27   ` Steven Rostedt
  2008-10-10 16:12     ` H. Peter Anvin
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2008-10-10 13:27 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Anders Kaseorg, linux-kernel, H. Peter Anvin


On Fri, 10 Oct 2008, Ingo Molnar wrote:

> 
> * Anders Kaseorg <andersk@MIT.EDU> wrote:
> 
> > Commit 4c3dc21b136f8cb4b72afee16c3ba7e961656c0b in tip introduced the
> > 5-byte NOP ftrace_test_p6nop:
> >   jmp . + 5
> >   .byte 0x00, 0x00, 0x00
> > This is not friendly to disassemblers because an odd number of 0x00s
> > ends in the middle of an instruction boundary.  This changes the 0x00s
> > to 1-byte NOPs (0x90).
> > 
> > Signed-off-by: Anders Kaseorg <andersk@mit.edu>
> 
> applied to tip/tracing/ftrace, good spotting Anders!
> 
> Steve, any objections?

Nope, it's fine with me.

Acked-by: Steven Rostedt <srostedt@redhat.com>


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

* Re: [PATCH] ftrace: Make ftrace_test_p6nop disassembler-friendly
  2008-10-10 13:27   ` Steven Rostedt
@ 2008-10-10 16:12     ` H. Peter Anvin
  2008-10-10 16:56       ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: H. Peter Anvin @ 2008-10-10 16:12 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ingo Molnar, Anders Kaseorg, linux-kernel

Steven Rostedt wrote:
> On Fri, 10 Oct 2008, Ingo Molnar wrote:
> 
>> * Anders Kaseorg <andersk@MIT.EDU> wrote:
>>
>>> Commit 4c3dc21b136f8cb4b72afee16c3ba7e961656c0b in tip introduced the
>>> 5-byte NOP ftrace_test_p6nop:
>>>   jmp . + 5
>>>   .byte 0x00, 0x00, 0x00
>>> This is not friendly to disassemblers because an odd number of 0x00s
>>> ends in the middle of an instruction boundary.  This changes the 0x00s
>>> to 1-byte NOPs (0x90).
>>>
>>> Signed-off-by: Anders Kaseorg <andersk@mit.edu>
>> applied to tip/tracing/ftrace, good spotting Anders!
>>
>> Steve, any objections?
> 
> Nope, it's fine with me.
> 
> Acked-by: Steven Rostedt <srostedt@redhat.com>
> 

The (semi-)amusing thing is that it should never, ever, get there.
66 66 66 66 90 is used over this, which should always work.

	-hpa

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

* Re: [PATCH] ftrace: Make ftrace_test_p6nop disassembler-friendly
  2008-10-10 16:12     ` H. Peter Anvin
@ 2008-10-10 16:56       ` Steven Rostedt
  0 siblings, 0 replies; 5+ messages in thread
From: Steven Rostedt @ 2008-10-10 16:56 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Ingo Molnar, Anders Kaseorg, linux-kernel


On Fri, 10 Oct 2008, H. Peter Anvin wrote:
> 
> The (semi-)amusing thing is that it should never, ever, get there.
> 66 66 66 66 90 is used over this, which should always work.

Yeah, that was me being overly paranoid ;-) Which is not always a bad 
thing.

-- Steve


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

end of thread, other threads:[~2008-10-10 16:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-10  2:19 [PATCH] ftrace: Make ftrace_test_p6nop disassembler-friendly Anders Kaseorg
2008-10-10  8:54 ` Ingo Molnar
2008-10-10 13:27   ` Steven Rostedt
2008-10-10 16:12     ` H. Peter Anvin
2008-10-10 16:56       ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox