Re: [PATCH v4 00/63] objtool,livepatch: klp-build livepatch module generation

2025-09-18 Thread Josh Poimboeuf
On Wed, Sep 17, 2025 at 09:03:08AM -0700, Josh Poimboeuf wrote: > Changes since v3 > (https://lore.kernel.org/cover.1750980516.git.jpoim...@kernel.org): > > - Get rid of the SHF_MERGE+SHF_WRITE toolchain shenanigans in favor of > simple .discard.annotate_data annotations &g

[PATCH v4.1 12/63] interval_tree: Fix ITSTATIC usage for *_subtree_search()

2025-09-18 Thread Josh Poimboeuf
For consistency with the other function templates, change _subtree_search_*() to use the user-supplied ITSTATIC rather than the hard-coded 'static'. Signed-off-by: Josh Poimboeuf --- v4.1: Fixed a couple more INTERVAL_TREE_DEFINE usages. drivers/infiniband/hw/usnic/usnic_uiom_inter

Re: [PATCH v2 6/6] unwind: arm64: Add reliable stacktrace with sframe unwinder.

2025-09-17 Thread Josh Poimboeuf
code have correct cfi/sframe metadata? In order for it to be "reliable", we need to know the unwind reached the end of the stack (e.g., the task pt_regs frame, from entry-from-user). -- Josh

[PATCH v4 21/63] objtool: Fix __pa_symbol() relocation handling

2025-09-17 Thread Josh Poimboeuf
__pa_symbol() generates a relocation which refers to a physical address. Convert it to back its virtual form before calculating the addend. Signed-off-by: Josh Poimboeuf --- tools/objtool/arch/x86/decode.c | 13 - 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools

[PATCH v4 39/63] objtool: Generalize elf_create_symbol()

2025-09-17 Thread Josh Poimboeuf
diff code. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 111 +++- tools/objtool/include/objtool/elf.h | 11 ++- 2 files changed, 69 insertions(+), 53 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index c35726a47c07c

[PATCH v4 54/63] objtool: Refactor prefix symbol creation code

2025-09-17 Thread Josh Poimboeuf
The prefix symbol creation code currently ignores all errors, presumably because some functions don't have the leading NOPs. Shuffle the code around a bit, improve the error handling and document why some errors are ignored. Signed-off-by: Josh Poimboeuf --- tools/objtool/ch

[PATCH v4 49/63] objtool/klp: Add --checksum option to generate per-function checksums

2025-09-17 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, add a command-line option to generate a unique checksum for each function. This will enable detection of functions which have changed between two versions of an object file. Signed-off-by: Josh Poimboeuf --- tools/objtool/Makefile

[PATCH v4 43/63] objtool: Add elf_create_file()

2025-09-17 Thread Josh Poimboeuf
Add interface to enable the creation of a new ELF file. Signed-off-by: Josh Poimboeuf --- tools/objtool/builtin-check.c | 2 +- tools/objtool/elf.c | 144 +++- tools/objtool/include/objtool/elf.h | 5 +- 3 files changed, 147 insertions(+), 4

[PATCH v4 61/63] livepatch/klp-build: Add --debug option to show cloning decisions

2025-09-17 Thread Josh Poimboeuf
Add a --debug option which gets passed to "objtool klp diff" to enable debug output related to cloning decisions. Signed-off-by: Josh Poimboeuf --- scripts/livepatch/klp-build | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/livepatch/k

[PATCH v4 60/63] livepatch/klp-build: Introduce klp-build script for generating livepatch modules

2025-09-17 Thread Josh Poimboeuf
livepatch module (aka work around linker wreckage) using 'objtool klp post-link'. Signed-off-by: Josh Poimboeuf --- scripts/Makefile.lib | 1 + scripts/livepatch/fix-patch-lines | 2 +- scripts/livepatch/klp-build | 743 ++ tool

[PATCH v4 59/63] livepatch/klp-build: Add stub init code for livepatch modules

2025-09-17 Thread Josh Poimboeuf
Add a module initialization stub which can be linked with binary diff objects to produce a livepatch module. Signed-off-by: Josh Poimboeuf --- scripts/livepatch/init.c | 108 +++ 1 file changed, 108 insertions(+) create mode 100644 scripts/livepatch/init.c

[PATCH v4 56/63] livepatch: Add CONFIG_KLP_BUILD

2025-09-17 Thread Josh Poimboeuf
In preparation for introducing klp-build, add a new CONFIG_KLP_BUILD option. The initial version will only be supported on x86-64. Signed-off-by: Josh Poimboeuf --- arch/x86/Kconfig | 1 + kernel/livepatch/Kconfig | 12 2 files changed, 13 insertions(+) diff --git a/arch

[PATCH v4 45/63] objtool: Move ANNOTATE* macros to annotate.h

2025-09-17 Thread Josh Poimboeuf
In preparation for using the objtool annotation macros in higher-level objtool.h macros like UNWIND_HINT, move them to their own file. Signed-off-by: Josh Poimboeuf --- include/linux/annotate.h | 109 +++ include/linux/objtool.h | 90

[PATCH v4 53/63] objtool/klp: Add post-link subcommand to finalize livepatch modules

2025-09-17 Thread Josh Poimboeuf
inker-compliant intermediate binary which encodes the relevant KLP section/reloc/symbol metadata. After module linking, the .ko then needs to be converted to an actual livepatch module. Introduce a new klp post-link subcommand to do so. Signed-off-by: Josh Poimboeuf --- tools/objtool/

[PATCH v4 52/63] objtool/klp: Add --debug option to show cloning decisions

2025-09-17 Thread Josh Poimboeuf
Add a --debug option to klp diff which prints cloning decisions and an indented dependency tree for all cloned symbols and relocations. This helps visualize which symbols and relocations were included and why. Signed-off-by: Josh Poimboeuf --- tools/objtool/include/objtool/warn.h | 21

[PATCH v4 51/63] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-09-17 Thread Josh Poimboeuf
ted as a reference to the next symbol, or vice versa. A potential future alternative to '-ffunction-sections -fdata-sections' would be to introduce a toolchain option that forces symbol-based (non-section) relocations. Signed-off-by: Josh Poimboeuf --- MAINTAINERS

[PATCH v4 48/63] objtool: Unify STACK_FRAME_NON_STANDARD entry sizes

2025-09-17 Thread Josh Poimboeuf
tting inline asm in a dummy function in order to pass the 'func' pointer to the asm. Signed-off-by: Josh Poimboeuf --- include/linux/objtool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/objtool.h b/include/linux/objtool.h index 4fea6a042b28f..b18ab

[PATCH v4 63/63] livepatch: Introduce source code helpers for livepatch modules

2025-09-17 Thread Josh Poimboeuf
Add some helper macros which can be used by livepatch source .patch files to register callbacks, convert static calls to regular calls where needed, and patch syscalls. Signed-off-by: Josh Poimboeuf --- include/linux/livepatch_helpers.h | 77 +++ 1 file changed, 77

[PATCH v4 62/63] livepatch/klp-build: Add --show-first-changed option to show function divergence

2025-09-17 Thread Josh Poimboeuf
the first differing instruction. This can be useful for quickly determining where and why a function changed. Signed-off-by: Josh Poimboeuf --- scripts/livepatch/klp-build | 82 +++-- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/scripts/livepatch/k

[PATCH v4 46/63] objtool: Add ANNOTATE_DATA_SPECIAL

2025-09-17 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, add an ANNOTATE_DATA_SPECIAL macro which annotates special section entries so that objtool can determine their size and location and extract them when needed. Signed-off-by: Josh Poimboeuf --- include/linux/annotate.h| 49

[PATCH v4 44/63] objtool: Add annotype() helper

2025-09-17 Thread Josh Poimboeuf
... for reading annotation types. Signed-off-by: Josh Poimboeuf --- tools/objtool/arch/loongarch/orc.c | 1 - tools/objtool/arch/powerpc/decode.c| 1 - tools/objtool/arch/x86/decode.c| 1 - tools/objtool/arch/x86/orc.c | 1 - tools/objtool/check.c

[PATCH v4 22/63] objtool: Fix "unexpected end of section" warning for alternatives

2025-09-17 Thread Josh Poimboeuf
h can trigger a confusing "unexpected end of section" warning which blames .altinstr_replacement rather than the offending fallthrough function. Fix that by not caching the section. There's no point in doing that anyway. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 5 +---

[PATCH v4 58/63] livepatch/klp-build: Introduce fix-patch-lines script to avoid __LINE__ diff noise

2025-09-17 Thread Josh Poimboeuf
: Josh Poimboeuf --- MAINTAINERS | 1 + scripts/livepatch/fix-patch-lines | 79 +++ 2 files changed, 80 insertions(+) create mode 100755 scripts/livepatch/fix-patch-lines diff --git a/MAINTAINERS b/MAINTAINERS index 605390cdfb75e..485042b545b3e

[PATCH v4 11/63] interval_tree: Sync interval_tree_generic.h with tools

2025-09-17 Thread Josh Poimboeuf
n sync going forward. Signed-off-by: Josh Poimboeuf --- tools/include/linux/interval_tree_generic.h | 8 ++-- tools/objtool/sync-check.sh | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/include/linux/interval_tree_generic.h b/tools/include/linux/int

[PATCH v4 55/63] objtool: Add base objtool support for livepatch modules

2025-09-17 Thread Josh Poimboeuf
to the IBT function pointer section whitelist. - Prevent KLP symbols from getting incorrectly classified as cold subfunctions. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 52 ++--- tools/objtool/elf.c | 5 ++- tools/objto

[PATCH v4 57/63] kbuild,objtool: Defer objtool validation step for CONFIG_KLP_BUILD

2025-09-17 Thread Josh Poimboeuf
for IBT and LTO. Eventually the per-translation-unit mode will be phased out. Signed-off-by: Josh Poimboeuf --- scripts/Makefile.lib| 2 +- scripts/link-vmlinux.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index

[PATCH v4 50/63] objtool/klp: Add --debug-checksum= to show per-instruction checksums

2025-09-17 Thread Josh Poimboeuf
Add a --debug-checksum= option to the check subcommand to print the calculated checksum of each instruction in the given functions. This is useful for determining where two versions of a function begin to diverge. Signed-off-by: Josh Poimboeuf --- tools/objtool/builtin-check.c| 6

[PATCH v4 38/63] objtool: Simplify special symbol handling in elf_update_symbol()

2025-09-17 Thread Josh Poimboeuf
!sym->sec isn't actually a thing: even STT_UNDEF and other special symbol types belong to NULL section 0. Simplify the initialization of 'shndx' accordingly. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)

[PATCH v4 41/63] objtool: Add elf_create_data()

2025-09-17 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, refactor elf_add_string() by adding a new elf_add_data() helper which allows the adding of arbitrary data to a section. Make both interfaces global so they can be used by the upcoming klp diff code. Signed-off-by: Josh Poimboeuf --- tools

[PATCH v4 40/63] objtool: Generalize elf_create_section()

2025-09-17 Thread Josh Poimboeuf
-by: Josh Poimboeuf --- tools/objtool/elf.c | 118 tools/objtool/include/objtool/elf.h | 7 +- tools/objtool/orc_gen.c | 6 +- 3 files changed, 77 insertions(+), 54 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index

[PATCH v4 47/63] x86/asm: Annotate special section entries

2025-09-17 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, add annotations for special section entries. This will enable objtool to determine the size and location of the entries and to extract them when needed. Signed-off-by: Josh Poimboeuf --- arch/x86/include/asm/alternative.h | 4 arch/x86

[PATCH v4 33/63] objtool: Avoid emptying lists for duplicate sections

2025-09-17 Thread Josh Poimboeuf
When a to-be-created section already exists, there's no point in emptying the various lists if their respective sections already exist. In fact it's better to leave them intact as they might get used later. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 4 1 file

[PATCH v4 34/63] objtool: Rename --Werror to --werror

2025-09-17 Thread Josh Poimboeuf
tool's other options. Signed-off-by: Josh Poimboeuf --- scripts/Makefile.lib | 2 +- scripts/Makefile.vmlinux_o| 2 +- tools/objtool/builtin-check.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index b955602661240..1

[PATCH v4 32/63] objtool: Simplify reloc offset calculation in unwind_read_hints()

2025-09-17 Thread Josh Poimboeuf
Simplify the relocation offset calculation in unwind_read_hints(), similar to other conversions which have already been done. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 9 + 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool

[PATCH v4 31/63] objtool: Mark prefix functions

2025-09-17 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, introduce a flag to identify __pfx_*() and __cfi_*() functions in advance so they don't need to be manually identified every time a check is needed. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 5 + tools/ob

[PATCH v4 42/63] objtool: Add elf_create_reloc() and elf_init_reloc()

2025-09-17 Thread Josh Poimboeuf
. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 170 +--- tools/objtool/include/objtool/elf.h | 9 ++ 2 files changed, 165 insertions(+), 14 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 117a1b5915a14..8d01fc3b4f679 100644

[PATCH v4 37/63] objtool: Refactor add_jump_destinations()

2025-09-17 Thread Josh Poimboeuf
The add_jump_destinations() logic is a bit weird and convoluted after being incrementally tweaked over the years. Refactor it to hopefully be more logical and straightforward. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 222 +--- tools

[PATCH v4 36/63] objtool: Reindent check_options[]

2025-09-17 Thread Josh Poimboeuf
Bring the cmdline check_options[] array back into vertical alignment for better readability. Signed-off-by: Josh Poimboeuf --- tools/objtool/builtin-check.c | 54 +-- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/tools/objtool/builtin-check.c b

[PATCH v4 26/63] objtool: Remove .parainstructions reference

2025-09-17 Thread Josh Poimboeuf
The .parainstructions section no longer exists since the following commit: 60bc276b129e ("x86/paravirt: Switch mixed paravirt/alternative calls to alternatives"). Remove the reference to it. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 1 - 1 file changed, 1 deletio

[PATCH v4 35/63] objtool: Resurrect --backup option

2025-09-17 Thread Josh Poimboeuf
ng back the old --backup option, but with the new behavior: only on warnings/errors, and print the args to make it easier to recreate. Suggested-by: Peter Zijlstra Signed-off-by: Josh Poimboeuf --- tools/objtool/builtin-check.c | 25 +++-- tools/objtool/check.c

[PATCH v4 24/63] objtool: Const string cleanup

2025-09-17 Thread Josh Poimboeuf
Use 'const char *' where applicable. Signed-off-by: Josh Poimboeuf --- tools/objtool/arch/loongarch/decode.c | 2 +- tools/objtool/arch/powerpc/decode.c | 2 +- tools/objtool/arch/x86/decode.c | 2 +- tools/objtool/elf.c | 6 +++--- tools/objtool/include/objt

[PATCH v4 30/63] objtool: Fix weak symbol hole detection for .cold functions

2025-09-17 Thread Josh Poimboeuf
uding .cold functions) so the ordering of the discovery doesn't matter. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 84 ++- tools/objtool/include/objtool/check.h | 3 +- 2 files changed, 45 insertions(+), 42 deletions(-) diff --git a/too

