From: rostedt@goodmis.org (Steven Rostedt)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 09/10] ARM: ftrace: add Thumb-2 support to dynamic ftrace
Date: Tue, 23 Feb 2010 08:35:00 -0500 [thread overview]
Message-ID: <1266932100.19540.12.camel@frodo> (raw)
In-Reply-To: <1266090518-31120-10-git-send-email-rabin@rab.in>
On Sun, 2010-02-14 at 01:18 +0530, Rabin Vincent wrote:
> Handle the different nop and call instructions for Thumb-2. Also, we
> need to adjust the recorded mcount_loc addresses because they have the
> lsb set.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Rabin Vincent <rabin@rab.in>
> ---
> arch/arm/include/asm/ftrace.h | 4 ++++
> arch/arm/kernel/ftrace.c | 33 +++++++++++++++++++++++++++++++++
> scripts/recordmcount.pl | 2 +-
> 3 files changed, 38 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h
> index 4a56a2e..0845f2d 100644
> --- a/arch/arm/include/asm/ftrace.h
> +++ b/arch/arm/include/asm/ftrace.h
> @@ -18,7 +18,11 @@ struct dyn_arch_ftrace {
>
> static inline unsigned long ftrace_call_adjust(unsigned long addr)
> {
> +#ifdef CONFIG_THUMB2_KERNEL
> + return addr & ~1;
Would it be safe to do that for all arm archs? Instead of adding a
config option around it. Or do some arm archs need the lsb set.
I'm just saying a comment here would look better than #ifdef #else.
> +#else
> return addr;
> +#endif
> }
>
> extern void ftrace_caller_old(void);
> diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
> index f09014c..971ac8c 100644
> --- a/arch/arm/kernel/ftrace.c
> +++ b/arch/arm/kernel/ftrace.c
> @@ -18,7 +18,11 @@
> #include <asm/cacheflush.h>
> #include <asm/ftrace.h>
>
> +#ifdef CONFIG_THUMB2_KERNEL
> +#define NOP 0xeb04f85d /* pop.w {lr} */
> +#else
> #define NOP 0xe8bd4000 /* pop {lr} */
> +#endif
>
> #ifdef CONFIG_OLD_MCOUNT
> #define OLD_MCOUNT_ADDR ((unsigned long) mcount)
> @@ -56,6 +60,34 @@ static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
> #endif
>
> /* construct a branch (BL) instruction to addr */
> +#ifdef CONFIG_THUMB2_KERNEL
> +static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
> +{
> + unsigned long s, j1, j2, i1, i2, imm10, imm11;
> + unsigned long first, second;
> + long offset;
> +
> + offset = (long)addr - (long)(pc + 4);
> + if (offset < -16777216 || offset > 16777214) {
> + WARN_ON_ONCE(1);
> + return 0;
> + }
> +
> + s = (offset >> 24) & 0x1;
> + i1 = (offset >> 23) & 0x1;
> + i2 = (offset >> 22) & 0x1;
> + imm10 = (offset >> 12) & 0x3ff;
> + imm11 = (offset >> 1) & 0x7ff;
> +
> + j1 = (!i1) ^ s;
> + j2 = (!i2) ^ s;
> +
> + first = 0xf000 | (s << 10) | imm10;
> + second = 0xd000 | (j1 << 13) | (j2 << 11) | imm11;
> +
> + return (second << 16) | first;
> +}
> +#else
> static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
> {
> long offset;
> @@ -73,6 +105,7 @@ static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
>
> return 0xeb000000 | offset;
> }
> +#endif
>
> static int ftrace_modify_code(unsigned long pc, unsigned long old,
> unsigned long new)
> diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
> index 66c1c4b..88b083b 100755
> --- a/scripts/recordmcount.pl
> +++ b/scripts/recordmcount.pl
For the recordmcount.pl change;
Acked-by: Steven Rostedt <rostedt@goodmis.org>
-- Steve
> @@ -267,7 +267,7 @@ if ($arch eq "x86_64") {
> } elsif ($arch eq "arm") {
> $alignment = 2;
> $section_type = '%progbits';
> - $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24)" .
> + $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24|THM_CALL)" .
> "\\s+(__gnu_mcount_nc|mcount)\$";
>
> } elsif ($arch eq "ia64") {
WARNING: multiple messages have this Message-ID (diff)
From: Steven Rostedt <rostedt@goodmis.org>
To: Rabin Vincent <rabin@rab.in>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Frederic Weisbecker" <fweisbec@gmail.com>,
"Ingo Molnar" <mingo@redhat.com>,
"Abhishek Sagar" <sagar.abhishek@gmail.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Subject: Re: [PATCH 09/10] ARM: ftrace: add Thumb-2 support to dynamic ftrace
Date: Tue, 23 Feb 2010 08:35:00 -0500 [thread overview]
Message-ID: <1266932100.19540.12.camel@frodo> (raw)
In-Reply-To: <1266090518-31120-10-git-send-email-rabin@rab.in>
On Sun, 2010-02-14 at 01:18 +0530, Rabin Vincent wrote:
> Handle the different nop and call instructions for Thumb-2. Also, we
> need to adjust the recorded mcount_loc addresses because they have the
> lsb set.
>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Rabin Vincent <rabin@rab.in>
> ---
> arch/arm/include/asm/ftrace.h | 4 ++++
> arch/arm/kernel/ftrace.c | 33 +++++++++++++++++++++++++++++++++
> scripts/recordmcount.pl | 2 +-
> 3 files changed, 38 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h
> index 4a56a2e..0845f2d 100644
> --- a/arch/arm/include/asm/ftrace.h
> +++ b/arch/arm/include/asm/ftrace.h
> @@ -18,7 +18,11 @@ struct dyn_arch_ftrace {
>
> static inline unsigned long ftrace_call_adjust(unsigned long addr)
> {
> +#ifdef CONFIG_THUMB2_KERNEL
> + return addr & ~1;
Would it be safe to do that for all arm archs? Instead of adding a
config option around it. Or do some arm archs need the lsb set.
I'm just saying a comment here would look better than #ifdef #else.
> +#else
> return addr;
> +#endif
> }
>
> extern void ftrace_caller_old(void);
> diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
> index f09014c..971ac8c 100644
> --- a/arch/arm/kernel/ftrace.c
> +++ b/arch/arm/kernel/ftrace.c
> @@ -18,7 +18,11 @@
> #include <asm/cacheflush.h>
> #include <asm/ftrace.h>
>
> +#ifdef CONFIG_THUMB2_KERNEL
> +#define NOP 0xeb04f85d /* pop.w {lr} */
> +#else
> #define NOP 0xe8bd4000 /* pop {lr} */
> +#endif
>
> #ifdef CONFIG_OLD_MCOUNT
> #define OLD_MCOUNT_ADDR ((unsigned long) mcount)
> @@ -56,6 +60,34 @@ static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
> #endif
>
> /* construct a branch (BL) instruction to addr */
> +#ifdef CONFIG_THUMB2_KERNEL
> +static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
> +{
> + unsigned long s, j1, j2, i1, i2, imm10, imm11;
> + unsigned long first, second;
> + long offset;
> +
> + offset = (long)addr - (long)(pc + 4);
> + if (offset < -16777216 || offset > 16777214) {
> + WARN_ON_ONCE(1);
> + return 0;
> + }
> +
> + s = (offset >> 24) & 0x1;
> + i1 = (offset >> 23) & 0x1;
> + i2 = (offset >> 22) & 0x1;
> + imm10 = (offset >> 12) & 0x3ff;
> + imm11 = (offset >> 1) & 0x7ff;
> +
> + j1 = (!i1) ^ s;
> + j2 = (!i2) ^ s;
> +
> + first = 0xf000 | (s << 10) | imm10;
> + second = 0xd000 | (j1 << 13) | (j2 << 11) | imm11;
> +
> + return (second << 16) | first;
> +}
> +#else
> static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
> {
> long offset;
> @@ -73,6 +105,7 @@ static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr)
>
> return 0xeb000000 | offset;
> }
> +#endif
>
> static int ftrace_modify_code(unsigned long pc, unsigned long old,
> unsigned long new)
> diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
> index 66c1c4b..88b083b 100755
> --- a/scripts/recordmcount.pl
> +++ b/scripts/recordmcount.pl
For the recordmcount.pl change;
Acked-by: Steven Rostedt <rostedt@goodmis.org>
-- Steve
> @@ -267,7 +267,7 @@ if ($arch eq "x86_64") {
> } elsif ($arch eq "arm") {
> $alignment = 2;
> $section_type = '%progbits';
> - $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24)" .
> + $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24|THM_CALL)" .
> "\\s+(__gnu_mcount_nc|mcount)\$";
>
> } elsif ($arch eq "ia64") {
next prev parent reply other threads:[~2010-02-23 13:35 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-13 19:48 [PATCH 00/10] ARM: ftrace: cleanups, Thumb-2, and dynamic ftrace Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-13 19:48 ` [PATCH 01/10] ARM: ftrace: clean up mcount assembly indentation Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-13 20:18 ` Uwe Kleine-König
2010-02-13 20:18 ` Uwe Kleine-König
2010-02-22 18:36 ` Frederic Weisbecker
2010-02-22 18:36 ` Frederic Weisbecker
2010-02-13 19:48 ` [PATCH 02/10] ARM: ftrace: document mcount formats Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-13 20:37 ` Uwe Kleine-König
2010-02-13 20:37 ` Uwe Kleine-König
2010-02-22 18:06 ` Rabin Vincent
2010-02-22 18:06 ` Rabin Vincent
2010-02-22 19:20 ` Uwe Kleine-König
2010-02-22 19:20 ` Uwe Kleine-König
2010-02-23 19:42 ` Rabin Vincent
2010-02-23 19:42 ` Rabin Vincent
2010-02-23 20:27 ` Uwe Kleine-König
2010-02-23 20:27 ` Uwe Kleine-König
2010-02-22 18:41 ` Frederic Weisbecker
2010-02-22 18:41 ` Frederic Weisbecker
2010-02-13 19:48 ` [PATCH 03/10] ftrace: allow building without frame pointers Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-22 18:36 ` Frederic Weisbecker
2010-02-22 18:36 ` Frederic Weisbecker
2010-02-23 13:44 ` Steven Rostedt
2010-02-23 13:44 ` Steven Rostedt
2010-02-13 19:48 ` [PATCH 04/10] ARM: " Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-22 19:05 ` Frederic Weisbecker
2010-02-22 19:05 ` Frederic Weisbecker
2010-02-23 13:18 ` Steven Rostedt
2010-02-23 13:18 ` Steven Rostedt
2010-02-23 17:11 ` Frederic Weisbecker
2010-02-23 17:11 ` Frederic Weisbecker
2010-02-23 17:58 ` Rabin Vincent
2010-02-23 17:58 ` Rabin Vincent
2010-02-23 18:03 ` Steven Rostedt
2010-02-23 18:03 ` Steven Rostedt
2010-02-23 18:41 ` Rabin Vincent
2010-02-23 18:41 ` Rabin Vincent
2010-02-23 13:47 ` Steven Rostedt
2010-02-23 13:47 ` Steven Rostedt
2010-02-13 19:48 ` [PATCH 05/10] ARM: ftrace: add ENDPROC annotations Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-13 22:54 ` Catalin Marinas
2010-02-13 22:54 ` Catalin Marinas
2010-02-13 19:48 ` [PATCH 06/10] ARM: ftrace: add Thumb-2 support Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-13 23:27 ` Catalin Marinas
2010-02-13 23:27 ` Catalin Marinas
2010-02-14 16:38 ` Rabin Vincent
2010-02-14 16:38 ` Rabin Vincent
2010-02-13 19:48 ` [PATCH 07/10] ftrace: pass KBUILD_CFLAGS to record_mcount.pl Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-23 13:30 ` Steven Rostedt
2010-02-23 13:30 ` Steven Rostedt
2010-02-23 18:23 ` Rabin Vincent
2010-02-23 18:23 ` Rabin Vincent
2010-02-23 18:37 ` Steven Rostedt
2010-02-23 18:37 ` Steven Rostedt
2010-02-13 19:48 ` [PATCH 08/10] ARM: ftrace: fix and update dynamic ftrace Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-14 11:08 ` Uwe Kleine-König
2010-02-14 11:08 ` Uwe Kleine-König
2010-02-14 15:53 ` Rabin Vincent
2010-02-14 15:53 ` Rabin Vincent
2010-02-13 19:48 ` [PATCH 09/10] ARM: ftrace: add Thumb-2 support to " Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-23 13:35 ` Steven Rostedt [this message]
2010-02-23 13:35 ` Steven Rostedt
2010-02-23 17:10 ` Rabin Vincent
2010-02-23 17:10 ` Rabin Vincent
2010-02-13 19:48 ` [PATCH 10/10] ARM: ftrace: enable " Rabin Vincent
2010-02-13 19:48 ` Rabin Vincent
2010-02-22 18:16 ` [PATCH 00/10] ARM: ftrace: cleanups, Thumb-2, and " Rabin Vincent
2010-02-22 18:16 ` Rabin Vincent
-- strict thread matches above, loose matches on Subject: below --
2010-03-13 6:49 [PATCH 00/10] ARM: ftrace: cleanups, Thumb-2, and dynamic ftrace (v2) Rabin Vincent
2010-03-13 6:49 ` [PATCH 09/10] ARM: ftrace: add Thumb-2 support to dynamic ftrace Rabin Vincent
2010-03-13 6:49 ` Rabin Vincent
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=1266932100.19540.12.camel@frodo \
--to=rostedt@goodmis.org \
--cc=linux-arm-kernel@lists.infradead.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 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.