All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Nathan Chancellor <natechancellor@gmail.com>,
	Kees Cook <keescook@chromium.org>,
	Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	Joe Perches <joe@perches.com>, Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
	"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
	<x86@kernel.org>, Kan Liang <kan.liang@linux.intel.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Shawn Landden <shawn@git.icu>,
	clang-built-linux <clang-built-linux@googlegroups.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Craig Topper <craig.topper@intel.com>,
	Chandler Carruth <chandlerc@google.com>
Subject: Re: [PATCH] perf/x86/intel: Mark expected switch fall-throughs
Date: Thu, 27 Jun 2019 01:11:12 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.1906270043480.32342@nanos.tec.linutronix.de> (raw)
In-Reply-To: <CAKwvOdnvKLs1oF0-G8iq2T4wqcVkBGRKiZjPbb+K0gDRh3Liww@mail.gmail.com>

On Wed, 26 Jun 2019, Nick Desaulniers wrote:
> On Wed, Jun 26, 2019 at 9:31 AM Peter Zijlstra <peterz@infradead.org> wrote:
> > On Tue, Jun 25, 2019 at 11:47:06PM +0200, Thomas Gleixner wrote:
> > > I just checked two of them in the disassembly. In both cases it's jump
> > > label related. Here is one:
> > >
> > >       asm volatile("1: rdmsr\n"
> > >  410:   b9 59 02 00 00          mov    $0x259,%ecx
> > >  415:   0f 32                   rdmsr
> > >  417:   49 89 c6                mov    %rax,%r14
> > >  41a:   48 89 d3                mov    %rdx,%rbx
> > >       return EAX_EDX_VAL(val, low, high);
> > >  41d:   48 c1 e3 20             shl    $0x20,%rbx
> > >  421:   48 09 c3                or     %rax,%rbx
> > >  424:   0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
> > >  429:   eb 0f                   jmp    43a <get_fixed_ranges+0xaa>
> > >       do_trace_read_msr(msr, val, 0);
> > >  42b:   bf 59 02 00 00          mov    $0x259,%edi   <------- "unreachable"
> 
> I assume if 0x42b is unreachable, that's bad as $0x259 is never stored
> in %edi before the call to get_fixed_ranges+0xaa...

Well no. The static key will never be enabled because it's not in the jump
table entries. And that's why objtool complains. That code path @42b will
never be reached even if the tracepoints are enabled because due to the
missing entry the kernel will not patch it.

> > So for some reason the .rela__jump_table are buggy on this clang build.
> 
> So that sounds like a correctness bug then. (I'd been doing testing
> with the STATIC_KEYS_SELFTEST, which I guess doesn't expose this).
> I'm kind of surprised we can boot and pass STATIC_KEYS_SELFTEST.  Any
> way you can help us pare down a test case?

Well, the test thing works as long as the entries which are used there are
correct. And looking at the output of that kernel build I did, I get 6
unreachable entries in 6 different files. That means that ~99% are
correct. So the chance that the self test fails is low.

Vs. test case. Just compile a kernel and pick the first file where objtool
complains. Look at the disassembly which will have the

	   nopl   0x0(%rax,%rax,1)

and that do_trace_read_msr() reference right at that failing offset (or
whatever other function is called in the file you pick).

From there you should be able to debug why the compiler is not emitting the
r.rela__jump_table entry for this particular instance.

I compiled arch/x86/kernel/cpu/mtrr/generic.o several times and the failure
is fully reproducible.

Kernel version is plain v5.2-rc6 and the config I used is here:

  https://tglx.de/~tglx/config-clang-repro

Make invocation is:

  make CC=clang HOST_CC=clang arch/x86/kernel/cpu/mtrr/generic.o

that builds only that single file and not the whole kernel Moloch.

Output:

  CC      arch/x86/kernel/cpu/mtrr/generic.o
arch/x86/kernel/cpu/mtrr/generic.o: warning: objtool: get_fixed_ranges()+0x9b: unreachable instruction

That's with the compiler I built a few hours ago with Nathans fixed
build-llvm.py script. Head commit of llvm-project is:

  master 600941e34fe: Print NULL as "(null)" in diagnostic message

Hope that helps.

Thanks,

	tglx

  reply	other threads:[~2019-06-26 23:11 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24 16:19 [PATCH] perf/x86/intel: Mark expected switch fall-throughs Gustavo A. R. Silva
2019-06-24 19:31 ` Peter Zijlstra
2019-06-24 19:45   ` Joe Perches
2019-06-24 20:37     ` Peter Zijlstra
2019-06-24 20:53       ` Gustavo A. R. Silva
2019-06-24 20:57         ` Joe Perches
2019-06-25  7:20           ` Peter Zijlstra
2019-06-24 22:28         ` Miguel Ojeda
2019-06-25  7:18           ` Peter Zijlstra
2019-06-25 12:47             ` Miguel Ojeda
2019-06-25 18:15               ` Nick Desaulniers
2019-06-25 22:29                 ` Joe Perches
2019-06-25 22:57                   ` Nick Desaulniers
2019-06-25 23:25                     ` Joe Perches
2019-06-26  8:49                 ` Peter Zijlstra
2019-06-26 22:14                   ` Nick Desaulniers
2019-06-27  7:12                     ` Peter Zijlstra
2019-06-28 13:31                       ` Peter Zijlstra
2019-06-28 18:44                         ` Nick Desaulniers
2019-06-29  7:10                           ` Peter Zijlstra
2019-06-25 17:12             ` Kees Cook
2019-06-25 18:05               ` Nathan Chancellor
2019-06-25 19:53                 ` Thomas Gleixner
2019-06-25 20:27                   ` Nathan Chancellor
2019-06-25 20:37                     ` Nick Desaulniers
2019-06-25 21:47                     ` Thomas Gleixner
2019-06-26  5:10                       ` Nathan Chancellor
2019-06-26 15:18                         ` Thomas Gleixner
2019-06-26 19:00                           ` Nathan Chancellor
2019-06-26 19:46                             ` Thomas Gleixner
2019-06-26 20:03                               ` Nathan Chancellor
2019-06-26  9:24                       ` Peter Zijlstra
2019-06-26  9:55                         ` Peter Zijlstra
2019-06-26 22:23                           ` Nick Desaulniers
2019-06-27  7:35                             ` Peter Zijlstra
2019-06-26 10:43                         ` Peter Zijlstra
2019-06-26 22:15                         ` Nick Desaulniers
2019-06-27  7:16                           ` Peter Zijlstra
2019-06-26 16:30                       ` Peter Zijlstra
2019-06-26 22:33                         ` Nick Desaulniers
2019-06-26 23:11                           ` Thomas Gleixner [this message]
2019-06-27  7:11                           ` Peter Zijlstra
2019-06-25 23:46                     ` Arnaldo Carvalho de Melo
2019-06-26  5:14                       ` Nathan Chancellor
2019-06-25 20:09                 ` Kees Cook
2019-06-26  8:06               ` Peter Zijlstra
2019-06-25  7:15         ` Peter Zijlstra
2019-07-25 16:27 ` [tip:perf/urgent] " tip-bot for Gustavo A. R. Silva
2019-07-25 17:06   ` Borislav Petkov
2019-07-25 17:35     ` Peter Zijlstra
2019-07-25 23:18       ` Joe Perches
2019-07-25 23:28         ` Kees Cook

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=alpine.DEB.2.21.1906270043480.32342@nanos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=chandlerc@google.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=craig.topper@intel.com \
    --cc=gustavo@embeddedor.com \
    --cc=hpa@zytor.com \
    --cc=joe@perches.com \
    --cc=jolsa@redhat.com \
    --cc=jpoimboe@redhat.com \
    --cc=kan.liang@linux.intel.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=shawn@git.icu \
    --cc=x86@kernel.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.