[PATCH v4 28/63] objtool: Add section/symbol type helpers

2025-09-17 Thread Josh Poimboeuf
Add some helper macros to improve readability. Signed-off-by: Josh Poimboeuf --- tools/objtool/arch/x86/special.c| 2 +- tools/objtool/check.c | 58 - tools/objtool/elf.c | 20 - tools/objtool/include/objtool/elf.h | 66

[PATCH v4 27/63] objtool: Convert elf iterator macros to use 'struct elf'

2025-09-17 Thread Josh Poimboeuf
'struct objtool_file' is specific to the check code and doesn't belong in the elf code which is supposed to be objtool_file-agnostic. Convert the elf iterator macros to use 'struct elf' instead. Signed-off-by: Josh Poimboeuf --- tools/objtool/c

[PATCH v4 29/63] objtool: Mark .cold subfunctions

2025-09-17 Thread Josh Poimboeuf
Introduce a flag to identify .cold subfunctions so they can be detected easier and faster. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 14 ++ tools/objtool/elf.c | 19 ++- tools/objtool/include/objtool/elf.h | 1 + 3 files

[PATCH v4 25/63] objtool: Clean up compiler flag usage

2025-09-17 Thread Josh Poimboeuf
e new warnings happy. Signed-off-by: Josh Poimboeuf --- tools/objtool/Makefile | 15 ++- tools/objtool/check.c | 4 ++-- tools/objtool/elf.c| 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index 8c20361d

