Skip to content

Commit 63e6995

Browse files
committed
Merge tag 'objtool-core-2025-12-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool updates from Ingo Molnar: - klp-build livepatch module generation (Josh Poimboeuf) Introduce new objtool features and a klp-build script to generate livepatch modules using a source .patch as input. This builds on concepts from the longstanding out-of-tree kpatch project which began in 2012 and has been used for many years to generate livepatch modules for production kernels. However, this is a complete rewrite which incorporates hard-earned lessons from 12+ years of maintaining kpatch. Key improvements compared to kpatch-build: - Integrated with objtool: Leverages objtool's existing control-flow graph analysis to help detect changed functions. - Works on vmlinux.o: Supports late-linked objects, making it compatible with LTO, IBT, and similar. - Simplified code base: ~3k fewer lines of code. - Upstream: No more out-of-tree #ifdef hacks, far less cruft. - Cleaner internals: Vastly simplified logic for symbol/section/reloc inclusion and special section extraction. - Robust __LINE__ macro handling: Avoids false positive binary diffs caused by the __LINE__ macro by introducing a fix-patch-lines script which injects #line directives into the source .patch to preserve the original line numbers at compile time. - Disassemble code with libopcodes instead of running objdump (Alexandre Chartre) - Disassemble support (-d option to objtool) by Alexandre Chartre, which supports the decoding of various Linux kernel code generation specials such as alternatives: 17ef: sched_balance_find_dst_group+0x62f mov 0x34(%r9),%edx 17f3: sched_balance_find_dst_group+0x633 | <alternative.17f3> | X86_FEATURE_POPCNT 17f3: sched_balance_find_dst_group+0x633 | call 0x17f8 <__sw_hweight64> | popcnt %rdi,%rax 17f8: sched_balance_find_dst_group+0x638 cmp %eax,%edx ... jump table alternatives: 1895: sched_use_asym_prio+0x5 test $0x8,%ch 1898: sched_use_asym_prio+0x8 je 0x18a9 <sched_use_asym_prio+0x19> 189a: sched_use_asym_prio+0xa | <jump_table.189a> | JUMP 189a: sched_use_asym_prio+0xa | jmp 0x18ae <sched_use_asym_prio+0x1e> | nop2 189c: sched_use_asym_prio+0xc mov $0x1,%eax 18a1: sched_use_asym_prio+0x11 and $0x80,%ecx ... exception table alternatives: native_read_msr: 5b80: native_read_msr+0x0 mov %edi,%ecx 5b82: native_read_msr+0x2 | <ex_table.5b82> | EXCEPTION 5b82: native_read_msr+0x2 | rdmsr | resume at 0x5b84 <native_read_msr+0x4> 5b84: native_read_msr+0x4 shl $0x20,%rdx .... x86 feature flag decoding (also see the X86_FEATURE_POPCNT example in sched_balance_find_dst_group() above): 2faaf: start_thread_common.constprop.0+0x1f jne 0x2fba4 <start_thread_common.constprop.0+0x114> 2fab5: start_thread_common.constprop.0+0x25 | <alternative.2fab5> | X86_FEATURE_ALWAYS | X86_BUG_NULL_SEG 2fab5: start_thread_common.constprop.0+0x25 | jmp 0x2faba <.altinstr_aux+0x2f4> | jmp 0x4b0 <start_thread_common.constprop.0+0x3f> | nop5 2faba: start_thread_common.constprop.0+0x2a mov $0x2b,%eax ... NOP sequence shortening: 1048e2: snapshot_write_finalize+0xc2 je 0x104917 <snapshot_write_finalize+0xf7> 1048e4: snapshot_write_finalize+0xc4 nop6 1048ea: snapshot_write_finalize+0xca nop11 1048f5: snapshot_write_finalize+0xd5 nop11 104900: snapshot_write_finalize+0xe0 mov %rax,%rcx 104903: snapshot_write_finalize+0xe3 mov 0x10(%rdx),%rax ... and much more. - Function validation tracing support (Alexandre Chartre) - Various -ffunction-sections fixes (Josh Poimboeuf) - Clang AutoFDO (Automated Feedback-Directed Optimizations) support (Josh Poimboeuf) - Misc fixes and cleanups (Borislav Petkov, Chen Ni, Dylan Hatch, Ingo Molnar, John Wang, Josh Poimboeuf, Pankaj Raghav, Peter Zijlstra, Thorsten Blum) * tag 'objtool-core-2025-12-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (129 commits) objtool: Fix segfault on unknown alternatives objtool: Build with disassembly can fail when including bdf.h objtool: Trim trailing NOPs in alternative objtool: Add wide output for disassembly objtool: Compact output for alternatives with one instruction objtool: Improve naming of group alternatives objtool: Add Function to get the name of a CPU feature objtool: Provide access to feature and flags of group alternatives objtool: Fix address references in alternatives objtool: Disassemble jump table alternatives objtool: Disassemble exception table alternatives objtool: Print addresses with alternative instructions objtool: Disassemble group alternatives objtool: Print headers for alternatives objtool: Preserve alternatives order objtool: Add the --disas=<function-pattern> action objtool: Do not validate IBT for .return_sites and .call_sites objtool: Improve tracing of alternative instructions objtool: Add functions to better name alternatives objtool: Identify the different types of alternatives ...
2 parents b53440f + 6ec33db commit 63e6995

