This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH -tip v5 06/10] kprobes/x86: Cleanup save/restore registers
- From: Frederic Weisbecker <fweisbec at gmail dot com>
- To: Masami Hiramatsu <mhiramat at redhat dot com>
- Cc: Ingo Molnar <mingo at elte dot hu>, Ananth N Mavinakayanahalli <ananth at in dot ibm dot com>, lkml <linux-kernel at vger dot kernel dot org>, systemtap <systemtap at sources dot redhat dot com>, DLE <dle-develop at lists dot sourceforge dot net>, Jim Keniston <jkenisto at us dot ibm dot com>, Srikar Dronamraju <srikar at linux dot vnet dot ibm dot com>, Christoph Hellwig <hch at infradead dot org>, Steven Rostedt <rostedt at goodmis dot org>, "H. Peter Anvin" <hpa at zytor dot com>, Anders Kaseorg <andersk at ksplice dot com>, Tim Abbott <tabbott at ksplice dot com>, Andi Kleen <andi at firstfloor dot org>, Jason Baron <jbaron at redhat dot com>, Mathieu Desnoyers <mathieu dot desnoyers at polymtl dot ca>
- Date: Tue, 24 Nov 2009 21:19:22 +0100
- Subject: Re: [PATCH -tip v5 06/10] kprobes/x86: Cleanup save/restore registers
- References: <20091123232115.22071.71558.stgit@dhcp-100-2-132.bos.redhat.com> <20091123232204.22071.60562.stgit@dhcp-100-2-132.bos.redhat.com> <20091124025115.GB6752@nowhere> <4B0BFE21.7000102@redhat.com>
On Tue, Nov 24, 2009 at 10:39:13AM -0500, Masami Hiramatsu wrote:
> Frederic Weisbecker wrote:
> > On Mon, Nov 23, 2009 at 06:22:04PM -0500, Masami Hiramatsu wrote:
> >> +#ifdef CONFIG_X86_64
> >> +#define SAVE_REGS_STRING \
> >> + /* Skip cs, ip, orig_ax. */ \
> >> + " subq $24, %rsp\n" \
> >> + " pushq %rdi\n" \
> >> + " pushq %rsi\n" \
> >> + " pushq %rdx\n" \
> >> + " pushq %rcx\n" \
> >> + " pushq %rax\n" \
> >> + " pushq %r8\n" \
> >> + " pushq %r9\n" \
> >> + " pushq %r10\n" \
> >> + " pushq %r11\n" \
> >> + " pushq %rbx\n" \
> >> + " pushq %rbp\n" \
> >> + " pushq %r12\n" \
> >> + " pushq %r13\n" \
> >> + " pushq %r14\n" \
> >> + " pushq %r15\n"
> >> +#define RESTORE_REGS_STRING \
> >> + " popq %r15\n" \
> >> + " popq %r14\n" \
> >> + " popq %r13\n" \
> >> + " popq %r12\n" \
> >> + " popq %rbp\n" \
> >> + " popq %rbx\n" \
> >> + " popq %r11\n" \
> >> + " popq %r10\n" \
> >> + " popq %r9\n" \
> >> + " popq %r8\n" \
> >> + " popq %rax\n" \
> >> + " popq %rcx\n" \
> >> + " popq %rdx\n" \
> >> + " popq %rsi\n" \
> >> + " popq %rdi\n" \
> >
> >
> > BTW, do you really need to push/pop every registers
> > before/after calling a probe handler?
>
> Yes, in both cases (kretprobe/optprpbe) it needs to
> emulate kprobes behavior. kprobes can be used as
> fault injection, it should pop pt_regs.
>
> > Is it possible to only save/restore the scratch ones?
>
> Hmm, what code did you mean?
Ah this chain of push/pop is there to dump a struct pt_regs for
the handler?
Sorry, I just thought it was to save the registers from the probed
function.