[PATCH v4 23/63] objtool: Check for missing annotation entries in read_annotate()

2025-09-17 Thread Josh Poimboeuf
Add a sanity check to make sure none of the relocations for the .discard.annotate_insn section have gone missing. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 5 + 1 file changed, 5 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index bea9b124dcf48

[PATCH v4 15/63] objtool: Propagate elf_truncate_section() error in elf_write()

2025-09-17 Thread Josh Poimboeuf
Properly check and propagate the return value of elf_truncate_section() to avoid silent failures. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index b009d9feed760

[PATCH v4 14/63] objtool: Fix broken error handling in read_symbols()

2025-09-17 Thread Josh Poimboeuf
al errors which lead to an immediate exit(). Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 1c1bb2cb960da..b009d9feed760 100644 --- a/tools/objtool/elf.c +++ b

[PATCH v4 20/63] objtool: Fix x86 addend calculation

2025-09-17 Thread Josh Poimboeuf
On x86, arch_dest_reloc_offset() hardcodes the addend adjustment to four, but the actual adjustment depends on the relocation type. Fix that. Signed-off-by: Josh Poimboeuf --- tools/objtool/arch/loongarch/decode.c | 4 ++-- tools/objtool/arch/powerpc/decode.c | 4 ++-- tools/objtool/arch