99 files changed

Lines changed: 7592 additions & 1246 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

MAINTAINERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14459,10 +14459,11 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching.g
1445914459
F: Documentation/ABI/testing/sysfs-kernel-livepatch
1446014460
F: Documentation/livepatch/
1446114461
F: arch/powerpc/include/asm/livepatch.h
14462-
F: include/linux/livepatch.h
14462+
F: include/linux/livepatch*.h
1446314463
F: kernel/livepatch/
1446414464
F: kernel/module/livepatch.c
1446514465
F: samples/livepatch/
14466+
F: scripts/livepatch/
1446614467
F: tools/testing/selftests/livepatch/
1446714468

1446814469
LLC (802.2)

arch/s390/include/asm/nospec-insn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#ifdef CONFIG_EXPOLINE_EXTERN
2020
SYM_CODE_START(\name)
2121
#else
22-
.pushsection .text.\name,"axG",@progbits,\name,comdat
22+
.pushsection .text..\name,"axG",@progbits,\name,comdat
2323
.globl \name
2424
.hidden \name
2525
.type \name,@function

arch/s390/kernel/vmlinux.lds.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ SECTIONS
5151
IRQENTRY_TEXT
5252
SOFTIRQENTRY_TEXT
5353
FTRACE_HOTPATCH_TRAMPOLINES_TEXT
54-
*(.text.*_indirect_*)
54+
*(.text..*_indirect_*)
5555
*(.gnu.warning)
5656
. = ALIGN(PAGE_SIZE);
5757
_etext = .; /* End of text section */

arch/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ config X86
261261
select HAVE_FUNCTION_ERROR_INJECTION
262262
select HAVE_KRETPROBES
263263
select HAVE_RETHOOK
264+
select HAVE_KLP_BUILD if X86_64
264265
select HAVE_LIVEPATCH if X86_64
265266
select HAVE_MIXED_BREAKPOINTS_REGS
266267
select HAVE_MOD_ARCH_SPECIFIC

arch/x86/boot/startup/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $(patsubst %.o,$(obj)/%.o,$(lib-y)): OBJECT_FILES_NON_STANDARD := y
3636
# relocations, even if other objtool actions are being deferred.
3737
#
3838
$(pi-objs): objtool-enabled = 1
39-
$(pi-objs): objtool-args = $(if $(delay-objtool),,$(objtool-args-y)) --noabs
39+
$(pi-objs): objtool-args = $(if $(delay-objtool),--dry-run,$(objtool-args-y)) --noabs
4040

4141
#
4242
# Confine the startup code by prefixing all symbols with __pi_ (for position

arch/x86/include/asm/alternative.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
198198

199199
#define ALTINSTR_ENTRY(ft_flags) \
200200
".pushsection .altinstructions,\"a\"\n" \
201+
ANNOTATE_DATA_SPECIAL \
201202
" .long 771b - .\n" /* label */ \
202203
" .long 774f - .\n" /* new instruction */ \
203204
" .4byte " __stringify(ft_flags) "\n" /* feature + flags */ \
@@ -207,6 +208,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
207208

