linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Kim Phillips <kim.phillips@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>,
	Will Deacon <will.deacon@arm.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>, Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Jiri Olsa <jolsa@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
	kernel-team@lge.com
Subject: Re: [PATCH] perf tools: set kernel end address properly
Date: Tue, 24 Apr 2018 08:13:57 +0200	[thread overview]
Message-ID: <CAKv+Gu-u1E9gH7=p5sbiA4k_9mQ13y+056nYKnr2D9BPENNyMg@mail.gmail.com> (raw)
In-Reply-To: <20180423164317.5a47f3dd9842d533413a1d4b@arm.com>

On 23 April 2018 at 23:43, Kim Phillips <kim.phillips@arm.com> wrote:
> On Fri, 20 Apr 2018 10:10:32 +0200
> Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
>> On 20 April 2018 at 01:33, Kim Phillips <kim.phillips@arm.com> wrote:
>> > On Thu, 19 Apr 2018 11:54:24 +0900
>> > Namhyung Kim <namhyung@kernel.org> wrote:
>> >
>> >> On Wed, Apr 18, 2018 at 07:37:59PM -0500, Kim Phillips wrote:
>> >> > diff --git a/tools/perf/arch/arm64/util/sym-handling.c b/tools/perf/arch/arm64/util/sym-handling.c
>> >> > index 0051b1ee8450..5c4a2e208bbc 100644
>> >> > --- a/tools/perf/arch/arm64/util/sym-handling.c
>> >> > +++ b/tools/perf/arch/arm64/util/sym-handling.c
>> >> > @@ -20,3 +20,16 @@ bool elf__needs_adjust_symbols(GElf_Ehdr ehdr)
>> >> >                ehdr.e_type == ET_DYN;
>> >> >  }
>> >> >  #endif
>> >> > +
>> >> > +const char *arch__normalize_symbol_name(const char *name)
>> >> > +{
>> >> > +       /*
>> >> > +        * arm64 kernels compensating for a CPU erratum can put up a
>> >> > +        * module_emit_adrp_veneer in place of a module_emit_plt_entry
>> >> > +        */
>> >> > +       if (name && strlen(name) >= 23 &&
>> >> > +           !strncmp(name, "module_emit_adrp_veneer", 23))
>> >> > +               return "module_emit_plt_entry";
>> >> > +
>> >> > +       return name;
>> >> > +}
>> >>
>> >> I don't know it's always preferable or just for the test.  It it's the
>> >> latter it may be better to move it to the test code.
>> >
>> > AFACT, the veneer is a moniker and doesn't technically exist, and
>> > shouldn't be being looked-up.  Both chunks of this diff are needed to
>> > pass perf test 1: this chunk above is because in
>> > arch__normalize_symbol_name(), we squash the perf test 1's "<veneer>
>> > not in *kallsyms*" problem, and in the below chunk, we prevent it
>> > coming up when the test code iterates over the *vmlinux* symbols. I.e.
>> > we need to prevent the veneer from coming up in both kallsyms *and*
>> > vmlinux.
>>
>> I don't have all the context here, so I don't know what exactly
>> arch__normalize_symbol_name() is trying to accomplish.
>
> Sorry about that.  The problem is that perf test 1 ("vmlinux
> symtab matches kallsyms") is failing, because
> module_emit_adrp_veneer exists in /boot/vmlinux but doesn't exist
> in /proc/kallsyms, and, sure enough, it's not in the latter.
>
>> What I do know is that module_emit_adrp_veneer() and
>> module_emit_plt_entry() are not part of the veneer themselves: they
>> are ordinary routines that are part of the module loader, and which
>> populate the allocated veneer space on demand when encountering ADRP
>> instructions that need to be rerouted.
> ...
>> > >> rare case we might need to add more paranoid checks.
>> >
>> > It's certainly rare: Adding the authors of the veneer to cc for
>> > comments:
>> >
>> > Will, Ard, how probable are veneer-style symbols such as the
>> > one introduced in commit a257e0257 "arm64/kernel: don't ban ADRP to
>> > work around Cortex-A53 erratum #843419" to happen again in the future?
>> >
>>
>> Distro kernels typically enable full KASLR, so on systems that
>> implement EFI_RNG_PROTOCOL, all function calls from modules into the
>> kernel proper are redirected via veneers. (Note that these are bl
>> instructions not adrp instructions though).
>>
>> > I would have thought WARNing on within-a-pagesize would be OK,
>> > Namhyung.  Are you suggesting checking instead for a hardcoded veneer
>> > symbol string?
>>
>> Veneers don't have symbol strings. Veneers are anonymous sequences of
>> instructions living in a patch of R-X mapped module space somewhere.
>> The only symbol strings are for the routines that generate these
>> veneers, not for the veneers themselves.
>
> OK, thanks, so AFAICT this means the function module_emit_adrp_veneer()
> should still show up in /proc/kallsyms, but it's not.  I'm also seeing
> some weird characters, e.g., here there's a byte with a binary 02 value
> following a weird symbol named 'L14472' (part of the xfs module?):
>
> $ grep L1 /proc/kallsyms | hexdump -C | head
> <snip>
> 00000540  30 30 30 30 30 20 72 20  2e 4c 31 34 34 37 32 02  |00000 r .L14472.|
> <snip>
>
> arch__normalize_symbol_name() is a place where architecture code can
> clean up symbol names in perf, and I thought module_emit_adrp_veneer()
> was a veneer itself, but it seems that's not the case, so the
> literal string check for it shouldn't be needed.  The test is still
> failing though because it doesn't show up in kallsyms...
>

This turns out to be an unintended side effect of the fact that we
(I?) taught kallsyms to disregard symbols ending in "_veneer"

So we should probably rename the function, and everything will be fine.

  reply	other threads:[~2018-04-24  6:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16  4:22 [PATCH] perf tools: set kernel end address properly Namhyung Kim
2018-04-16  9:23 ` Jiri Olsa
2018-04-16 13:51   ` Arnaldo Carvalho de Melo
2018-04-16 16:07     ` Kim Phillips
2018-04-16 16:58       ` Arnaldo Carvalho de Melo
2018-04-16 17:24         ` Kim Phillips
2018-04-16 22:48           ` Kim Phillips
2018-04-17  2:27             ` Namhyung Kim
2018-04-19  0:37               ` Kim Phillips
2018-04-19  2:37                 ` Namhyung Kim
2018-04-19 23:20                   ` Kim Phillips
2018-04-19 23:59                     ` Namhyung Kim
2018-04-20 23:23                       ` Kim Phillips
2018-04-23 13:52                         ` Arnaldo Carvalho de Melo
2018-04-23 14:56                           ` Kim Phillips
2018-04-26  5:51                       ` [tip:perf/urgent] perf machine: Set main " tip-bot for Namhyung Kim
2018-04-19  2:54                 ` [PATCH] perf tools: set " Namhyung Kim
2018-04-19 23:33                   ` Kim Phillips
2018-04-20  0:11                     ` Namhyung Kim
2018-04-20  8:10                     ` Ard Biesheuvel
2018-04-23 21:43                       ` Kim Phillips
2018-04-24  6:13                         ` Ard Biesheuvel [this message]
2018-04-24 12:50                           ` Kim Phillips
2018-04-24 13:07                             ` Ard Biesheuvel
2018-04-24 15:13                               ` [PATCH] arm64/kernel: rename module_emit_adrp_veneer->module_emit_veneer_for_adrp Kim Phillips
2018-04-24 15:15                                 ` Ard Biesheuvel
2018-04-24 15:39                                   ` [PATCH v2] " Kim Phillips

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='CAKv+Gu-u1E9gH7=p5sbiA4k_9mQ13y+056nYKnr2D9BPENNyMg@mail.gmail.com' \
    --to=ard.biesheuvel@linaro.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=kernel-team@lge.com \
    --cc=kim.phillips@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=will.deacon@arm.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).