Skip to content

Commit 18aa611

Browse files
author
Peter Zijlstra
committed
objtool: Convert VALIDATE_UNRET_BEGIN to ANNOTATE
Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 317f2a6 commit 18aa611

File tree

4 files changed

+10
-29
lines changed

4 files changed

+10
-29
lines changed

include/linux/objtool.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,12 @@
130130
* NOTE: The macro must be used at the beginning of a global symbol, otherwise
131131
* it will be ignored.
132132
*/
133-
.macro VALIDATE_UNRET_BEGIN
134133
#if defined(CONFIG_NOINSTR_VALIDATION) && \
135134
(defined(CONFIG_MITIGATION_UNRET_ENTRY) || defined(CONFIG_MITIGATION_SRSO))
136-
.Lhere_\@:
137-
.pushsection .discard.validate_unret
138-
.long .Lhere_\@ - .
139-
.popsection
135+
#define VALIDATE_UNRET_BEGIN ANNOTATE type=ANNOTYPE_UNRET_BEGIN
136+
#else
137+
#define VALIDATE_UNRET_BEGIN
140138
#endif
141-
.endm
142139

143140
.macro REACHABLE
144141
.Lhere_\@:

include/linux/objtool_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@ struct unwind_hint {
6161
#define ANNOTYPE_RETPOLINE_SAFE 2
6262
#define ANNOTYPE_INSTR_BEGIN 3
6363
#define ANNOTYPE_INSTR_END 4
64+
#define ANNOTYPE_UNRET_BEGIN 5
6465

6566
#endif /* _LINUX_OBJTOOL_TYPES_H */

tools/include/linux/objtool_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@ struct unwind_hint {
6161
#define ANNOTYPE_RETPOLINE_SAFE 2
6262
#define ANNOTYPE_INSTR_BEGIN 3
6363
#define ANNOTYPE_INSTR_END 4
64+
#define ANNOTYPE_UNRET_BEGIN 5
6465

6566
#endif /* _LINUX_OBJTOOL_TYPES_H */

tools/objtool/check.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2458,33 +2458,15 @@ static int __annotate_instr(int type, struct instruction *insn)
24582458
return 0;
24592459
}
24602460

2461-
static int read_validate_unret_hints(struct objtool_file *file)
2461+
static int __annotate_unret(int type, struct instruction *insn)
24622462
{
2463-
struct section *rsec;
2464-
struct instruction *insn;
2465-
struct reloc *reloc;
2466-
2467-
rsec = find_section_by_name(file->elf, ".rela.discard.validate_unret");
2468-
if (!rsec)
2463+
if (type != ANNOTYPE_UNRET_BEGIN)
24692464
return 0;
24702465

2471-
for_each_reloc(rsec, reloc) {
2472-
if (reloc->sym->type != STT_SECTION) {
2473-
WARN("unexpected relocation symbol type in %s", rsec->name);
2474-
return -1;
2475-
}
2476-
2477-
insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
2478-
if (!insn) {
2479-
WARN("bad .discard.instr_end entry");
2480-
return -1;
2481-
}
2482-
insn->unret = 1;
2483-
}
2484-
2466+
insn->unret = 1;
24852467
return 0;
2486-
}
24872468

2469+
}
24882470

24892471
static int read_intra_function_calls(struct objtool_file *file)
24902472
{
@@ -2705,7 +2687,7 @@ static int decode_sections(struct objtool_file *file)
27052687
if (ret)
27062688
return ret;
27072689

2708-
ret = read_validate_unret_hints(file);
2690+
ret = read_annotate(file, __annotate_unret);
27092691
if (ret)
27102692
return ret;
27112693

0 commit comments

Comments
 (0)