Skip to content

Commit a6640c8

Browse files
committed
Merge tag 'objtool-core-2025-01-20' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool updates from Ingo Molnar: - Introduce the generic section-based annotation infrastructure a.k.a. ASM_ANNOTATE/ANNOTATE (Peter Zijlstra) - Convert various facilities to ASM_ANNOTATE/ANNOTATE: (Peter Zijlstra) - ANNOTATE_NOENDBR - ANNOTATE_RETPOLINE_SAFE - instrumentation_{begin,end}() - VALIDATE_UNRET_BEGIN - ANNOTATE_IGNORE_ALTERNATIVE - ANNOTATE_INTRA_FUNCTION_CALL - {.UN}REACHABLE - Optimize the annotation-sections parsing code (Peter Zijlstra) - Centralize annotation definitions in <linux/objtool.h> - Unify & simplify the barrier_before_unreachable()/unreachable() definitions (Peter Zijlstra) - Convert unreachable() calls to BUG() in x86 code, as unreachable() has unreliable code generation (Peter Zijlstra) - Remove annotate_reachable() and annotate_unreachable(), as it's unreliable against compiler optimizations (Peter Zijlstra) - Fix non-standard ANNOTATE_REACHABLE annotation order (Peter Zijlstra) - Robustify the annotation code by warning about unknown annotation types (Peter Zijlstra) - Allow arch code to discover jump table size, in preparation of annotated jump table support (Ard Biesheuvel) * tag 'objtool-core-2025-01-20' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/mm: Convert unreachable() to BUG() objtool: Allow arch code to discover jump table size objtool: Warn about unknown annotation types objtool: Fix ANNOTATE_REACHABLE to be a normal annotation objtool: Convert {.UN}REACHABLE to ANNOTATE objtool: Remove annotate_{,un}reachable() loongarch: Use ASM_REACHABLE x86: Convert unreachable() to BUG() unreachable: Unify objtool: Collect more annotations in objtool.h objtool: Collapse annotate sequences objtool: Convert ANNOTATE_INTRA_FUNCTION_CALL to ANNOTATE objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE to ANNOTATE objtool: Convert VALIDATE_UNRET_BEGIN to ANNOTATE objtool: Convert instrumentation_{begin,end}() to ANNOTATE objtool: Convert ANNOTATE_RETPOLINE_SAFE to ANNOTATE objtool: Convert ANNOTATE_NOENDBR to ANNOTATE objtool: Generic annotation infrastructure
2 parents 8838a1a + 41a1e97 commit a6640c8

File tree

22 files changed

+267
-463
lines changed

22 files changed

+267
-463
lines changed

arch/loongarch/include/asm/bug.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <asm/break.h>
66
#include <linux/stringify.h>
7+
#include <linux/objtool.h>
78

89
#ifndef CONFIG_DEBUG_BUGVERBOSE
910
#define _BUGVERBOSE_LOCATION(file, line)
@@ -33,25 +34,25 @@
3334

3435
#define ASM_BUG_FLAGS(flags) \
3536
__BUG_ENTRY(flags) \
36-
break BRK_BUG
37+
break BRK_BUG;
3738

3839
#define ASM_BUG() ASM_BUG_FLAGS(0)
3940

40-
#define __BUG_FLAGS(flags) \
41-
asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)));
41+
#define __BUG_FLAGS(flags, extra) \
42+
asm_inline volatile (__stringify(ASM_BUG_FLAGS(flags)) \
43+
extra);
4244

4345
#define __WARN_FLAGS(flags) \
4446
do { \
4547
instrumentation_begin(); \
46-
__BUG_FLAGS(BUGFLAG_WARNING|(flags)); \
47-
annotate_reachable(); \
48+
__BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\
4849
instrumentation_end(); \
4950
} while (0)
5051

5152
#define BUG() \
5253
do { \
5354
instrumentation_begin(); \
54-
__BUG_FLAGS(0); \
55+
__BUG_FLAGS(0, ""); \
5556
unreachable(); \
5657
} while (0)
5758

arch/x86/entry/entry_64.S

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,9 @@ SYM_CODE_END(xen_error_entry)
308308
movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
309309
.endif
310310

311-
call \cfunc
312-
313311
/* For some configurations \cfunc ends up being a noreturn. */
314-
REACHABLE
312+
ANNOTATE_REACHABLE
313+
call \cfunc
315314

316315
jmp error_return
317316
.endm
@@ -529,10 +528,10 @@ SYM_CODE_START(\asmsym)
529528
movq %rsp, %rdi /* pt_regs pointer into first argument */
530529
movq ORIG_RAX(%rsp), %rsi /* get error code into 2nd argument*/
531530
movq $-1, ORIG_RAX(%rsp) /* no syscall to restart */
532-
call \cfunc
533531

534532
/* For some configurations \cfunc ends up being a noreturn. */
535-
REACHABLE
533+
ANNOTATE_REACHABLE
534+
call \cfunc
536535