[PATCH v4 18/63] objtool: Fix interval tree insertion for zero-length symbols

2025-09-17 Thread Josh Poimboeuf
Zero-length symbols get inserted in the wrong spot. Fix that. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index a8a78b55d3ece..c024937eb12a2 100644 --- a/tools/objtool/elf.c

[PATCH v4 17/63] objtool: Add empty symbols to the symbol tree again

2025-09-17 Thread Josh Poimboeuf
t;objtool: Don't add empty symbols to the rbtree") is no longer needed. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 19e249f4783cf..a8a78b55d3ece 10

[PATCH v4 19/63] objtool: Fix weak symbol detection

2025-09-17 Thread Josh Poimboeuf
zero for a given section. Fixes a bunch of (-ffunction-sections) warnings like: vmlinux.o: warning: objtool: .text.__x64_sys_io_setup+0x10: unreachable instruction Fixes: 4adb23686795 ("objtool: Ignore extra-symbol code") Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 8 +

[PATCH v4 16/63] objtool: Remove error handling boilerplate

2025-09-17 Thread Josh Poimboeuf
Up to a certain point in objtool's execution, all errors are fatal and return -1. When propagating such errors, just return -1 directly instead of trying to propagate the original return code. This helps make the code more compact and the behavior more explicit. Signed-off-by: Josh Poim

