| To: | Al Cooper <alcooperx@gmail.com> |
|---|---|
| Subject: | Re: [PATCH V2] mips: function tracer: Fix broken function tracing |
| From: | Geert Uytterhoeven <geert@linux-m68k.org> |
| Date: | Thu, 17 Jan 2013 07:27:19 +0100 |
| Cc: | rostedt@goodmis.org, ddaney.cavm@gmail.com, ralf@linux-mips.org, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org |
| Dkim-signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=N1qNzm1W67FE8FoAgiJ4unQxDRFrLnQRjSEWoMXwkso=; b=Zs6AIwouBwJtCOrIs9SNj+sF5WAPdpcIqEnddDAofJUlO75YMf9P1uQc45hpMkE4l5 7Nnem/Hwja7Yi9f99qxo3tjWCB2XFf7rK+TdjrnwJUHhuVDxShkK17Zc9AXoWMLmKXQb 6TQBT8JZnzVa6H6Zk4h56Fsjr/zv0fhkGYvxP/laEvpVC+zHNKwYAx5XKmG8QVJC3351 74QHDnQx/5ToQ5lWiDUv1nxhnYie/NIDkM2ilwJS8E5iufv+mN60MA8Ayjv3+lCGL1we hRfPnaXDJcrf984V0abEyJyM+i3+9QMTpW5HSCIYCVU01z+UfK4cWoSAhlGe9mSrQJU4 IBEg== |
| In-reply-to: | <1358379808-16449-1-git-send-email-alcooperx@gmail.com> |
| List-archive: | <http://www.linux-mips.org/archives/linux-mips/> |
| List-help: | <mailto:ecartis@linux-mips.org?Subject=help> |
| List-id: | linux-mips <linux-mips.eddie.linux-mips.org> |
| List-owner: | <mailto:ralf@linux-mips.org> |
| List-post: | <mailto:linux-mips@linux-mips.org> |
| List-software: | Ecartis version 1.0.0 |
| List-subscribe: | <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips> |
| List-unsubscribe: | <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips> |
| References: | <1358379808-16449-1-git-send-email-alcooperx@gmail.com> |
| Sender: | linux-mips-bounce@linux-mips.org |
On Thu, Jan 17, 2013 at 12:43 AM, Al Cooper <alcooperx@gmail.com> wrote:
> Part of the sequence is "addiu sp,sp,-8" in the delay slot after every
> call to the trace routine "_mcount" (some legacy thing where 2 arguments
> used to be pushed on the stack). The _mcount routine is expected to
> adjust the sp by +8 before returning.
So when not disabled, the original jalr and addiu will be there, so _mcount has
to adjust sp.
> The problem is that when tracing is disabled for a function, the
> "jalr _mcount" instruction is replaced with a nop, but the
> "addiu sp,sp,-8" is still executed and the stack pointer is left
> trashed. When frame pointers are enabled the problem is masked
> because any access to the stack is done through the frame
> pointer and the stack pointer is restored from the frame pointer when
> the function returns.
>
> This patch writes two nops starting at the address of the "jalr _mcount"
> instruction whenever tracing is disabled. This means that the
> "addiu sp,sp.-8" will be converted to a nop along with the "jalr".
When disabled, there will be two nops.
> This is SMP safe because the first time this happens is during
> ftrace_init() which is before any other processor has been started.
> Subsequent calls to enable/disable tracing when other CPUs ARE running
> will still be safe because the enable will only change the first nop
> to a "jalr" and the disable, while writing 2 nops, will only be changing
When re-enabled, there will be a jalr and a nop, which differs from the initial
case, so _mcount doesn't have to adjust sp?
> @@ -69,7 +68,7 @@ NESTED(ftrace_caller, PT_SIZE, ra)
> .globl _mcount
> _mcount:
> b ftrace_stub
> - nop
> + addiu sp,sp,8
> lw t1, function_trace_stop
> bnez t1, ftrace_stub
> nop
But _mcount will always adjust the stack pointer?
What am I missing?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCH V2] mips: function tracer: Fix broken function tracing, Al Cooper |
|---|---|
| Next by Date: | RE: [PATCH] mips: bcm47xx: select GPIOLIB for BCMA on bcm47xx platform, Arend Van Spriel |
| Previous by Thread: | [PATCH V2] mips: function tracer: Fix broken function tracing, Al Cooper |
| Next by Thread: | Re: [PATCH V2] mips: function tracer: Fix broken function tracing, Alan Cooper |
| Indexes: | [Date] [Thread] [Top] [All Lists] |