From: Petr Mladek <pmladek@suse.com>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Tony Luck <tony.luck@intel.com>,
Fenghua Yu <fenghua.yu@intel.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>,
Michael Ellerman <mpe@ellerman.id.au>,
James Bottomley <jejb@parisc-linux.org>,
Helge Deller <deller@gmx.de>,
Andrew Morton <akpm@linux-foundation.org>,
Jessica Yu <jeyu@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCHv3 6/7] symbol lookup: use new kernel and module dereference functions
Date: Wed, 4 Oct 2017 13:53:06 +0200 [thread overview]
Message-ID: <20171004115306.GH20084@pathway.suse.cz> (raw)
In-Reply-To: <20170930025319.987-7-sergey.senozhatsky@gmail.com>
On Sat 2017-09-30 11:53:18, Sergey Senozhatsky wrote:
> Call appropriate function descriptor dereference ARCH callbacks:
> - dereference_kernel_function_descriptor() if the pointer is a
> kernel symbol;
>
> - dereference_module_function_descriptor() if the pointer is a
> module symbol.
>
> This patch also removes dereference_function_descriptor() from
> '%pF/%pf' vsprintf handler, because it has the same behavior with
> '%pS/%ps' now.
The description is pretty criptic. It should explain why
the dereference was moved from vsprintf to the symbol lookup
and if it is safe.
Note that kallsyms_lookup() and module_address_lookup() is used
in many other situations.
Also I would not be afraid to repeat description of the big picture
from the 2nd patch.
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> Tested-by: Helge Deller <deller@gmx.de> # parisc64
> Tested-by: Santosh Sivaraj <santosh@fossix.org> # powerpc64
> Acked-by: Michael Ellerman <mpe@ellerman.id.au> # powerpc64
> Tested-by: Tony Luck <tony.luck@intel.com> # ia64
> ---
> Documentation/printk-formats.txt | 20 ++++++++++----------
> kernel/kallsyms.c | 1 +
> kernel/module.c | 1 +
> lib/vsprintf.c | 5 +----
> 4 files changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt
> index 361789df51ec..3adbc4fdd482 100644
> --- a/Documentation/printk-formats.txt
> +++ b/Documentation/printk-formats.txt
> @@ -50,26 +50,28 @@ Symbols/Function Pointers
>
> ::
>
> + %pS versatile_init+0x0/0x110
> + %ps versatile_init
> %pF versatile_init+0x0/0x110
> %pf versatile_init
> - %pS versatile_init+0x0/0x110
> %pSR versatile_init+0x9/0x110
> (with __builtin_extract_return_addr() translation)
> - %ps versatile_init
> %pB prev_fn_of_versatile_init+0x88/0x88
>
> -The ``F`` and ``f`` specifiers are for printing function pointers,
> -for example, f->func, &gettimeofday. They have the same result as
> -``S`` and ``s`` specifiers. But they do an extra conversion on
> -ia64, ppc64 and parisc64 architectures where the function pointers
> -are actually function descriptors.
> -
> The ``S`` and ``s`` specifiers can be used for printing symbols
> from direct addresses, for example, __builtin_return_address(0),
> (void *)regs->ip. They result in the symbol name with (``S``) or
> without (``s``) offsets. If KALLSYMS are disabled then the symbol
> address is printed instead.
This paragraph makes the feeling that ``S`` is still only for direct
adresses. We should update it as well.
> +Note, that the ``F`` and ``f`` specifiers are identical to ``S`` (``s``)
> +and thus deprecated. We have ``F`` and ``f`` because on ia64, ppc64 and
> +parisc64 function pointers are indirect and, in fact, are function
> +descriptors, which require additional dereferencing before we can lookup
> +the symbol. As of now, ``S`` and ``s`` perform dereferencing on those
> +platforms (when needed), so ``F`` and ``f`` exist for compatibility
> +reasons only.
> +
> The ``B`` specifier results in the symbol name with offsets and should be
> used when printing stack backtraces. The specifier takes into
> consideration the effect of compiler optimisations which may occur
> @@ -77,8 +79,6 @@ when tail-call``s are used and marked with the noreturn GCC attribute.
>
> Examples::
>
> - printk("Going to call: %pF\n", gettimeofday);
> - printk("Going to call: %pF\n", p->func);
> printk("%s: called from %pS\n", __func__, (void *)_RET_IP_);
> printk("%s: called from %pS\n", __func__,
> (void *)__builtin_return_address(0));
We should either replace %pF with %pS or remove all examples.
It is strange to keep only half of them.
> diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> index 127e7cfafa55..e2fc09ea9509 100644
> --- a/kernel/kallsyms.c
> +++ b/kernel/kallsyms.c
> @@ -322,6 +322,7 @@ const char *kallsyms_lookup(unsigned long addr,
> if (is_ksym_addr(addr)) {
is_ksym_addr() ignores the special .opd elf sections if
CONFIG_KALLSYMS_ALL is disabled. We should dereference before
this call.
> unsigned long pos;
>
> + addr = dereference_kernel_function_descriptor(addr);
> pos = get_symbol_pos(addr, symbolsize, offset);
I still wonder if doing the dereference in the widely used kallsyms
might cause any regression.
One possible problem is that this function returns "offset".
One might expect that it is offset against "addr" but
it is not if the dereference happens here.
Also get_symbol_pos() is called in several other helpers
but the dereference is done only here. It would be
confusing if for example kallsyms_lookup_size_offset()
and kallsyms_lookup() give different result.
I would feel much more comfortable if we keep the derefenrece
only in vsprintf.
In each case, we need approval from Jessica for the
change in module.c.
Best Regards,
Petr
next prev parent reply other threads:[~2017-10-04 11:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-30 2:53 [PATCHv3 0/7] printk/ia64/ppc64/parisc64: let's deprecate %pF/%pf printk specifiers Sergey Senozhatsky
2017-09-30 2:53 ` [PATCHv3 1/7] switch dereference_function_descriptor() to `unsigned long' Sergey Senozhatsky
2017-10-04 8:24 ` Petr Mladek
2017-10-19 6:50 ` Sergey Senozhatsky
2017-10-20 13:25 ` Petr Mladek
2017-09-30 2:53 ` [PATCHv3 2/7] sections: split dereference_function_descriptor() Sergey Senozhatsky
2017-10-04 9:00 ` Petr Mladek
2017-10-19 6:45 ` Sergey Senozhatsky
2017-09-30 2:53 ` [PATCHv3 3/7] ia64: Add .opd based function descriptor dereference Sergey Senozhatsky
2017-10-04 9:05 ` Petr Mladek
2017-09-30 2:53 ` [PATCHv3 4/7] powerpc64: " Sergey Senozhatsky
2017-10-04 9:21 ` Petr Mladek
2017-10-04 11:06 ` Michael Ellerman
2017-10-19 14:01 ` Sergey Senozhatsky
2017-10-19 6:45 ` Sergey Senozhatsky
2017-09-30 2:53 ` [PATCHv3 5/7] parisc64: " Sergey Senozhatsky
2017-10-04 10:40 ` Petr Mladek
2017-10-19 6:44 ` Sergey Senozhatsky
2017-09-30 2:53 ` [PATCHv3 6/7] symbol lookup: use new kernel and module dereference functions Sergey Senozhatsky
2017-10-04 11:53 ` Petr Mladek [this message]
2017-10-19 6:42 ` Sergey Senozhatsky
2017-10-20 13:08 ` Petr Mladek
2017-10-23 8:38 ` Sergey Senozhatsky
2017-09-30 2:53 ` [PATCHv3 7/7] checkpatch: add pF/pf deprecation warning Sergey Senozhatsky
2017-10-04 12:08 ` 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=20171004115306.GH20084@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=akpm@linux-foundation.org \
--cc=ast@kernel.org \
--cc=benh@kernel.crashing.org \
--cc=deller@gmx.de \
--cc=fenghua.yu@intel.com \
--cc=jejb@parisc-linux.org \
--cc=jeyu@kernel.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
--cc=tony.luck@intel.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;
as well as URLs for NNTP newsgroup(s).