[PATCH v4 13/63] objtool: Make find_symbol_containing() less arbitrary

2025-09-17 Thread Josh Poimboeuf
In the rare case of overlapping symbols, find_symbol_containing() just returns the first one it finds. Make it slightly less arbitrary by returning the smallest symbol with size > 0. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 25 - 1 file changed,

[PATCH v4 10/63] x86/alternative: Refactor INT3 call emulation selftest

2025-09-17 Thread Josh Poimboeuf
reworking the functionality and moving int3_selftest_ip() to a separate asm function. While at it, improve the naming. Signed-off-by: Josh Poimboeuf --- arch/x86/kernel/alternative.c | 51 +++ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/arch/x86

[PATCH v4 12/63] interval_tree: Fix ITSTATIC usage for *_subtree_search()

2025-09-17 Thread Josh Poimboeuf
For consistency with the other function templates, change _subtree_search_*() to use the user-supplied ITSTATIC rather than the hard-coded 'static'. Signed-off-by: Josh Poimboeuf --- include/linux/interval_tree.h | 4 include/linux/interval_tree_generic.h

[PATCH v4 09/63] modpost: Ignore unresolved section bounds symbols

2025-09-17 Thread Josh Poimboeuf
amada Signed-off-by: Josh Poimboeuf --- scripts/mod/modpost.c | 5 + 1 file changed, 5 insertions(+) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5ca7c268294eb..c2b2c8fa6d258 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -606,6 +606,11 @@ stati

[PATCH v4 07/63] elfnote: Change ELFNOTE() to use __UNIQUE_ID()

2025-09-17 Thread Josh Poimboeuf
ne ELF note per line" limitation. Signed-off-by: Josh Poimboeuf --- include/linux/elfnote.h | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h index 69b136e4dd2b6..bb3dcded055fc 100644 --- a/include/linux/elfnote.h

[PATCH v4 08/63] kbuild: Remove 'kmod_' prefix from __KBUILD_MODNAME

2025-09-17 Thread Josh Poimboeuf
he name comes before the unique part. That will enable objtool to properly correlate symbols across builds. Cc: Masahiro Yamada Signed-off-by: Josh Poimboeuf --- include/linux/init.h | 3 ++- scripts/Makefile.lib | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/li

[PATCH v4 06/63] compiler.h: Make addressable symbols less of an eyesore

2025-09-17 Thread Josh Poimboeuf
. Signed-off-by: Josh Poimboeuf --- include/linux/compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index db5796b8b0a71..9bc690be60675 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -287,7

[PATCH v4 05/63] compiler: Tweak __UNIQUE_ID() naming

2025-09-17 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, add an underscore between the name and the counter. This will make it possible for objtool to distinguish between the non-unique and unique parts of the symbol name so it can properly correlate the symbols. Signed-off-by: Josh Poimboeuf

[PATCH v4 01/63] s390/vmlinux.lds.S: Prevent thunk functions from getting placed with normal text

2025-09-17 Thread Josh Poimboeuf
asily Gorbik Cc: Alexander Gordeev Acked-by: Heiko Carstens Signed-off-by: Josh Poimboeuf --- arch/s390/include/asm/nospec-insn.h | 2 +- arch/s390/kernel/vmlinux.lds.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/nospec-insn.h b/arch/s390/includ

[PATCH v4 02/63] vmlinux.lds: Unify TEXT_MAIN, DATA_MAIN, and related macros

2025-09-17 Thread Josh Poimboeuf
asily Gorbik Cc: Alexander Gordeev Signed-off-by: Josh Poimboeuf --- include/asm-generic/vmlinux.lds.h | 40 ++- scripts/module.lds.S | 12 -- 2 files changed, 17 insertions(+), 35 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/in

[PATCH v4 03/63] x86/module: Improve relocation error messages

2025-09-17 Thread Josh Poimboeuf
Add the section number and reloc index to relocation error messages to help find the faulty relocation. Signed-off-by: Josh Poimboeuf --- arch/x86/kernel/module.c | 15 +-- kernel/livepatch/core.c | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/x86