537536
jmp paranoid_exit
538537

arch/x86/include/asm/alternative.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <linux/types.h>
66
#include <linux/stringify.h>
7+
#include <linux/objtool.h>
78
#include <asm/asm.h>
89

910
#define ALT_FLAGS_SHIFT 16
@@ -54,16 +55,6 @@
5455
#define LOCK_PREFIX ""
5556
#endif
5657

57-
/*
58-
* objtool annotation to ignore the alternatives and only consider the original
59-
* instruction(s).
60-
*/
61-
#define ANNOTATE_IGNORE_ALTERNATIVE \
62-
"999:\n\t" \
63-
".pushsection .discard.ignore_alts\n\t" \
64-
".long 999b\n\t" \
65-
".popsection\n\t"
66-
6758
/*
6859
* The patching flags are part of the upper bits of the @ft_flags parameter when
6960
* specifying them. The split is currently like this:
@@ -310,17 +301,6 @@ void nop_func(void);
310301
.endm
311302
#endif
312303

313-
/*
314-
* objtool annotation to ignore the alternatives and only consider the original
315-
* instruction(s).
316-
*/
317-
.macro ANNOTATE_IGNORE_ALTERNATIVE
318-
.Lannotate_\@:
319-
.pushsection .discard.ignore_alts
320-
.long .Lannotate_\@
321-
.popsection
322-
.endm
323-
324304
/*
325305
* Issue one struct alt_instr descriptor entry (need to put it into
326306
* the section .altinstructions, see below). This entry contains

arch/x86/include/asm/bug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ do { \
9292
do { \
9393
__auto_type __flags = BUGFLAG_WARNING|(flags); \
9494
instrumentation_begin(); \
95-
_BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \
95+
_BUG_FLAGS(ASM_UD2, __flags, ANNOTATE_REACHABLE(1b)); \
9696
instrumentation_end(); \
9797
} while (0)
9898

arch/x86/include/asm/irq_stack.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100
}
101101

102102
#define ASM_CALL_ARG0 \
103-
"call %c[__func] \n" \
104-
ASM_REACHABLE
103+
"1: call %c[__func] \n" \
104+
ANNOTATE_REACHABLE(1b)
105105

106106
#define ASM_CALL_ARG1 \
107107
"movq %[arg1], %%rdi \n" \

arch/x86/include/asm/nospec-branch.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,6 @@
179179

180180
#ifdef __ASSEMBLY__
181181

182-
/*
183-
* This should be used immediately before an indirect jump/call. It tells
184-
* objtool the subsequent indirect jump/call is vouched safe for retpoline
185-
* builds.
186-
*/
187-
.macro ANNOTATE_RETPOLINE_SAFE
188-
.Lhere_\@:
189-
.pushsection .discard.retpoline_safe
190-
.long .Lhere_\@
191-
.popsection
192-
.endm
193-
194182
/*
195183
* (ab)use RETPOLINE_SAFE on RET to annotate away 'bare' RET instructions
196184
* vs RETBleed validation.
@@ -350,12 +338,6 @@
350338

351339
#else /* __ASSEMBLY__ */
352340

353-
#define ANNOTATE_RETPOLINE_SAFE \
354-
"999:\n\t" \
355-
".pushsection .discard.retpoline_safe\n\t" \
356-
".long 999b\n\t" \
357-
".popsection\n\t"
358-
359341
typedef u8 retpoline_thunk_t[RETPOLINE_THUNK_SIZE];
360342
extern retpoline_thunk_t __x86_indirect_thunk_array[];
361343
extern retpoline_thunk_t __x86_indirect_call_thunk_array[];

arch/x86/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ void __noreturn stop_this_cpu(void *dummy)
839839
#ifdef CONFIG_SMP
840840
if (smp_ops.stop_this_cpu) {
841841
smp_ops.stop_this_cpu();
842-
unreachable();
842+
BUG();
843843
}
844844
#endif
845845

arch/x86/kernel/reboot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs)
883883

884884
if (smp_ops.stop_this_cpu) {
885885
smp_ops.stop_this_cpu();
886-
unreachable();
886+
BUG();
887887
}
888888

889889
/* Assume hlt works */

arch/x86/kvm/svm/sev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3820,7 +3820,7 @@ static int snp_begin_psc(struct vcpu_svm *svm, struct psc_buffer *psc)
38203820
goto next_range;
38213821
}
38223822

3823-
unreachable();
3823+
BUG();
38243824
}
38253825

38263826
static int __sev_snp_update_protected_guest_state(struct kvm_vcpu *vcpu)

arch/x86/mm/fault.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ page_fault_oops(struct pt_regs *regs, unsigned long error_code,
678678
ASM_CALL_ARG3,
679679
, [arg1] "r" (regs), [arg2] "r" (address), [arg3] "r" (&info));
680680

681-
unreachable();
681+
BUG();
682682
}
683683
#endif
684684

0 commit comments

Comments
 (0)