Skip to content

Commit 87116ae

Browse files
author
Peter Zijlstra
committed
objtool: Fix ANNOTATE_REACHABLE to be a normal annotation
Currently REACHABLE is weird for being on the instruction after the instruction it modifies. Since all REACHABLE annotations have an explicit instruction, flip them around. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Link: https://lore.kernel.org/r/20241128094312.494176035@infradead.org
1 parent e7a174f commit 87116ae

File tree

6 files changed

+8
-32
lines changed

6 files changed

+8
-32
lines changed

arch/loongarch/include/asm/bug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#define __WARN_FLAGS(flags) \
4646
do { \
4747
instrumentation_begin(); \
48-
__BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE);\
48+
__BUG_FLAGS(BUGFLAG_WARNING|(flags), ANNOTATE_REACHABLE(10001b));\
4949
instrumentation_end(); \
5050
} while (0)
5151

arch/x86/entry/entry_64.S

Lines changed: 2 additions & 3 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. */
314312
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. */
535533
ANNOTATE_REACHABLE
534+
call \cfunc
536535

537536
jmp paranoid_exit
538537

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, ANNOTATE_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-
ANNOTATE_REACHABLE
103+
"1: call %c[__func] \n" \
104+
ANNOTATE_REACHABLE(1b)
105105

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

include/linux/objtool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,11 @@
177177
*/
178178
#define ANNOTATE_UNRET_BEGIN ASM_ANNOTATE(ANNOTYPE_UNRET_BEGIN)
179179
/*
180-
* This should be used directly after an instruction that is considered
180+
* This should be used to refer to an instruction that is considered
181181
* terminating, like a noreturn CALL or UD2 when we know they are not -- eg
182182
* WARN using UD2.
183183
*/
184-
#define ANNOTATE_REACHABLE ASM_ANNOTATE(ANNOTYPE_REACHABLE)
184+
#define ANNOTATE_REACHABLE(label) __ASM_ANNOTATE(label, ANNOTYPE_REACHABLE)
185185

186186
#else
187187
#define ANNOTATE_NOENDBR ANNOTATE type=ANNOTYPE_NOENDBR

tools/objtool/check.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -614,19 +614,6 @@ static int init_pv_ops(struct objtool_file *file)
614614
return 0;
615615
}
616616

617-
static struct instruction *find_last_insn(struct objtool_file *file,
618-
struct section *sec)
619-
{
620-
struct instruction *insn = NULL;
621-
unsigned int offset;
622-
unsigned int end = (sec->sh.sh_size > 10) ? sec->sh.sh_size - 10 : 0;
623-
624-
for (offset = sec->sh.sh_size - 1; offset >= end && !insn; offset--)
625-
insn = find_insn(file, sec, offset);
626-
627-
return insn;
628-
}
629-
630617
static int create_static_call_sections(struct objtool_file *file)
631618
{
632619
struct static_call_site *site;
@@ -2281,16 +2268,6 @@ static int read_annotate(struct objtool_file *file,
22812268
offset = reloc->sym->offset + reloc_addend(reloc);
22822269
insn = find_insn(file, reloc->sym->sec, offset);
22832270

2284-
/*
2285-
* Reachable annotations are 'funneh' and act on the previous instruction :/
2286-
*/
2287-
if (type == ANNOTYPE_REACHABLE) {
2288-
if (insn)
2289-
insn = prev_insn_same_sec(file, insn);
2290-
else if (offset == reloc->sym->sec->sh.sh_size)
2291-
insn = find_last_insn(file, reloc->sym->sec);
2292-
}
2293-
22942271
if (!insn) {
22952272
WARN("bad .discard.annotate_insn entry: %d of type %d", reloc_idx(reloc), type);
22962273
return -1;

0 commit comments

Comments
 (0)