[PATCH v4 04/63] x86/kprobes: Remove STACK_FRAME_NON_STANDARD annotation

2025-09-17 Thread Josh Poimboeuf
Since commit 877b145f0f47 ("x86/kprobes: Move trampoline code into RODATA"), the optprobe template code is no longer analyzed by objtool so it doesn't need to be ignored. Signed-off-by: Josh Poimboeuf --- arch/x86/kernel/kprobes/opt.c | 4 1 file changed, 4 deletions(-) di

[PATCH v4 00/63] objtool,livepatch: klp-build livepatch module generation

2025-09-17 Thread Josh Poimboeuf
ng. These patches can also be found at: git://git.kernel.org/pub/scm/linux/kernel/git/jpoimboe/linux.git klp-build-v3 Please test! [1] https://github.com/dynup/kpatch Josh Poimboeuf (63): s390/vmlinux.lds.S: Prevent thunk functions from getting placed with normal text vmlinux.lds: U

Re: [PATCH v3 42/64] kbuild,x86: Fix special section module permissions

2025-09-16 Thread Josh Poimboeuf
On Mon, Jun 30, 2025 at 09:31:44AM +0200, Peter Zijlstra wrote: > On Fri, Jun 27, 2025 at 10:34:15AM -0700, Josh Poimboeuf wrote: > > On Fri, Jun 27, 2025 at 12:53:28PM +0200, Peter Zijlstra wrote: > > > On Thu, Jun 26, 2025 at 04:55:29PM -0700, Josh Poimboeuf wrote: > > &g

Re: [PATCH v3 26/64] objtool: Add section/symbol type helpers

2025-07-01 Thread Josh Poimboeuf
On Mon, Jun 30, 2025 at 09:29:38AM +0200, Peter Zijlstra wrote: > On Fri, Jun 27, 2025 at 09:36:08AM -0700, Josh Poimboeuf wrote: > > On Fri, Jun 27, 2025 at 12:29:30PM +0200, Peter Zijlstra wrote: > > > Naming seems inconsistent, there are: > > > > > > sym_h

Re: [PATCH v3 42/64] kbuild,x86: Fix special section module permissions

2025-06-27 Thread Josh Poimboeuf
On Fri, Jun 27, 2025 at 12:53:28PM +0200, Peter Zijlstra wrote: > On Thu, Jun 26, 2025 at 04:55:29PM -0700, Josh Poimboeuf wrote: > > An upcoming patch will add the SHF_MERGE flag to x86 __jump_table and > > __bug_table so their entry sizes can be defined in inline asm. > >

Re: [PATCH v3 44/64] x86/jump_label: Define ELF section entry size for jump labels

2025-06-27 Thread Josh Poimboeuf
(LRU_GEN_WIDTH, 0); > > DEFINE(__LRU_REFS_WIDTH, 0); > > +#endif > > +#if defined(CONFIG_HAVE_ARCH_JUMP_LABEL_RELATIVE) && > > defined(CONFIG_JUMP_LABEL) > > How is HAVE_ARCH_JUMP_LABEL_RELATIVE relevant here? #ifdef CONFIG_HAVE_ARCH_JUMP_LABEL_RELATIVE struct jump_entry { s32 code; s32 target; long key; // key may be far away from the core kernel under KASLR }; -- Josh

Re: [PATCH v3 29/64] objtool: Mark prefix functions

2025-06-27 Thread Josh Poimboeuf
lso, since we only ever set sym->prefix when is_func_sym(), this helper > could avoid checking that again. Indeed... -- Josh

Re: [PATCH v3 26/64] objtool: Add section/symbol type helpers

2025-06-27 Thread Josh Poimboeuf
se adjectives can be read as noun adjuncts, e.g. "chicken soup", where a noun functions as an adjective. If we changed those to: "is ?" or "is a ?" then it doesn't always read correctly: is_sym_file(): "is symbol a file?" is_sec_string(): "is section a string?" -- Josh

Re: [PATCH v3 17/64] objtool: Fix weak symbol detection

2025-06-27 Thread Josh Poimboeuf
On Fri, Jun 27, 2025 at 11:13:10AM +0200, Peter Zijlstra wrote: > On Thu, Jun 26, 2025 at 04:55:04PM -0700, Josh Poimboeuf wrote: > > find_symbol_hole_containing() fails to find a symbol hole (aka stripped > > weak symbol) if its section has no symbols before the hole. This breaks

[PATCH v3 62/64] livepatch/klp-build: Add --debug option to show cloning decisions

2025-06-26 Thread Josh Poimboeuf
Add a --debug option which gets passed to "objtool klp diff" to enable debug output related to cloning decisions. Signed-off-by: Josh Poimboeuf --- scripts/livepatch/klp-build | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/livepatch/k

