Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
arch/x86/include/asm/ibt.h
- A previous rhel9 partial backport updated this file. This
commit completes the backport by adding the
tools/objtool/check.c updates.
commit e27e5bea956ce4d3eb15112de5fa5a3b77c2f488
Author: Josh Poimboeuf <jpoimboe@kernel.org>
Date: Thu Aug 18 14:39:27 2022 -0700
x86/ibt, objtool: Add IBT_NOSEAL()
Add a macro which prevents a function from getting sealed if there are
no compile-time references to it.
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Message-Id: <20220818213927.e44fmxkoq4yj6ybn@treble>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 38e0e4d04d4187c63d6b511396faae7db6a3cd9e
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Jun 28 12:57:42 2022 +0200
x86/ibt, objtool: Don't discard text references from tracepoint section
On Tue, Jun 28, 2022 at 04:28:58PM +0800, Pengfei Xu wrote:
> # ./ftracetest
> === Ftrace unit tests ===
> [1] Basic trace file check [PASS]
> [2] Basic test for tracers [PASS]
> [3] Basic trace clock test [PASS]
> [4] Basic event tracing check [PASS]
> [5] Change the ringbuffer size [PASS]
> [6] Snapshot and tracing setting [PASS]
> [7] trace_pipe and trace_marker [PASS]
> [8] Test ftrace direct functions against tracers [UNRESOLVED]
> [9] Test ftrace direct functions against kprobes [UNRESOLVED]
> [10] Generic dynamic event - add/remove eprobe events [FAIL]
> [11] Generic dynamic event - add/remove kprobe events
>
> It 100% reproduced in step 11 and then missing ENDBR BUG generated:
> "
> [ 9332.752836] mmiotrace: enabled CPU7.
> [ 9332.788612] mmiotrace: disabled.
> [ 9337.103426] traps: Missing ENDBR: syscall_regfunc+0x0/0xb0
It turns out that while syscall_regfunc() does have an ENDBR when
generated, it gets sealed by objtool's .ibt_endbr_seal list.
Since the only text references to this function:
$ git grep syscall_regfunc
include/linux/tracepoint.h:extern int syscall_regfunc(void);
include/trace/events/syscalls.h: syscall_regfunc, syscall_unregfunc
include/trace/events/syscalls.h: syscall_regfunc, syscall_unregfunc
kernel/tracepoint.c:int syscall_regfunc(void)
appear in the __tracepoint section which is excluded by objtool.
Fixes: 3c6f9f77e618 ("objtool: Rework ibt and extricate from stack validation")
Reported-by: Pengfei Xu <pengfei.xu@intel.com
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/Yrrepdaow4F5kqG0@hirez.programming.kicks-ass.net
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 22682a07acc308ef78681572e19502ce8893c4d4
Author: Mikulas Patocka <mpatocka@redhat.com>
Date: Mon May 16 11:06:36 2022 -0400
objtool: Fix objtool regression on x32 systems
Commit c087c6e7b551 ("objtool: Fix type of reloc::addend") failed to
appreciate cross building from ILP32 hosts, where 'int' == 'long' and
the issue persists.
As such, use s64/int64_t/Elf64_Sxword for this field and suffer the
pain that is ISO C99 printf formats for it.
Fixes: c087c6e7b551 ("objtool: Fix type of reloc::addend")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
[peterz: reword changelog, s/long long/s64/]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/alpine.LRH.2.02.2205161041260.11556@file01.intranet.prod.int.rdu2.redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 5141d3a06b2da1731ac82091298b766a1f95d3d8
Author: Sami Tolvanen <samitolvanen@google.com>
Date: Thu Sep 8 14:54:58 2022 -0700
objtool: Preserve special st_shndx indexes in elf_update_symbol
elf_update_symbol fails to preserve the special st_shndx values
between [SHN_LORESERVE, SHN_HIRESERVE], which results in it
converting SHN_ABS entries into SHN_UNDEF, for example. Explicitly
check for the special indexes and ensure these symbols are not
marked undefined.
Fixes: ead165fa1042 ("objtool: Fix symbol creation")
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20220908215504.3686827-17-samitolvanen@google.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit ead165fa1042247b033afad7be4be9b815d04ade
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue May 17 17:42:04 2022 +0200
objtool: Fix symbol creation
Nathan reported objtool failing with the following messages:
warning: objtool: no non-local symbols !?
warning: objtool: gelf_update_symshndx: invalid section index
The problem is due to commit 4abff6d48dbc ("objtool: Fix code relocs
vs weak symbols") failing to consider the case where an object would
have no non-local symbols.
The problem that commit tries to address is adding a STB_LOCAL symbol
to the symbol table in light of the ELF spec's requirement that:
In each symbol table, all symbols with STB_LOCAL binding preced the
weak and global symbols. As ``Sections'' above describes, a symbol
table section's sh_info section header member holds the symbol table
index for the first non-local symbol.
The approach taken is to find this first non-local symbol, move that
to the end and then re-use the freed spot to insert a new local symbol
and increment sh_info.
Except it never considered the case of object files without global
symbols and got a whole bunch of details wrong -- so many in fact that
it is a wonder it ever worked :/
Specifically:
- It failed to re-hash the symbol on the new index, so a subsequent
find_symbol_by_index() would not find it at the new location and a
query for the old location would now return a non-deterministic
choice between the old and new symbol.
- It failed to appreciate that the GElf wrappers are not a valid disk
format (it works because GElf is basically Elf64 and we only
support x86_64 atm.)
- It failed to fully appreciate how horrible the libelf API really is
and got the gelf_update_symshndx() call pretty much completely
wrong; with the direct consequence that if inserting a second
STB_LOCAL symbol would require moving the same STB_GLOBAL symbol
again it would completely come unstuck.
Write a new elf_update_symbol() function that wraps all the magic
required to update or create a new symbol at a given index.
Specifically, gelf_update_sym*() require an @ndx argument that is
relative to the @data argument; this means you have to manually
iterate the section data descriptor list and update @ndx.
Fixes: 4abff6d48dbc ("objtool: Fix code relocs vs weak symbols")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Cc: <stable@vger.kernel.org>
Link: https://lkml.kernel.org/r/YoPCTEYjoPqE4ZxB@hirez.programming.kicks-ass.net
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 4bc78005887f6fca60b624822943708652fda01a
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date: Wed May 11 16:37:50 2022 +0800
objtool: Remove libsubcmd.a when make clean
The file libsubcmd.a still exists after make clean, remove it.
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/1652258270-6278-3-git-send-email-yangtiezhu@loongson.cn
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit f193c32cad2ddc79ad55a2e2fb3bc35e7d92946a
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date: Wed May 11 16:37:49 2022 +0800
objtool: Remove inat-tables.c when make clean
When build objtool on x86, the generated file inat-tables.c is in
arch/x86/lib instead of arch/x86, use the correct dir to remove it
when make clean.
$ cd tools/objtool
$ make
[...]
GEN arch/x86/lib/inat-tables.c
[...]
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Link: https://lore.kernel.org/r/1652258270-6278-2-git-send-email-yangtiezhu@loongson.cn
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit a8e35fece49b16b20de000aab687ca075e4463af
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:44 2022 -0700
objtool: Update documentation
The objtool documentation is very stack validation centric. Broaden the
documentation and describe all the features objtool supports.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/b6a84d301d9f73ec6725752654097f4e31fa1b69.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
scripts/Makefile.build
- rhel9 doesn't have d31ed5d767c0 ("kbuild: Fixup the IBT kbuild
changes")
commit 753da4179d08b625d8df72e97724e22749969fd3
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:43 2022 -0700
objtool: Remove --lto and --vmlinux in favor of --link
The '--lto' option is a confusing way of telling objtool to do stack
validation despite it being a linked object. It's no longer needed now
that an explicit '--stackval' option exists. The '--vmlinux' option is
also redundant.
Remove both options in favor of a straightforward '--link' option which
identifies a linked object.
Also, implicitly set '--link' with a warning if the user forgets to do
so and we can tell that it's a linked object. This makes it easier for
manual vmlinux runs.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/dcd3ceffd15a54822c6183e5766d21ad06082b45.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
lib/Kconfig.debug
- rhel9 doesn't have upstream bece04b5b41d ("kcov: fix generic
Kconfig dependencies if ARCH_WANTS_NO_INSTR")
lib/Kconfig.kcsan
- rhel9 doesn't have upstream 69562e4983d9 ("kcsan: Add core
support for a subset of weak memory modeling"), so can't
update KCSAN_WEAK_MEMORY dependencies
commit 22102f4559beaabcea614b29ee090c6a214f002f
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:40 2022 -0700
objtool: Make noinstr hacks optional
Objtool has some hacks in place to workaround toolchain limitations
which otherwise would break no-instrumentation rules. Make the hacks
explicit (and optional for other arches) by turning it into a cmdline
option and kernel config option.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/b326eeb9c33231b9dfbb925f194ed7ee40edcd7c.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 4ab7674f5951ac6a8ac4fa8828090edb64a4771f
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:39 2022 -0700
objtool: Make jump label hack optional
Objtool secretly does a jump label hack to overcome the limitations of
the toolchain. Make the hack explicit (and optional for other arches)
by turning it into a cmdline option and kernel config option.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/3bdcbfdd27ecb01ddec13c04bdf756a583b13d24.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
scripts/Makefile.build
tools/objtool/builtin-check.c
tools/objtool/include/objtool/builtin.h
- (diff context) rhel9 already has upstream f43b9876e857
("x86/retbleed: Add fine grained Kconfig knobs"), which added
--rethunk option
commit 26e176896a5bb9222ae3433da902edd2566a61a4
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:38 2022 -0700
objtool: Make static call annotation optional
As part of making objtool more modular, put the existing static call
code behind a new '--static-call' option.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/d59ac57ef3d6d8380cdce20322314c9e2e556750.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 72064474964724c59ddff58a581a31b1ede75cf9
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:37 2022 -0700
objtool: Make stack validation frame-pointer-specific
Now that CONFIG_STACK_VALIDATION is frame-pointer specific, do the same
for the '--stackval' option. Now the '--no-fp' option is redundant and
can be removed.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/f563fa064b3b63d528de250c72012d49e14742a3.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit c2bdd61c98d915ad2cc1f8cd4661fcda1f1e4c16
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:35 2022 -0700
objtool: Extricate sls from stack validation
Extricate sls functionality from validate_branch() so they can be
executed (or ported) independently from each other.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/2545c86ffa5f27497f0d0c542540ad4a4be3c5a5.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 3c6f9f77e6188ca4d283633d66e91b3821a505ae
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:34 2022 -0700
objtool: Rework ibt and extricate from stack validation
Extricate ibt from validate_branch() so they can be executed (or ported)
independently from each other.
While shuffling code around, simplify and improve the ibt logic:
- Ignore an explicit list of known sections which reference functions
for reasons other than indirect branching to them. This helps prevent
unnnecesary sealing.
- Warn on missing !ENDBR for all other sections, not just .data and
.rodata. This finds additional warnings, because there are sections
other than .[ro]data which reference function pointers. For example,
the ksymtab sections which are used for exporting symbols.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/fd1435e46bb95f81031b8fb1fa360f5f787e4316.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 7dce62041ac34b613a5ed1bd937117e492e06dc8
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:33 2022 -0700
objtool: Make stack validation optional
Make stack validation an explicit cmdline option so that individual
objtool features can be enabled individually by other arches.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/52da143699574d756e65ca4c9d4acaffe9b0fe5f.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
squash with 3158d8573495d
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 99c0beb547a3e0ec3a63edeba0960c6ddf2226b0
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:31 2022 -0700
objtool: Add option to print section addresses
To help prevent objtool users from having to do math to convert function
addresses to section addresses, and to help out with finding data
addresses reported by IBT validation, add an option to print the section
address in addition to the function address.
Normal:
vmlinux.o: warning: objtool: fixup_exception()+0x2d1: unreachable instruction
With '--sec-address':
vmlinux.o: warning: objtool: fixup_exception()+0x2d1 (.text+0x76c51): unreachable instruction
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/2cea4d5299d53d1a4c09212a6ad7820aa46fda7a.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 2bc3dec7055e34c2c2e497f109da6748544c0791
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:28 2022 -0700
objtool: Don't print parentheses in function addresses
The parentheses in the "func()+off" address output are inconsistent with
how the kernel prints function addresses, breaking Peter's scripts.
Remove them.
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/f2bec70312f62ef4f1ea21c134d9def627182ad3.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
scripts/Makefile.build
tools/objtool/builtin-check.c
tools/objtool/include/objtool/builtin.h
- (diff context) rhel9 already has upstream f43b9876e857
("x86/retbleed: Add fine grained Kconfig knobs"),
which added --rethunk option and CONFIG_RETHUNK
commit b51277eb9775ce916f9efd2c51533e481180c1e8
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:27 2022 -0700
objtool: Ditch subcommands
Objtool has a fairly singular focus. It runs on object files and does
validations and transformations which can be combined in various ways.
The subcommand model has never been a good fit, making it awkward to
combine and remove options.
Remove the "check" and "orc" subcommands in favor of a more traditional
cmdline option model. This makes it much more flexible to use, and
easier to port individual features to other arches.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/5c61ebf805e90aefc5fa62bc63468ffae53b9df6.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
scripts/Makefile.build
- rhel9 already has CONFIG_RETHUNK from upstream f43b9876e857
("x86/retbleed: Add fine grained Kconfig knobs")
tools/objtool/builtin-check.c
- rhel9 already has upstream f43b9876e857 ("x86/retbleed: Add fine
grained Kconfig knobs"), which added --rethunk option
tools/objtool/check.c
tools/objtool/include/objtool/builtin.h
- rhel9 already has upstream f43b9876e857 ("x86/retbleed: Add fine
grained Kconfig knobs"), account for rethunk code
commit 2daf7faba7ded8703e4b4ebc8b161f22272fc91a
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:26 2022 -0700
objtool: Reorganize cmdline options
Split the existing options into two groups: actions, which actually do
something; and options, which modify the actions in some way.
Also there's no need to have short flags for all the non-action options.
Reserve short flags for the more important actions.
While at it:
- change a few of the short flags to be more intuitive
- make option descriptions more consistently descriptive
- sort options in the source like they are when printed
- move options to a global struct
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/9dcaa752f83aca24b1b21f0b0eeb28a0c181c0b0.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 4baae989e638e9bf4b7d29bc5e36b581fddcca52
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 18 09:50:29 2022 -0700
objtool: Print data address for "!ENDBR" data warnings
When a "!ENDBR" warning is reported for a data section, objtool just
prints the text address of the relocation target twice, without giving
any clues about the location of the original data reference:
vmlinux.o: warning: objtool: dcbnl_netdevice_event()+0x0: .text+0xb64680: data relocation to !ENDBR: dcbnl_netdevice_event+0x0
Instead, print the address of the data reference, in addition to the
address of the relocation target.
vmlinux.o: warning: objtool: dcbnl_nb+0x0: .data..read_mostly+0xe260: data relocation to !ENDBR: dcbnl_netdevice_event+0x0
Fixes: 89bc853eae4a ("objtool: Find unused ENDBR instructions")
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/762e88d51300e8eaf0f933a5b0feae20ac033bea.1650300597.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit d4e5268a08b211b536fed29beb24271ecd85187e
Author: Peter Zijlstra <peterz@infradead.org>
Date: Fri Apr 8 11:45:55 2022 +0200
x86,objtool: Mark cpu_startup_entry() __noreturn
GCC-8 isn't clever enough to figure out that cpu_start_entry() is a
noreturn while objtool is. This results in code after the call in
start_secondary(). Give GCC a hand so that they all agree on things.
vmlinux.o: warning: objtool: start_secondary()+0x10e: unreachable
Reported-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220408094718.383658532@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit c087c6e7b551b7f208c0b852304f044954cf2bb3
Author: Peter Zijlstra <peterz@infradead.org>
Date: Sun Apr 17 17:03:40 2022 +0200
objtool: Fix type of reloc::addend
Elf{32,64}_Rela::r_addend is of type: Elf{32,64}_Sword, that means
that our reloc::addend needs to be long or face tuncation issues when
we do elf_rebuild_reloc_section():
- 107: 48 b8 00 00 00 00 00 00 00 00 movabs $0x0,%rax 109: R_X86_64_64 level4_kernel_pgt+0x80000067
+ 107: 48 b8 00 00 00 00 00 00 00 00 movabs $0x0,%rax 109: R_X86_64_64 level4_kernel_pgt-0x7fffff99
Fixes: 627fce1480 ("objtool: Add ORC unwind table generation")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20220419203807.596871927@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 4abff6d48dbcea8200c7ea35ba70c242d128ebf3
Author: Peter Zijlstra <peterz@infradead.org>
Date: Sun Apr 17 17:03:36 2022 +0200
objtool: Fix code relocs vs weak symbols
Occasionally objtool driven code patching (think .static_call_sites
.retpoline_sites etc..) goes sideways and it tries to patch an
instruction that doesn't match.
Much head-scatching and cursing later the problem is as outlined below
and affects every section that objtool generates for us, very much
including the ORC data. The below uses .static_call_sites because it's
convenient for demonstration purposes, but as mentioned the ORC
sections, .retpoline_sites and __mount_loc are all similarly affected.
Consider:
foo-weak.c:
extern void __SCT__foo(void);
__attribute__((weak)) void foo(void)
{
return __SCT__foo();
}
foo.c:
extern void __SCT__foo(void);
extern void my_foo(void);
void foo(void)
{
my_foo();
return __SCT__foo();
}
These generate the obvious code
(gcc -O2 -fcf-protection=none -fno-asynchronous-unwind-tables -c foo*.c):
foo-weak.o:
0000000000000000 <foo>:
0: e9 00 00 00 00 jmpq 5 <foo+0x5> 1: R_X86_64_PLT32 __SCT__foo-0x4
foo.o:
0000000000000000 <foo>:
0: 48 83 ec 08 sub $0x8,%rsp
4: e8 00 00 00 00 callq 9 <foo+0x9> 5: R_X86_64_PLT32 my_foo-0x4
9: 48 83 c4 08 add $0x8,%rsp
d: e9 00 00 00 00 jmpq 12 <foo+0x12> e: R_X86_64_PLT32 __SCT__foo-0x4
Now, when we link these two files together, you get something like
(ld -r -o foos.o foo-weak.o foo.o):
foos.o:
0000000000000000 <foo-0x10>:
0: e9 00 00 00 00 jmpq 5 <foo-0xb> 1: R_X86_64_PLT32 __SCT__foo-0x4
5: 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:0x0(%rax,%rax,1)
f: 90 nop
0000000000000010 <foo>:
10: 48 83 ec 08 sub $0x8,%rsp
14: e8 00 00 00 00 callq 19 <foo+0x9> 15: R_X86_64_PLT32 my_foo-0x4
19: 48 83 c4 08 add $0x8,%rsp
1d: e9 00 00 00 00 jmpq 22 <foo+0x12> 1e: R_X86_64_PLT32 __SCT__foo-0x4
Noting that ld preserves the weak function text, but strips the symbol
off of it (hence objdump doing that funny negative offset thing). This
does lead to 'interesting' unused code issues with objtool when ran on
linked objects, but that seems to be working (fingers crossed).
So far so good.. Now lets consider the objtool static_call output
section (readelf output, old binutils):
foo-weak.o:
Relocation section '.rela.static_call_sites' at offset 0x2c8 contains 1 entry:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000000000000 0000000200000002 R_X86_64_PC32 0000000000000000 .text + 0
0000000000000004 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1
foo.o:
Relocation section '.rela.static_call_sites' at offset 0x310 contains 2 entries:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000000000000 0000000200000002 R_X86_64_PC32 0000000000000000 .text + d
0000000000000004 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1
foos.o:
Relocation section '.rela.static_call_sites' at offset 0x430 contains 4 entries:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000000000000 0000000100000002 R_X86_64_PC32 0000000000000000 .text + 0
0000000000000004 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1
0000000000000008 0000000100000002 R_X86_64_PC32 0000000000000000 .text + 1d
000000000000000c 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1
So we have two patch sites, one in the dead code of the weak foo and one
in the real foo. All is well.
*HOWEVER*, when the toolchain strips unused section symbols it
generates things like this (using new enough binutils):
foo-weak.o:
Relocation section '.rela.static_call_sites' at offset 0x2c8 contains 1 entry:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000000000000 0000000200000002 R_X86_64_PC32 0000000000000000 foo + 0
0000000000000004 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1
foo.o:
Relocation section '.rela.static_call_sites' at offset 0x310 contains 2 entries:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000000000000 0000000200000002 R_X86_64_PC32 0000000000000000 foo + d
0000000000000004 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1
foos.o:
Relocation section '.rela.static_call_sites' at offset 0x430 contains 4 entries:
Offset Info Type Symbol's Value Symbol's Name + Addend
0000000000000000 0000000100000002 R_X86_64_PC32 0000000000000000 foo + 0
0000000000000004 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1
0000000000000008 0000000100000002 R_X86_64_PC32 0000000000000000 foo + d
000000000000000c 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1
And now we can see how that foos.o .static_call_sites goes side-ways, we
now have _two_ patch sites in foo. One for the weak symbol at foo+0
(which is no longer a static_call site!) and one at foo+d which is in
fact the right location.
This seems to happen when objtool cannot find a section symbol, in which
case it falls back to any other symbol to key off of, however in this
case that goes terribly wrong!
As such, teach objtool to create a section symbol when there isn't
one.
Fixes: 44f6a7c075 ("objtool: Fix seg fault with Clang non-section symbols")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20220419203807.655552918@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 08feafe8d1958febf3a9733a3d1564d8fc23340e
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 11 16:10:32 2022 -0700
objtool: Fix function fallthrough detection for vmlinux
Objtool's function fallthrough detection only works on C objects.
The distinction between C and assembly objects no longer makes sense
with objtool running on vmlinux.o.
Now that copy_user_64.S has been fixed up, and an objtool sibling call
detection bug has been fixed, the asm code is in "compliance" and this
hack is no longer needed. Remove it.
Fixes: ed53a0d97192 ("x86/alternative: Use .ibt_endbr_seal to seal indirect calls")
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/b434cff98eca3a60dcc64c620d7d5d405a0f441c.1649718562.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
tools/objtool/check.c
- Merge conflict introduced when rhel9 backported a149180fbcf3
("x86: Add magic AMD return-thunk")
commit 34c861e806478ac2ea4032721defbf1d6967df08
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 11 16:10:31 2022 -0700
objtool: Fix sibling call detection in alternatives
In add_jump_destinations(), sibling call detection requires 'insn->func'
to be valid. But alternative instructions get their 'func' set in
handle_group_alt(), which runs *after* add_jump_destinations(). So
sibling calls in alternatives code don't get properly detected.
Fix that by changing the initialization order: call
add_special_section_alts() *before* add_jump_destinations().
This also means the special case for a missing 'jump_dest' in
add_jump_destinations() can be removed, as it has already been dealt
with.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/c02e0a0a2a4286b5f848d17c77fdcb7e0caf709c.1649718562.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
tools/objtool/check.c
- Merge conflict introduced when rhel9 backported a149180fbcf3
("x86: Add magic AMD return-thunk")
commit 26ff604102c98df79c3fe2614d1b9bb068d4c28c
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Mon Apr 11 16:10:30 2022 -0700
objtool: Don't set 'jump_dest' for sibling calls
For most sibling calls, 'jump_dest' is NULL because objtool treats the
jump like a call and sets 'call_dest'. But there are a few edge cases
where that's not true. Make it consistent to avoid unexpected behavior.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/8737d6b9d1691831aed73375f444f0f42da3e2c9.1649718562.git.jpoimboe@redhat.com
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit d139bca4b824ffb9731763c31b271a24b595948a
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Mar 22 12:33:31 2022 +0100
objtool: Fix IBT tail-call detection
Objtool reports:
arch/x86/crypto/poly1305-x86_64.o: warning: objtool: poly1305_blocks_avx() falls through to next function poly1305_blocks_x86_64()
arch/x86/crypto/poly1305-x86_64.o: warning: objtool: poly1305_emit_avx() falls through to next function poly1305_emit_x86_64()
arch/x86/crypto/poly1305-x86_64.o: warning: objtool: poly1305_blocks_avx2() falls through to next function poly1305_blocks_x86_64()
Which reads like:
0000000000000040 <poly1305_blocks_x86_64>:
40: f3 0f 1e fa endbr64
...
0000000000000400 <poly1305_blocks_avx>:
400: f3 0f 1e fa endbr64
404: 44 8b 47 14 mov 0x14(%rdi),%r8d
408: 48 81 fa 80 00 00 00 cmp $0x80,%rdx
40f: 73 09 jae 41a <poly1305_blocks_avx+0x1a>
411: 45 85 c0 test %r8d,%r8d
414: 0f 84 2a fc ff ff je 44 <poly1305_blocks_x86_64+0x4>
...
These are simple conditional tail-calls and *should* be recognised as
such by objtool, however due to a mistake in commit 08f87a93c8ec
("objtool: Validate IBT assumptions") this is failing.
Specifically, the jump_dest is +4, this means the instruction pointed
at will not be ENDBR and as such it will fail the second clause of
is_first_func_insn() that was supposed to capture this exact case.
Instead, have is_first_func_insn() look at the previous instruction.
Fixes: 08f87a93c8ec ("objtool: Validate IBT assumptions")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220322115125.811582125@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
tools/counter/Makefile
tools/tracing/rtla/Makefile
- These do not exist in rhel9
commit 5c8166419acf468b5bc3e48f928a040485d3e0c2
Author: Masahiro Yamada <masahiroy@kernel.org>
Date: Fri Feb 11 14:14:11 2022 +0900
kbuild: replace $(if A,A,B) with $(or A,B)
$(or ...) is available since GNU Make 3.81, and useful to shorten the
code in some places.
Covert as follows:
$(if A,A,B) --> $(or A,B)
This patch also converts:
$(if A, A, B) --> $(or A, B)
Strictly speaking, the latter is not an equivalent conversion because
GNU Make keeps spaces after commas; if A is not empty, $(if A, A, B)
expands to " A", while $(or A, B) expands to "A".
Anyway, preceding spaces are not significant in the code hunks I touched.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
tools/objtool/check.c
- rhel9 backport of upstream d9e9d2300681 ("x86,objtool: Create
.return_sites") already added a call to
create_return_sites_sections() and placed it after the mcount check.
Move it to before the mcount check to align better with upstream.
commit 89bc853eae4ad125030ef99f207ba76c2f00a26e
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Mar 8 16:30:55 2022 +0100
objtool: Find unused ENDBR instructions
Find all ENDBR instructions which are never referenced and stick them
in a section such that the kernel can poison them, sealing the
functions from ever being an indirect call target.
This removes about 1-in-4 ENDBR instructions.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154319.763643193@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
tools/objtool/builtin-check.c
tools/objtool/include/objtool/builtin.h
- rhel9 already contains backport of upstream f43b9876e857
("x86/retbleed: Add fine grained Kconfig knobs"), which added
rethunk option
tools/objtool/check.c
- rhel9 already contains upstream 8faea26e6111 ("objtool: Re-add
UNWIND_HINT_{SAVE_RESTORE}"), which added save and restore
checks to read_unwind_hints()
- rhel9 already contains upstream d9e9d2300681 ("x86,objtool:
Create .return_sites"), changing the diff context when adding
same_function() and is_first_func_insn()
commit 08f87a93c8ec709698edba66a5167077181fc978
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Mar 8 16:30:54 2022 +0100
objtool: Validate IBT assumptions
Intel IBT requires that every indirect JMP/CALL targets an ENDBR
instructions, failing this #CP happens and we die. Similarly, all
exception entries should be ENDBR.
Find all code relocations and ensure they're either an ENDBR
instruction or ANNOTATE_NOENDBR. For the exceptions look for
UNWIND_HINT_IRET_REGS at sym+0 not being ENDBR.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154319.705110141@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 7d209d13e7c3a3d60dc262f11a8ae4e6b4454d30
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Mar 8 16:30:53 2022 +0100
objtool: Add IBT/ENDBR decoding
Intel IBT requires the target of any indirect CALL or JMP instruction
to be the ENDBR instruction; optionally it allows those two
instructions to have a NOTRACK prefix in order to avoid this
requirement.
The kernel will not enable the use of NOTRACK, as such any occurence
of it in compiler generated code should be flagged.
Teach objtool to Decode ENDBR instructions and WARN about NOTRACK
prefixes.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154319.645963517@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
tools/objtool/include/objtool/check.h
- rhel9 already contains upstream 8faea26e6111 ("objtool: Re-add
UNWIND_HINT_{SAVE_RESTORE}"), which added save and restore
values to struct instruction
commit 96db4a988d653a7f18b518c25367f7bf238f4667
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Mar 8 16:30:52 2022 +0100
objtool: Read the NOENDBR annotation
Read the new NOENDBR annotation. While there, attempt to not bloat
struct instruction.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154319.586815435@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 0e5b613b4d4be3345dda349fb90dd73d2103302f
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Mar 8 16:30:49 2022 +0100
objtool: Rework ASM_REACHABLE
Currently ASM_REACHABLE only works for UD2 instructions; reorder
things to also allow over-riding dead_end_function().
To that end:
- Mark INSN_BUG instructions in decode_instructions(), this saves
having to iterate all instructions yet again.
- Have add_call_destinations() set insn->dead_end for
dead_end_function() calls.
- Move add_dead_ends() *after* add_call_destinations() such that
ASM_REACHABLE can clear the ->dead_end mark.
- have validate_branch() only check ->dead_end.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154319.410010807@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 4adb23686795e9c88e3217b5d7b4524c0da9d04f
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Mar 8 16:30:46 2022 +0100
objtool: Ignore extra-symbol code
There's a fun implementation detail on linking STB_WEAK symbols. When
the linker combines two translation units, where one contains a weak
function and the other an override for it. It simply strips the
STB_WEAK symbol from the symbol table, but doesn't actually remove the
code.
The result is that when objtool is ran in a whole-archive kind of way,
it will encounter *heaps* of unused (and unreferenced) code. All
rudiments of weak functions.
Additionally, when a weak implementation is split into a .cold
subfunction that .cold symbol is left in place, even though completely
unused.
Teach objtool to ignore such rudiments by searching for symbol holes;
that is, code ranges that fall outside the given symbol bounds.
Specifically, ignore a sequence of unreachable instruction iff they
occupy a single hole, additionally ignore any .cold subfunctions
referenced.
Both ld.bfd and ld.lld behave like this. LTO builds otoh can (and do)
properly DCE weak functions.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154319.232019347@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
Conflicts:
tools/objtool/builtin-check.c
tools/objtool/include/objtool/builtin.h
- rhel9 already contains backport of upstream f43b9876e857
("x86/retbleed: Add fine grained Kconfig knobs"), which added
rethunk option
commit 53f7109ef957315ab53205ba3a3f4f48874c0428
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Mar 8 16:30:45 2022 +0100
objtool: Rename --duplicate to --lto
In order to prepare for LTO like objtool runs for modules, rename the
duplicate argument to lto.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154319.172584233@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 5cff2086b01526b8c7deacc86473ffbab0cddfa9
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Mar 8 16:30:16 2022 +0100
objtool: Have WARN_FUNC fall back to sym+off
Currently WARN_FUNC() either prints func+off and failing that prints
sec+off, add an intermediate sym+off. This is useful when playing
around with entry code.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154317.461283840@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 1ffbe4e935f9b7308615c75be990aec07464d1e7
Author: Peter Zijlstra <peterz@infradead.org>
Date: Tue Mar 8 16:30:14 2022 +0100
objtool: Default ignore INT3 for unreachable
Ignore all INT3 instructions for unreachable code warnings, similar to NOP.
This allows using INT3 for various paddings instead of NOPs.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154317.343312938@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 0509811952e41ad1e04c50d2378078250b6b7be3
Author: Marco Elver <elver@google.com>
Date: Tue Nov 30 12:44:31 2021 +0100
objtool, kcsan: Remove memory barrier instrumentation from noinstr
Teach objtool to turn instrumentation required for memory barrier
modeling into nops in noinstr text.
The __tsan_func_entry/exit calls are still emitted by compilers even
with the __no_sanitize_thread attribute. The memory barrier
instrumentation will be inserted explicitly (without compiler help), and
thus needs to also explicitly be removed.
Signed-off-by: Marco Elver <elver@google.com>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 0525bd82f6a9b5860ed3ea53520ac11ebfa09d5b
Author: Marco Elver <elver@google.com>
Date: Tue Nov 30 12:44:30 2021 +0100
objtool, kcsan: Add memory barrier instrumentation to whitelist
Adds KCSAN's memory barrier instrumentation to objtool's uaccess
whitelist.
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 9af9dcf11bda3e2c0e24c1acaacb8685ad974e93
Author: Peter Zijlstra <peterz@infradead.org>
Date: Thu Jun 24 11:41:00 2021 +0200
x86/xen: Mark cpu_bringup_and_idle() as dead_end_function
The asm_cpu_bringup_and_idle() function is required to push the return
value on the stack in order to make ORC happy, but the only reason
objtool doesn't complain is because of a happy accident.
The thing is that asm_cpu_bringup_and_idle() doesn't return, so
validate_branch() never terminates and falls through to the next
function, which in the normal case is the hypercall_page. And that, as
it happens, is 4095 NOPs and a RET.
Make asm_cpu_bringup_and_idle() terminate on it's own, by making the
function it calls as a dead-end. This way we no longer rely on what
code happens to come after.
Fixes: c3881eb58d ("x86/xen: Make the secondary CPU idle tasks reliable")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Link: https://lore.kernel.org/r/20210624095147.693801717@infradead.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit 86e1e054e0d2105cf32b0266cf1a64e6c26424f7
Author: Michael Forney <mforney@mforney.org>
Date: Sat May 8 17:01:03 2021 -0700
objtool: Update section header before relocations
The libelf implementation from elftoolchain has a safety check in
gelf_update_rel[a] to check that the data corresponds to a section
that has type SHT_REL[A] [0]. If the relocation is updated before
the section header is updated with the proper type, this check
fails.
To fix this, update the section header first, before the relocations.
Previously, the section size was calculated in elf_rebuild_reloc_section
by counting the number of entries in the reloc_list. However, we
now need the size during elf_write so instead keep a running total
and add to it for every new relocation.
[0] https://sourceforge.net/p/elftoolchain/mailman/elftoolchain-developers/thread/CAGw6cBtkZro-8wZMD2ULkwJ39J+tHtTtAWXufMjnd3cQ7XG54g@mail.gmail.com/
Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20210509000103.11008-2-mforney@mforney.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2121207
commit b46179d6bb3182c020f2bf9bb4df6ba5463b0495
Author: Michael Forney <mforney@mforney.org>
Date: Sat May 8 17:01:02 2021 -0700
objtool: Check for gelf_update_rel[a] failures
Otherwise, if these fail we end up with garbage data in the
.rela.orc_unwind_ip section, leading to errors like
ld: fs/squashfs/namei.o: bad reloc symbol index (0x7f16 >= 0x12) for offset 0x7f16d5c82cc8 in section `.orc_unwind_ip'
Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20210509000103.11008-1-mforney@mforney.org
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>