From: Steven Rostedt <rostedt@goodmis.org>
To: Abel Vesa <abelvesa@linux.com>
Cc: linux@armlinux.org.uk, jpoimboe@redhat.com, jeyu@redhat.com,
jikos@kernel.org, mbenes@suse.cz, pmladek@suse.com,
mingo@redhat.com, gregkh@linuxfoundation.org,
geert+renesas@glider.be, davem@davemloft.net,
akpm@linux-foundation.org, emil.l.velikov@gmail.com,
mchehab@kernel.org, linux@roeck-us.net,
ard.biesheuvel@linaro.org, jens.wiklander@linaro.org,
jean-philippe.brucker@arm.com, viro@zeniv.linux.org.uk,
stefano.stabellini@eu.citrix.com, chris.brandt@renesas.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
live-patching@vger.kernel.org
Subject: Re: [PATCH 4/7] arm: Add ftrace with regs support
Date: Tue, 6 Dec 2016 21:43:55 -0500 [thread overview]
Message-ID: <20161206214355.268d2791@grimm.local.home> (raw)
In-Reply-To: <1481043967-15602-5-git-send-email-abelvesa@linux.com>
On Tue, 6 Dec 2016 17:06:04 +0000
Abel Vesa <abelvesa@linux.com> wrote:
> This adds __ftrace_regs_caller which, unlike __ftrace_caller,
> adds register saving/restoring and livepatch handling if
> the pc register gets modified by klp_ftrace_handler.
>
> Signed-off-by: Abel Vesa <abelvesa@linux.com>
> ---
> arch/arm/kernel/entry-ftrace.S | 49
> ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49
> insertions(+)
>
> diff --git a/arch/arm/kernel/entry-ftrace.S
> b/arch/arm/kernel/entry-ftrace.S index c73c403..b6ada5c 100644
> --- a/arch/arm/kernel/entry-ftrace.S
> +++ b/arch/arm/kernel/entry-ftrace.S
> @@ -92,6 +92,46 @@
> 2: mcount_exit
> .endm
>
> +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> +
> +.macro __ftrace_regs_caller suffix
> +
> + stmdb sp!, {r0-r15}
> + mov r3, sp
> +
> + ldr r10, [sp, #60]
> +
> + mcount_get_lr r1 @ lr of instrumented
> func
> + mcount_adjust_addr r0, lr @
> instrumented function +
> + .globl ftrace_regs_call\suffix
> +ftrace_regs_call\suffix:
> + bl ftrace_stub
> +
> +#ifdef CONFIG_FUNCTION_GRAPH_TRACER
> + .globl ftrace_regs_graph_call\suffix
> +ftrace_regs_graph_call\suffix:
> + mov r0, r0
> +#endif
So basically what the below does is to undo the mcount prologue and
recall the new function as the old function is called.
> +#ifdef CONFIG_LIVEPATCH
> + ldr r0, [sp, #60]
> + cmp r0, r10
> + beq ftrace_regs_caller_end
> + ldmia sp!, {r0-r12}
> + add sp, sp, #8
> + ldmia sp!, {r11}
> + sub sp, r12, #16
> + str r11, [sp, #12]
> + ldmia sp!, {r11, r12, lr, pc}
But the above really could do with a lot of comments to explain exactly
what it is doing.
I don't condemn or condone this code. I'm just happy I don't have to
maintain it.
-- Steve
> +#endif
> +ftrace_regs_caller_end\suffix:
> + ldmia sp!, {r0-r14}
> + add sp, sp, #4
> + mov pc, lr
> +.endm
> +
> +#endif
> +
> .macro __ftrace_caller suffix
> mcount_enter
>
> @@ -212,6 +252,15 @@ UNWIND(.fnstart)
> __ftrace_caller
> UNWIND(.fnend)
> ENDPROC(ftrace_caller)
> +
> +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
> +ENTRY(ftrace_regs_caller)
> +UNWIND(.fnstart)
> + __ftrace_regs_caller
> +UNWIND(.fnend)
> +ENDPROC(ftrace_regs_caller)
> +#endif
> +
> #endif
>
> #ifdef CONFIG_FUNCTION_GRAPH_TRACER
next prev parent reply other threads:[~2016-12-07 2:44 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-06 17:06 [PATCH 0/7] arm: Add livepatch support Abel Vesa
2016-12-06 17:06 ` [PATCH 1/7] arm: Add livepatch arch specific code Abel Vesa
2017-01-16 16:47 ` Miroslav Benes
2017-01-17 0:22 ` Jessica Yu
2017-01-17 2:27 ` Jessica Yu
2017-01-17 13:53 ` Miroslav Benes
2016-12-06 17:06 ` [PATCH 2/7] arm: ftrace: Add call modify mechanism Abel Vesa
2016-12-07 10:37 ` kbuild test robot
2016-12-06 17:06 ` [PATCH 3/7] arm: module: Add apply_relocate_add Abel Vesa
2016-12-07 2:08 ` kbuild test robot
2017-01-17 4:49 ` Jessica Yu
2017-01-18 10:37 ` Miroslav Benes
2016-12-06 17:06 ` [PATCH 4/7] arm: Add ftrace with regs support Abel Vesa
2016-12-07 2:43 ` Steven Rostedt [this message]
2016-12-07 10:57 ` Russell King - ARM Linux
2016-12-07 11:58 ` Robin Murphy
2016-12-07 12:10 ` Abel Vesa
2016-12-06 17:06 ` [PATCH 5/7] arm: ftrace: Add ARCH_SUPPORTS_FTRACE_OPS for ftrace with regs Abel Vesa
2016-12-06 17:06 ` [PATCH 6/7] arm: Add livepatch to build if CONFIG_LIVEPATCH Abel Vesa
2016-12-07 15:05 ` Petr Mladek
2016-12-07 16:11 ` Abel Vesa
2017-01-18 12:36 ` Miroslav Benes
2016-12-06 17:06 ` [PATCH 7/7] arm: Add livepatch necessary arch selects into Kconfig Abel Vesa
2016-12-07 2:45 ` Steven Rostedt
2016-12-07 6:48 ` kbuild test robot
2017-01-18 12:40 ` Miroslav Benes
2017-01-18 13:35 ` Russell King - ARM Linux
2016-12-07 1:38 ` [PATCH 0/7] arm: Add livepatch support zhouchengming
2016-12-07 11:39 ` Abel Vesa
2016-12-07 15:19 ` Petr Mladek
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=20161206214355.268d2791@grimm.local.home \
--to=rostedt@goodmis.org \
--cc=abelvesa@linux.com \
--cc=akpm@linux-foundation.org \
--cc=ard.biesheuvel@linaro.org \
--cc=chris.brandt@renesas.com \
--cc=davem@davemloft.net \
--cc=emil.l.velikov@gmail.com \
--cc=geert+renesas@glider.be \
--cc=gregkh@linuxfoundation.org \
--cc=jean-philippe.brucker@arm.com \
--cc=jens.wiklander@linaro.org \
--cc=jeyu@redhat.com \
--cc=jikos@kernel.org \
--cc=jpoimboe@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@roeck-us.net \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mchehab@kernel.org \
--cc=mingo@redhat.com \
--cc=pmladek@suse.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=viro@zeniv.linux.org.uk \
/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