[PATCH v3 63/64] livepatch/klp-build: Add --show-first-changed option to show function divergence

2025-06-26 Thread Josh Poimboeuf
the first differing instruction. This can be useful for quickly determining where and why a function changed. Signed-off-by: Josh Poimboeuf --- scripts/livepatch/klp-build | 82 +++-- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/scripts/livepatch/k

[PATCH v3 59/64] livepatch/klp-build: Introduce fix-patch-lines script to avoid __LINE__ diff noise

2025-06-26 Thread Josh Poimboeuf
: Josh Poimboeuf --- MAINTAINERS | 1 + scripts/livepatch/fix-patch-lines | 79 +++ 2 files changed, 80 insertions(+) create mode 100755 scripts/livepatch/fix-patch-lines diff --git a/MAINTAINERS b/MAINTAINERS index 0298d9570ca8..dd622368d74b

[PATCH v3 64/64] livepatch: Introduce source code helpers for livepatch modules

2025-06-26 Thread Josh Poimboeuf
Add some helper macros which can be used by livepatch source .patch files to register callbacks, convert static calls to regular calls where needed, and patch syscalls. Signed-off-by: Josh Poimboeuf --- include/linux/livepatch_helpers.h | 79 +++ 1 file changed, 79

[PATCH v3 60/64] livepatch/klp-build: Add stub init code for livepatch modules

2025-06-26 Thread Josh Poimboeuf
Add a module initialization stub which can be linked with binary diff objects to produce a livepatch module. Signed-off-by: Josh Poimboeuf --- scripts/livepatch/init.c | 108 +++ 1 file changed, 108 insertions(+) create mode 100644 scripts/livepatch/init.c

[PATCH v3 58/64] kbuild,objtool: Defer objtool validation step for CONFIG_KLP_BUILD

2025-06-26 Thread Josh Poimboeuf
for IBT and LTO. Eventually the per-translation-unit mode will be phased out. Signed-off-by: Josh Poimboeuf --- scripts/Makefile.lib| 2 +- scripts/link-vmlinux.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index

[PATCH v3 61/64] livepatch/klp-build: Introduce klp-build script for generating livepatch modules

2025-06-26 Thread Josh Poimboeuf
livepatch module (aka work around linker wreckage) using 'objtool klp post-link'. Signed-off-by: Josh Poimboeuf --- scripts/livepatch/fix-patch-lines | 2 +- scripts/livepatch/klp-build | 747 ++ tools/objtool/klp-diff.c | 6 +-

[PATCH v3 57/64] livepatch: Add CONFIG_KLP_BUILD

2025-06-26 Thread Josh Poimboeuf
In preparation for introducing klp-build, add a new CONFIG_KLP_BUILD option. The initial version will only be supported on x86-64. Signed-off-by: Josh Poimboeuf --- arch/x86/Kconfig | 1 + kernel/livepatch/Kconfig | 12 2 files changed, 13 insertions(+) diff --git a/arch

[PATCH v3 56/64] objtool: Add base objtool support for livepatch modules

2025-06-26 Thread Josh Poimboeuf
to the IBT function pointer section whitelist. - Prevent KLP symbols from getting incorrectly classified as cold subfunctions. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 48 + tools/objtool/elf.c | 5 ++- tools/objto

[PATCH v3 54/64] objtool/klp: Add post-link subcommand to finalize livepatch modules

2025-06-26 Thread Josh Poimboeuf
inker-compliant intermediate binary which encodes the relevant KLP section/reloc/symbol metadata. After module linking, the .ko then needs to be converted to an actual livepatch module. Introduce a new klp post-link subcommand to do so. Signed-off-by: Josh Poimboeuf --- tools/objtool/

[PATCH v3 52/64] objtool/klp: Introduce klp diff subcommand for diffing object files

2025-06-26 Thread Josh Poimboeuf
ted as a reference to the next symbol, or vice versa. A potential future alternative to '-ffunction-sections -fdata-sections' would be to introduce a toolchain option that forces symbol-based (non-section) relocations. Signed-off-by: Josh Poimboeuf --- MAINTAINERS

[PATCH v3 55/64] objtool: Disallow duplicate prefix symbols

2025-06-26 Thread Josh Poimboeuf
In preparation for adding objtool 'check' support for analyzing livepatch modules, error out if a duplicate prefix symbol is attempted. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 12 +++- tools/objtool/elf.c | 9 + too

[PATCH v3 51/64] objtool/klp: Add --debug-checksum= to show per-instruction checksums

2025-06-26 Thread Josh Poimboeuf
Add a --debug-checksum= option to the check subcommand to print the calculated checksum of each instruction in the given functions. This is useful for determining where two versions of a function begin to diverge. Signed-off-by: Josh Poimboeuf --- tools/objtool/builtin-check.c| 6

