Skip to content

Commit f0cd57c

Browse files
author
Peter Zijlstra
committed
objtool: Convert ANNOTATE_IGNORE_ALTERNATIVE 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 18aa611 commit f0cd57c

File tree

4 files changed

+15
-46
lines changed

4 files changed

+15
-46
lines changed

arch/x86/include/asm/alternative.h

Lines changed: 3 additions & 11 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
@@ -58,11 +59,7 @@
5859
* objtool annotation to ignore the alternatives and only consider the original
5960
* instruction(s).
6061
*/
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"
62+
#define ANNOTATE_IGNORE_ALTERNATIVE ASM_ANNOTATE(ANNOTYPE_IGNORE_ALTS)
6663

6764
/*
6865
* The patching flags are part of the upper bits of the @ft_flags parameter when
@@ -314,12 +311,7 @@ void nop_func(void);
314311
* objtool annotation to ignore the alternatives and only consider the original
315312
* instruction(s).
316313
*/
317-
.macro ANNOTATE_IGNORE_ALTERNATIVE
318-
.Lannotate_\@:
319-
.pushsection .discard.ignore_alts
320-
.long .Lannotate_\@
321-
.popsection
322-
.endm
314+
#define ANNOTATE_IGNORE_ALTERNATIVE ANNOTATE type=ANNOTYPE_IGNORE_ALTS
323315

324316
/*
325317
* Issue one struct alt_instr descriptor entry (need to put it into

include/linux/objtool_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@ struct unwind_hint {
6262
#define ANNOTYPE_INSTR_BEGIN 3
6363
#define ANNOTYPE_INSTR_END 4
6464
#define ANNOTYPE_UNRET_BEGIN 5
65+
#define ANNOTYPE_IGNORE_ALTS 6
6566

6667
#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
@@ -62,5 +62,6 @@ struct unwind_hint {
6262
#define ANNOTYPE_INSTR_BEGIN 3
6363
#define ANNOTYPE_INSTR_END 4
6464
#define ANNOTYPE_UNRET_BEGIN 5
65+
#define ANNOTYPE_IGNORE_ALTS 6
6566

6667
#endif /* _LINUX_OBJTOOL_TYPES_H */

tools/objtool/check.c

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,40 +1309,6 @@ static void add_uaccess_safe(struct objtool_file *file)
13091309
}
13101310
}
13111311

1312-
/*
1313-
* FIXME: For now, just ignore any alternatives which add retpolines. This is
1314-
* a temporary hack, as it doesn't allow ORC to unwind from inside a retpoline.
1315-
* But it at least allows objtool to understand the control flow *around* the
1316-
* retpoline.
1317-
*/
1318-
static int add_ignore_alternatives(struct objtool_file *file)
1319-
{
1320-
struct section *rsec;
1321-
struct reloc *reloc;
1322-
struct instruction *insn;
1323-
1324-
rsec = find_section_by_name(file->elf, ".rela.discard.ignore_alts");
1325-
if (!rsec)
1326-
return 0;
1327-
1328-
for_each_reloc(rsec, reloc) {
1329-
if (reloc->sym->type != STT_SECTION) {
1330-
WARN("unexpected relocation symbol type in %s", rsec->name);
1331-
return -1;
1332-
}
1333-
1334-
insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
1335-
if (!insn) {
1336-
WARN("bad .discard.ignore_alts entry");
1337-
return -1;
1338-
}
1339-
1340-
insn->ignore_alts = true;
1341-
}
1342-
1343-
return 0;
1344-
}
1345-
13461312
/*
13471313
* Symbols that replace INSN_CALL_DYNAMIC, every (tail) call to such a symbol
13481314
* will be added to the .retpoline_sites section.
@@ -2414,6 +2380,15 @@ static int read_annotate(struct objtool_file *file, int (*func)(int type, struct
24142380
return 0;
24152381
}
24162382

2383+
static int __annotate_ignore_alts(int type, struct instruction *insn)
2384+
{
2385+
if (type != ANNOTYPE_IGNORE_ALTS)
2386+
return 0;
2387+
2388+
insn->ignore_alts = true;
2389+
return 0;
2390+
}
2391+
24172392
static int __annotate_noendbr(int type, struct instruction *insn)
24182393
{
24192394
if (type != ANNOTYPE_NOENDBR)
@@ -2626,7 +2601,7 @@ static int decode_sections(struct objtool_file *file)
26262601
add_ignores(file);
26272602
add_uaccess_safe(file);
26282603

2629-
ret = add_ignore_alternatives(file);
2604+
ret = read_annotate(file, __annotate_ignore_alts);
26302605
if (ret)
26312606
return ret;
26322607

0 commit comments

Comments
 (0)