208209
#define ALTINSTR_REPLACEMENT(newinstr) /* replacement */ \
209210
".pushsection .altinstr_replacement, \"ax\"\n" \
211+
ANNOTATE_DATA_SPECIAL \
210212
"# ALT: replacement\n" \
211213
"774:\n\t" newinstr "\n775:\n" \
212214
".popsection\n"
@@ -337,6 +339,7 @@ void nop_func(void);
337339
* instruction. See apply_alternatives().
338340
*/
339341
.macro altinstr_entry orig alt ft_flags orig_len alt_len
342+
ANNOTATE_DATA_SPECIAL
340343
.long \orig - .
341344
.long \alt - .
342345
.4byte \ft_flags
@@ -365,6 +368,7 @@ void nop_func(void);
365368
.popsection ; \
366369
.pushsection .altinstr_replacement,"ax" ; \
367370
743: \
371+
ANNOTATE_DATA_SPECIAL ; \
368372
newinst ; \
369373
744: \
370374
.popsection ;

arch/x86/include/asm/asm.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#ifndef _ASM_X86_ASM_H
33
#define _ASM_X86_ASM_H
44

5+
#include <linux/annotate.h>
6+
57
#ifdef __ASSEMBLER__
68
# define __ASM_FORM(x, ...) x,## __VA_ARGS__
79
# define __ASM_FORM_RAW(x, ...) x,## __VA_ARGS__
@@ -132,6 +134,7 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
132134
# define _ASM_EXTABLE_TYPE(from, to, type) \
133135
.pushsection "__ex_table","a" ; \
134136
.balign 4 ; \
137+
ANNOTATE_DATA_SPECIAL ; \
135138
.long (from) - . ; \
136139
.long (to) - . ; \
137140
.long type ; \
@@ -179,6 +182,7 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
179182
# define _ASM_EXTABLE_TYPE(from, to, type) \
180183
" .pushsection \"__ex_table\",\"a\"\n" \
181184
" .balign 4\n" \
185+
ANNOTATE_DATA_SPECIAL \
182186
" .long (" #from ") - .\n" \
183187
" .long (" #to ") - .\n" \
184188
" .long " __stringify(type) " \n" \
@@ -187,6 +191,7 @@ static __always_inline __pure void *rip_rel_ptr(void *p)
187191
# define _ASM_EXTABLE_TYPE_REG(from, to, type, reg) \
188192
" .pushsection \"__ex_table\",\"a\"\n" \
189193
" .balign 4\n" \
194+
ANNOTATE_DATA_SPECIAL \
190195
" .long (" #from ") - .\n" \
191196
" .long (" #to ") - .\n" \
192197
DEFINE_EXTABLE_TYPE_REG \

arch/x86/include/asm/bug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#define _BUG_FLAGS_ASM(ins, file, line, flags, size, extra) \
5858
"1:\t" ins "\n" \
5959
".pushsection __bug_table,\"aw\"\n" \
60+
ANNOTATE_DATA_SPECIAL \
6061
__BUG_ENTRY(file, line, flags) \
6162
"\t.org 2b + " size "\n" \
6263
".popsection\n" \

arch/x86/include/asm/cpufeature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static __always_inline bool _static_cpu_has(u16 bit)
101101
asm goto(ALTERNATIVE_TERNARY("jmp 6f", %c[feature], "", "jmp %l[t_no]")
102102
".pushsection .altinstr_aux,\"ax\"\n"
103103
"6:\n"
104+
ANNOTATE_DATA_SPECIAL
104105
" testb %[bitnum], %a[cap_byte]\n"
105106
" jnz %l[t_yes]\n"
106107
" jmp %l[t_no]\n"

arch/x86/include/asm/jump_label.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define JUMP_TABLE_ENTRY(key, label) \
1616
".pushsection __jump_table, \"aw\" \n\t" \
1717
_ASM_ALIGN "\n\t" \
18+
ANNOTATE_DATA_SPECIAL \
1819
".long 1b - . \n\t" \
1920
".long " label " - . \n\t" \
2021
_ASM_PTR " " key " - . \n\t" \

0 commit comments

Comments
 (0)