[PATCH v3 53/64] objtool/klp: Add --debug option to show cloning decisions

2025-06-26 Thread Josh Poimboeuf
Add a --debug option to klp diff which prints cloning decisions and an indented dependency tree for all cloned symbols and relocations. This helps visualize which symbols and relocations were included and why. Signed-off-by: Josh Poimboeuf --- tools/objtool/include/objtool/warn.h | 21

[PATCH v3 48/64] x86/orc: Define ELF section entry size for unwind hints

2025-06-26 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, define the entry size for the discard.unwind_hints section in its ELF header. This will allow tooling to extract individual entries. Signed-off-by: Josh Poimboeuf --- include/linux/objtool.h | 11 --- kernel/bounds.c | 4

[PATCH v3 50/64] objtool/klp: Add --checksum option to generate per-function checksums

2025-06-26 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, add a command-line option to generate a unique checksum for each function. This will enable detection of functions which have changed between two versions of an object file. Signed-off-by: Josh Poimboeuf --- tools/objtool/Makefile

[PATCH v3 49/64] objtool: Unify STACK_FRAME_NON_STANDARD entry sizes

2025-06-26 Thread Josh Poimboeuf
tting inline asm in a dummy function in order to pass the 'func' pointer to the asm. Signed-off-by: Josh Poimboeuf --- include/linux/objtool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/objtool.h b/include/linux/objtool.h index c7a3851ae4ae..7d7bb7f1af

[PATCH v3 45/64] x86/static_call: Define ELF section entry size of static calls

2025-06-26 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, define the entry size for the .static_call_sites section in its ELF header. This will allow tooling to extract individual entries. Signed-off-by: Josh Poimboeuf --- arch/x86/include/asm/static_call.h | 3 ++- include/linux/static_call.h

[PATCH v3 47/64] x86/bug: Define ELF section entry size for bug table

2025-06-26 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, define the entry size for the __bug_table section in its ELF header. This will allow tooling to extract individual entries. Signed-off-by: Josh Poimboeuf --- arch/x86/include/asm/bug.h | 45 -- 1 file

[PATCH v3 46/64] x86/extable: Define ELF section entry size for exception table

2025-06-26 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, define the entry size for the __ex_table section in its ELF header. This will allow tooling to extract individual entries. Signed-off-by: Josh Poimboeuf --- arch/um/include/asm/Kbuild | 1 - arch/um/include/shared/common

[PATCH v3 43/64] x86/alternative: Define ELF section entry size for alternatives

2025-06-26 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, define the entry size for the .altinstructions section in its ELF header. This will allow tooling to extract individual entries. Signed-off-by: Josh Poimboeuf --- arch/um/include/shared/common-offsets.h| 2 ++ arch/x86/include/asm

[PATCH v3 44/64] x86/jump_label: Define ELF section entry size for jump labels

2025-06-26 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, define the entry size for the __jump_table section in its ELF header. This will allow tooling to extract individual entries. Signed-off-by: Josh Poimboeuf --- arch/x86/include/asm/jump_label.h | 17 +++-- kernel/bounds.c

[PATCH v3 42/64] kbuild,x86: Fix special section module permissions

2025-06-26 Thread Josh Poimboeuf
remain writable. While SHF_WRITE is ignored by vmlinux, it's still needed for modules. To work around the linker interference, remove SHF_WRITE during compilation and restore it after linking the module. Cc: Masahiro Yamada Signed-off-by: Josh Poimboeuf --- arch/Kc

[PATCH v3 41/64] objtool: Add elf_create_file()

2025-06-26 Thread Josh Poimboeuf
Add interface to enable the creation of a new ELF file. Signed-off-by: Josh Poimboeuf --- tools/objtool/builtin-check.c | 2 +- tools/objtool/elf.c | 144 +++- tools/objtool/include/objtool/elf.h | 5 +- 3 files changed, 147 insertions(+), 4

[PATCH v3 40/64] objtool: Add elf_create_reloc() and elf_init_reloc()

2025-06-26 Thread Josh Poimboeuf
. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 151 +--- tools/objtool/include/objtool/elf.h | 9 ++ 2 files changed, 145 insertions(+), 15 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 535bdcf077d0..0e98cf2ab533 100644

[PATCH v3 39/64] objtool: Add elf_create_data()

2025-06-26 Thread Josh Poimboeuf
In preparation for the objtool klp diff subcommand, refactor elf_add_string() by adding a new elf_add_data() helper which allows the adding of arbitrary data to a section. Make both interfaces public so they can be used by the upcoming klp diff code. Signed-off-by: Josh Poimboeuf --- tools

  1   2   3   4   5   6   7   8   9   10   >