Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: David Daney <david.s.daney@gmail.com>
To: Wu Zhangjin <wuzhangjin@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	linux-mips <linux-mips@linux-mips.org>
Subject: Re: [PATCH 9/9] tracing: MIPS: cleanup of the address space checking
Date: Wed, 12 May 2010 10:13:01 -0700	[thread overview]
Message-ID: <4BEAE19D.40502@gmail.com> (raw)
In-Reply-To: <86404e31ca5c4c33b785bad7f6223ac775f4f879.1273669419.git.wuzhangjin@gmail.com>

On 05/12/2010 06:23 AM, Wu Zhangjin wrote:
> From: Wu Zhangjin<wuzhangjin@gmail.com>
>
> This patch adds an inline function in_module() to check which space the
> instruction pointer in, kernel space or module space.
>
> Note: This may not work when the kernel is compiled with -msym32.
>

The kernel is always compiled with -msym32, so the patch is a bit pointless.



> Signed-off-by: Wu Zhangjin<wuzhangjin@gmail.com>
> ---
>   arch/mips/kernel/ftrace.c |   17 ++++++++++++++---
>   1 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c
> index 628e90b..37f15b6 100644
> --- a/arch/mips/kernel/ftrace.c
> +++ b/arch/mips/kernel/ftrace.c
> @@ -17,6 +17,17 @@
>   #include<asm/cacheflush.h>
>   #include<asm/uasm.h>
>
> +/*
> + * If the Instruction Pointer is in module space (0xc0000000), return true;
> + * otherwise, it is in kernel space (0x80000000), return false.
> + *
> + * FIXME: This may not work when the kernel is compiled with -msym32.
> + */
> +static inline int in_module(unsigned long ip)
> +{
> +	return ip&  0x40000000;
> +}
> +

How about (untested):


static inline int in_module(unsigned long ip)
{
	return ip < _text || ip > _etext;
}


But why do we even care?  Can't we just probe the function prologue and 
determine from that what needs to be done?

David Daney

>   #ifdef CONFIG_DYNAMIC_FTRACE
>
>   #define JAL 0x0c000000		/* jump&  link: ip -->  ra, jump to target */
> @@ -78,7 +89,7 @@ int ftrace_make_nop(struct module *mod,
>   	 * We have compiled module with -mlong-calls, but compiled the kernel
>   	 * without it, we need to cope with them respectively.
>   	 */
> -	if (ip&  0x40000000) {
> +	if (in_module(ip)) {
>   #if defined(KBUILD_MCOUNT_RA_ADDRESS)&&  defined(CONFIG_32BIT)
>   		/*
>   		 * lui v1, hi_16bit_of_mcount        -->  b 1f (0x10000005)
> @@ -117,7 +128,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
>   	unsigned long ip = rec->ip;
>
>   	/* ip, module: 0xc0000000, kernel: 0x80000000 */
> -	new = (ip&  0x40000000) ? insn_lui_v1_hi16_mcount : insn_jal_ftrace_caller;
> +	new = in_module(ip) ? insn_lui_v1_hi16_mcount : insn_jal_ftrace_caller;
>
>   	return ftrace_modify_code(ip, new);
>   }
> @@ -188,7 +199,7 @@ unsigned long ftrace_get_parent_addr(unsigned long self_addr,
>   	 * instruction "lui v1, hi_16bit_of_mcount"(offset is 20), but for
>   	 * kernel, move to the instruction "move ra, at"(offset is 12)
>   	 */
> -	ip = self_addr - ((self_addr&  0x40000000) ? 20 : 12);
> +	ip = self_addr - (in_module(self_addr) ? 20 : 12);
>
>   	/*
>   	 * search the text until finding the non-store instruction or "s{d,w}

  reply	other threads:[~2010-05-12 17:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-12 13:23 [PATCH v6 0/9] tracing: MIPS: add misc fixups and cleanups Wu Zhangjin
2010-05-12 13:23 ` [PATCH 1/9] tracing: MIPS: mcount.S: merge the same continuous #ifdefs Wu Zhangjin
2010-05-12 13:23 ` [PATCH 2/9] tracing: MIPS: mcount.S: Fixup of the 32bit support with gcc 4.5 Wu Zhangjin
2010-05-12 17:16   ` David Daney
2010-05-13  1:35     ` Wu Zhangjin
2010-05-12 13:23 ` [PATCH 3/9] tracing: MIPS: mcount.S: cleanup the arguments of prepare_ftrace_return Wu Zhangjin
2010-05-12 13:23 ` [PATCH 4/9] tracing: MIPS: mcount.S: cleanup of the comments Wu Zhangjin
2010-05-12 13:23 ` [PATCH 5/9] tracing: MIPS: Fixup of the 32bit support with -mmcount-ra-address Wu Zhangjin
2010-05-12 13:23 ` [PATCH 6/9] tracing: MIPS: cleanup of the instructions Wu Zhangjin
2010-05-12 13:23 ` [PATCH 7/9] tracing: MIPS: Reduce the overhead of dynamic Function Tracer Wu Zhangjin
2010-05-12 13:23 ` [PATCH 8/9] tracing: MIPS: cleanup of function graph tracer Wu Zhangjin
2010-05-12 13:23 ` [PATCH 9/9] tracing: MIPS: cleanup of the address space checking Wu Zhangjin
2010-05-12 17:13   ` David Daney [this message]
2010-05-13  2:19     ` Wu Zhangjin
2010-05-13 16:13     ` Ralf Baechle
2010-05-13 16:17       ` David Daney
  -- strict thread matches above, loose matches on Subject: below --
2010-05-14 11:08 [PATCH v7 0/9] tracing: MIPS: add misc fixups and cleanups Wu Zhangjin
2010-05-14 11:08 ` [PATCH 9/9] tracing: MIPS: cleanup of the address space checking Wu Zhangjin
2010-05-27 11:28   ` Ralf Baechle

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=4BEAE19D.40502@gmail.com \
    --to=david.s.daney@gmail.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=wuzhangjin@gmail.com \
    /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