LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Michael Jeanson <mjeanson@efficios.com>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>
Cc: linux-arch <linux-arch@vger.kernel.org>,
	"linux-ia64@vger.kernel.org" <linux-ia64@vger.kernel.org>,
	"open list:PARISC ARCHITECTURE" <linux-parisc@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: [RFC PATCH] Syscall tracing on PPC64_ELF_ABI_V1 without KALLSYMS_ALL
Date: Tue, 13 Dec 2022 07:29:50 +0000	[thread overview]
Message-ID: <39c53bd1-432f-15f6-4cbd-b8551fc261cf@csgroup.eu> (raw)
In-Reply-To: <20221212212159.3435046-1-mjeanson@efficios.com>

The changes are absolutely not specific to powerpc. You should adjust 
the subject accordingly, and copy linux-arch and tracing and probably 
also ia64 and parisc.

Le 12/12/2022 à 22:21, Michael Jeanson a écrit :
> In ad050d2390fccb22aa3e6f65e11757ce7a5a7ca5 we fixed ftrace syscall
> tracing on PPC64_ELF_ABI_V1 by looking for the non-dot prefixed symbol
> of a syscall.

Should be written as:

Commit ad050d2390fc ("powerpc/ftrace: fix syscall tracing on 
PPC64_ELF_ABI_V1") fixed ....


> 
> Ftrace uses kallsyms to locate syscall symbols and those non-dot
> prefixed symbols reside in a separate '.opd' section which is not
> included by kallsyms.
> 
> So we either need to have FTRACE_SYSCALLS select KALLSYMS_ALL on
> PPC64_ELF_ABI_V1 or add the '.opd' section symbols to kallsyms.
> 
> This patch does the minimum to achieve the latter, it's tested on a
> corenet64_smp_defconfig with KALLSYMS_ALL turned off.
> 
> I'm unsure which of the alternatives would be better.
> 
> ---
> In 'kernel/module/kallsyms.c' the 'is_core_symbol' function might also
> require some tweaking to make all opd symbols available to kallsyms but
> that doesn't impact ftrace syscall tracing.
> 
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
> ---
>   include/asm-generic/sections.h | 14 ++++++++++++++
>   include/linux/kallsyms.h       |  3 +++
>   kernel/kallsyms.c              |  2 ++
>   scripts/kallsyms.c             |  1 +
>   4 files changed, 20 insertions(+)
> 
> diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
> index db13bb620f52..1410566957e5 100644
> --- a/include/asm-generic/sections.h
> +++ b/include/asm-generic/sections.h
> @@ -180,6 +180,20 @@ static inline bool is_kernel_rodata(unsigned long addr)
>   	       addr < (unsigned long)__end_rodata;
>   }
>   
> +/**
> + * is_kernel_opd - checks if the pointer address is located in the
> + *                 .opd section
> + *
> + * @addr: address to check
> + *
> + * Returns: true if the address is located in .opd, false otherwise.
> + */
> +static inline bool is_kernel_opd(unsigned long addr)
> +{

I would add a check of CONFIG_HAVE_FUNCTION_DESCRIPTORS:

	if (!IS_ENABLED(CONFIG_HAVE_FUNCTION_DESCRIPTORS))
		return false;

> +	return addr >= (unsigned long)__start_opd &&
> +	       addr < (unsigned long)__end_opd;
> +}
> +
>   /**
>    * is_kernel_inittext - checks if the pointer address is located in the
>    *                      .init.text section
> diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
> index 649faac31ddb..9bfb4d8d41a5 100644
> --- a/include/linux/kallsyms.h
> +++ b/include/linux/kallsyms.h
> @@ -43,6 +43,9 @@ static inline int is_ksym_addr(unsigned long addr)
>   	if (IS_ENABLED(CONFIG_KALLSYMS_ALL))
>   		return is_kernel(addr);
>   
> +	if (IS_ENABLED(CONFIG_HAVE_FUNCTION_DESCRIPTORS))
> +		return is_kernel_text(addr) || is_kernel_inittext(addr) || is_kernel_opd(addr);
> +

With the check inside is_kernel_opd(), you can make it simpler:

	return is_kernel_text(addr) || is_kernel_inittext(addr) || 
is_kernel_opd(addr);

>   	return is_kernel_text(addr) || is_kernel_inittext(addr);
>   }
>   
> diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> index 60c20f301a6b..009b1ca21618 100644
> --- a/kernel/kallsyms.c
> +++ b/kernel/kallsyms.c
> @@ -281,6 +281,8 @@ static unsigned long get_symbol_pos(unsigned long addr,
>   			symbol_end = (unsigned long)_einittext;
>   		else if (IS_ENABLED(CONFIG_KALLSYMS_ALL))
>   			symbol_end = (unsigned long)_end;
> +		else if (IS_ENABLED(CONFIG_HAVE_FUNCTION_DESCRIPTORS) && is_kernel_opd(addr))
> +			symbol_end = (unsigned long)__end_opd;

Same, with the check included inside is_kernel_opd() you don't need the 
IS_ENABLED(CONFIG_HAVE_FUNCTION_DESCRIPTORS) here.

>   		else
>   			symbol_end = (unsigned long)_etext;
>   	}
> diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
> index 03fa07ad45d9..decf31c497f5 100644
> --- a/scripts/kallsyms.c
> +++ b/scripts/kallsyms.c
> @@ -64,6 +64,7 @@ static unsigned long long relative_base;
>   static struct addr_range text_ranges[] = {
>   	{ "_stext",     "_etext"     },
>   	{ "_sinittext", "_einittext" },
> +	{ "__start_opd", "__end_opd" },
>   };
>   #define text_range_text     (&text_ranges[0])
>   #define text_range_inittext (&text_ranges[1])

  reply	other threads:[~2022-12-13  7:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-12 21:21 [RFC PATCH] Syscall tracing on PPC64_ELF_ABI_V1 without KALLSYMS_ALL Michael Jeanson
2022-12-13  7:29 ` Christophe Leroy [this message]
2022-12-14 20:26   ` Michael Jeanson

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=39c53bd1-432f-15f6-4cbd-b8551fc261cf@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=arnd@arndb.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-ia64@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mjeanson@efficios.com \
    --cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox