Skip to content

Commit a69898c

Browse files
Peter Zijlstragregkh
authored andcommitted
objtool: Add module specific retpoline rules
commit ca41b97 upstream. David allowed retpolines in .init.text, except for modules, which will trip up objtool retpoline validation, fix that. Requested-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3945bbe commit a69898c

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎scripts/Makefile.build‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ __objtool_obj := $(objtree)/tools/objtool/objtool
261261

262262
objtool_args = $(if $(CONFIG_UNWINDER_ORC),orc generate,check)
263263

264+
objtool_args += $(if $(part-of-module), --module,)
265+
264266
ifndef CONFIG_FRAME_POINTER
265267
objtool_args += --no-fp
266268
endif

‎tools/objtool/builtin-check.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "builtin.h"
3030
#include "check.h"
3131

32-
bool no_fp, no_unreachable, retpoline;
32+
bool no_fp, no_unreachable, retpoline, module;
3333

3434
static const char * const check_usage[] = {
3535
"objtool check [<options>] file.o",
@@ -40,6 +40,7 @@ const struct option check_options[] = {
4040
OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"),
4141
OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"),
4242
OPT_BOOLEAN('r', "retpoline", &retpoline, "Validate retpoline assumptions"),
43+
OPT_BOOLEAN('m', "module", &module, "Indicates the object will be part of a kernel module"),
4344
OPT_END(),
4445
};
4546

‎tools/objtool/builtin.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <subcmd/parse-options.h>
2121

2222
extern const struct option check_options[];
23-
extern bool no_fp, no_unreachable, retpoline;
23+
extern bool no_fp, no_unreachable, retpoline, module;
2424

2525
extern int cmd_check(int argc, const char **argv);
2626
extern int cmd_orc(int argc, const char **argv);

‎tools/objtool/check.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,15 @@ static int validate_retpoline(struct objtool_file *file)
19571957
if (insn->retpoline_safe)
19581958
continue;
19591959

1960+
/*
1961+
* .init.text code is ran before userspace and thus doesn't
1962+
* strictly need retpolines, except for modules which are
1963+
* loaded late, they very much do need retpoline in their
1964+
* .init.text
1965+
*/
1966+
if (!strcmp(insn->sec->name, ".init.text") && !module)
1967+
continue;
1968+
19601969
WARN_FUNC("indirect %s found in RETPOLINE build",
19611970
insn->sec, insn->offset,
19621971
insn->type == INSN_JUMP_DYNAMIC ? "jump" : "call");

0 commit comments

Comments
 (0)