All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: remove the confusing entry in call trace
@ 2008-11-23 14:47 jia zhang
  2008-11-23 17:30 ` Alexander van Heukelum
  0 siblings, 1 reply; 3+ messages in thread
From: jia zhang @ 2008-11-23 14:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, tglx, hpa


avoid the confusion in call trace because of the lack of padding at the tail of function.

Signed-off-by: jia zhang <jia.zhang2008@gmail.com>
---
When do_exit get call, the return address behind call instruction is pushed into stack. If something get wrong in do_exit, for x86_64, the entry "kernel_execve +0x00/0xXX" rather than "child_rip +0xYY/0xZZ" is remained in call trace. It looks confused.

 b/arch/x86/kernel/entry_32.S |    1 +
 b/arch/x86/kernel/entry_64.S |    1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 28b597e..3290819 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1051,6 +1051,7 @@ ENTRY(kernel_thread_helper)
 	push %eax
 	CFI_ADJUST_CFA_OFFSET 4
 	call do_exit
+	nop			# padding for call trace
 	CFI_ENDPROC
 ENDPROC(kernel_thread_helper)
 
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index b86f332..6f677a6 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1170,6 +1170,7 @@ child_rip:
 	# exit
 	mov %eax, %edi
 	call do_exit
+	nop			# padding for call trace
 	CFI_ENDPROC
 ENDPROC(child_rip)
 

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

* Re: [PATCH] x86: remove the confusing entry in call trace
  2008-11-23 14:47 [PATCH] x86: remove the confusing entry in call trace jia zhang
@ 2008-11-23 17:30 ` Alexander van Heukelum
  2008-11-23 19:04   ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander van Heukelum @ 2008-11-23 17:30 UTC (permalink / raw)
  To: jia zhang; +Cc: linux-kernel, Ingo Molnar, tglx, hpa

On Sun, Nov 23, 2008 at 10:47:10PM +0800, jia zhang wrote:
> 
> avoid the confusion in call trace because of the lack of padding at the tail of
> function.
> 
> Signed-off-by: jia zhang <jia.zhang2008@gmail.com> --- When do_exit get call,
> the return address behind call instruction is pushed into stack. If something
> get wrong in do_exit, for x86_64, the entry "kernel_execve +0x00/0xXX" rather
> than "child_rip +0xYY/0xZZ" is remained in call trace. It looks confused.

It's valuable to know from where do_exit is called, so that's the
only reason why using "call" is important. Otherwise it could just
be changed to a jmp as do_exit does not return. It's maybe a bit
ugly to add the padding, but it does give better traces. Maybe
a 'ret', 'int3', or 'ud2' would be slightly less offensive?

Anyhow, I don't have a problem with the added padding, so:

Acked-by: Alexander van Heukelum <heukelum@fastmail.fm>


>  b/arch/x86/kernel/entry_32.S |    1 +
>  b/arch/x86/kernel/entry_64.S |    1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
> index 28b597e..3290819 100644
> --- a/arch/x86/kernel/entry_32.S
> +++ b/arch/x86/kernel/entry_32.S
> @@ -1051,6 +1051,7 @@ ENTRY(kernel_thread_helper)
>  	push %eax
>  	CFI_ADJUST_CFA_OFFSET 4
>  	call do_exit
> +	nop			# padding for call trace
>  	CFI_ENDPROC
>  ENDPROC(kernel_thread_helper)
>  
> diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
> index b86f332..6f677a6 100644
> --- a/arch/x86/kernel/entry_64.S
> +++ b/arch/x86/kernel/entry_64.S
> @@ -1170,6 +1170,7 @@ child_rip:
>  	# exit
>  	mov %eax, %edi
>  	call do_exit
> +	nop			# padding for call trace
>  	CFI_ENDPROC
>  ENDPROC(child_rip)

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

* Re: [PATCH] x86: remove the confusing entry in call trace
  2008-11-23 17:30 ` Alexander van Heukelum
@ 2008-11-23 19:04   ` Ingo Molnar
  0 siblings, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2008-11-23 19:04 UTC (permalink / raw)
  To: Alexander van Heukelum; +Cc: jia zhang, linux-kernel, tglx, hpa


* Alexander van Heukelum <heukelum@mailshack.com> wrote:

> On Sun, Nov 23, 2008 at 10:47:10PM +0800, jia zhang wrote:
> > 
> > avoid the confusion in call trace because of the lack of padding at the tail of
> > function.
> > 
> > Signed-off-by: jia zhang <jia.zhang2008@gmail.com> --- When do_exit get call,
> > the return address behind call instruction is pushed into stack. If something
> > get wrong in do_exit, for x86_64, the entry "kernel_execve +0x00/0xXX" rather
> > than "child_rip +0xYY/0xZZ" is remained in call trace. It looks confused.
> 
> It's valuable to know from where do_exit is called, so that's the
> only reason why using "call" is important. Otherwise it could just
> be changed to a jmp as do_exit does not return. It's maybe a bit
> ugly to add the padding, but it does give better traces. Maybe
> a 'ret', 'int3', or 'ud2' would be slightly less offensive?
> 
> Anyhow, I don't have a problem with the added padding, so:
> 
> Acked-by: Alexander van Heukelum <heukelum@fastmail.fm>

applied to tip/x86/debug, thanks guys!

i changed it to u2d based on your suggestion - that makes it not only 
easier to understand, but also more robust, should do_exit() return. 
(which it should never in practice)

	Ingo

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

end of thread, other threads:[~2008-11-23 19:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-23 14:47 [PATCH] x86: remove the confusing entry in call trace jia zhang
2008-11-23 17:30 ` Alexander van Heukelum
2008-11-23 19:04   ` Ingo Molnar

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.