Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

objtool: Add module specific retpoline rules

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>

authored by

Peter Zijlstra and committed by
Ingo Molnar
ca41b97e b5bc2231

+14 -2
+2
scripts/Makefile.build
··· 256 256 257 257 objtool_args = $(if $(CONFIG_UNWINDER_ORC),orc generate,check) 258 258 259 + objtool_args += $(if $(part-of-module), --module,) 260 + 259 261 ifndef CONFIG_FRAME_POINTER 260 262 objtool_args += --no-fp 261 263 endif
+2 -1
tools/objtool/builtin-check.c
··· 29 29 #include "builtin.h" 30 30 #include "check.h" 31 31 32 - bool no_fp, no_unreachable, retpoline; 32 + bool no_fp, no_unreachable, retpoline, module; 33 33 34 34 static const char * const check_usage[] = { 35 35 "objtool check [<options>] file.o", ··· 40 40 OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"), 41 41 OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"), 42 42 OPT_BOOLEAN('r', "retpoline", &retpoline, "Validate retpoline assumptions"), 43 + OPT_BOOLEAN('m', "module", &module, "Indicates the object will be part of a kernel module"), 43 44 OPT_END(), 44 45 }; 45 46
+1 -1
tools/objtool/builtin.h
··· 20 20 #include <subcmd/parse-options.h> 21 21 22 22 extern const struct option check_options[]; 23 - extern bool no_fp, no_unreachable, retpoline; 23 + extern bool no_fp, no_unreachable, retpoline, module; 24 24 25 25 extern int cmd_check(int argc, const char **argv); 26 26 extern int cmd_orc(int argc, const char **argv);
+9
tools/objtool/check.c
··· 1958 1958 if (insn->retpoline_safe) 1959 1959 continue; 1960 1960 1961 + /* 1962 + * .init.text code is ran before userspace and thus doesn't 1963 + * strictly need retpolines, except for modules which are 1964 + * loaded late, they very much do need retpoline in their 1965 + * .init.text 1966 + */ 1967 + if (!strcmp(insn->sec->name, ".init.text") && !module) 1968 + continue; 1969 + 1961 1970 WARN_FUNC("indirect %s found in RETPOLINE build", 1962 1971 insn->sec, insn->offset, 1963 1972 insn->type == INSN_JUMP_DYNAMIC ? "jump" : "call");