From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
Andrew Morton <akpm@linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>, stable <stable@vger.kernel.org>
Subject: Re: [RFC][PATCH] x86_32: Return actual stack when requesting sp from regs
Date: Wed, 18 Jul 2012 20:41:03 +0900 [thread overview]
Message-ID: <5006A0CF.5020003@hitachi.com> (raw)
In-Reply-To: <1342208654.30075.22.camel@gandalf.stny.rr.com>
(2012/07/14 4:44), Steven Rostedt wrote:
>
> As x86_32 traps do not save sp when taken in kernel mode, we need to
> accommodate the sp when requesting to get the register.
>
> This affects kprobes.
>
> Before:
>
> # echo 'p:ftrace sys_read+4 s=%sp' > /debug/tracing/kprobe_events
> # echo 1 > /debug/tracing/events/kprobes/enable
> # cat trace
> sshd-1345 [000] d... 489.117168: ftrace: (sys_read+0x4/0x70) s=b7e96768
> sshd-1345 [000] d... 489.117191: ftrace: (sys_read+0x4/0x70) s=b7e96768
> cat-1447 [000] d... 489.117392: ftrace: (sys_read+0x4/0x70) s=5a7
> cat-1447 [001] d... 489.118023: ftrace: (sys_read+0x4/0x70) s=b77ad05f
> less-1448 [000] d... 489.118079: ftrace: (sys_read+0x4/0x70) s=b7762e06
> less-1448 [000] d... 489.118117: ftrace: (sys_read+0x4/0x70) s=b7764970
>
> After:
> sshd-1352 [000] d... 362.348016: ftrace: (sys_read+0x4/0x70) s=f3febfa8
> sshd-1352 [000] d... 362.348048: ftrace: (sys_read+0x4/0x70) s=f3febfa8
> bash-1355 [001] d... 362.348081: ftrace: (sys_read+0x4/0x70) s=f5075fa8
> sshd-1352 [000] d... 362.348082: ftrace: (sys_read+0x4/0x70) s=f3febfa8
> sshd-1352 [000] d... 362.690950: ftrace: (sys_read+0x4/0x70) s=f3febfa8
> bash-1355 [001] d... 362.691033: ftrace: (sys_read+0x4/0x70) s=f5075fa8
>
> [ I wonder if this should also go to stable? ]
>
This obviously makes tracing output better on i386. Original %sp
gives nothing (or just misleading)...
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
NOTE: if someone needs to get kernel stack address from regs,
I recommend him to use kernel_stack_pointer() directly.
Thank you,
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
>
> Index: linux-trace.git/arch/x86/include/asm/ptrace.h
> ===================================================================
> --- linux-trace.git.orig/arch/x86/include/asm/ptrace.h
> +++ linux-trace.git/arch/x86/include/asm/ptrace.h
> @@ -246,6 +246,15 @@ static inline unsigned long regs_get_reg
> {
> if (unlikely(offset > MAX_REG_OFFSET))
> return 0;
> +#ifdef CONFIG_X86_32
> + /*
> + * Traps from the kernel do not save sp and ss.
> + * Use the helper function to retrieve sp.
> + */
> + if (offset == offsetof(struct pt_regs, sp) &&
> + regs->cs == __KERNEL_CS)
> + return kernel_stack_pointer(regs);
> +#endif
> return *(unsigned long *)((unsigned long)regs + offset);
> }
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
next prev parent reply other threads:[~2012-07-18 11:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-13 19:44 Steven Rostedt
2012-07-18 11:41 ` Masami Hiramatsu [this message]
2012-12-09 11:32 ` [tip:x86/asm] " tip-bot for Steven Rostedt
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=5006A0CF.5020003@hitachi.com \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=stable@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
Powered by JetHome