]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
objtool: Add module specific retpoline rules
authorPeter Zijlstra <peterz@infradead.org>
Wed, 31 Jan 2018 09:18:28 +0000 (10:18 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 21 Feb 2018 08:05:05 +0000 (09:05 +0100)
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>
scripts/Makefile.build
tools/objtool/builtin-check.c
tools/objtool/builtin.h
tools/objtool/check.c

index 53d862aee335f5902dbe2b226cf855a664a307a8..ce0fc4dd68c659c6706b0d478c513c74e4c546cb 100644 (file)
@@ -256,6 +256,8 @@ __objtool_obj := $(objtree)/tools/objtool/objtool
 
 objtool_args = $(if $(CONFIG_UNWINDER_ORC),orc generate,check)
 
+objtool_args += $(if $(part-of-module), --module,)
+
 ifndef CONFIG_FRAME_POINTER
 objtool_args += --no-fp
 endif
index dd6bcd6097f5171eaa50330244c52b5600cf012c..694abc628e9b3060b2252c1e8c86af4d6176e518 100644 (file)
@@ -29,7 +29,7 @@
 #include "builtin.h"
 #include "check.h"
 
-bool no_fp, no_unreachable, retpoline;
+bool no_fp, no_unreachable, retpoline, module;
 
 static const char * const check_usage[] = {
        "objtool check [<options>] file.o",
@@ -40,6 +40,7 @@ const struct option check_options[] = {
        OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"),
        OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"),
        OPT_BOOLEAN('r', "retpoline", &retpoline, "Validate retpoline assumptions"),
+       OPT_BOOLEAN('m', "module", &module, "Indicates the object will be part of a kernel module"),
        OPT_END(),
 };
 
index 7b6addfce045c1300feddca404fb3967b5e16c1a..28ff40e19a1413823b9b06ae4d1f1b42d922e850 100644 (file)
@@ -20,7 +20,7 @@
 #include <subcmd/parse-options.h>
 
 extern const struct option check_options[];
-extern bool no_fp, no_unreachable, retpoline;
+extern bool no_fp, no_unreachable, retpoline, module;
 
 extern int cmd_check(int argc, const char **argv);
 extern int cmd_orc(int argc, const char **argv);
index 5e5db7b4d77bb92172450340dfb103c94b10962e..472e64e95891e671b0c13c0d851e6defdc8e5b2c 100644 (file)
@@ -1958,6 +1958,15 @@ static int validate_retpoline(struct objtool_file *file)
                if (insn->retpoline_safe)
                        continue;
 
+               /*
+                * .init.text code is ran before userspace and thus doesn't
+                * strictly need retpolines, except for modules which are
+                * loaded late, they very much do need retpoline in their
+                * .init.text
+                */
+               if (!strcmp(insn->sec->name, ".init.text") && !module)
+                       continue;
+
                WARN_FUNC("indirect %s found in RETPOLINE build",
                          insn->sec, insn->offset,
                          insn->type == INSN_JUMP_DYNAMIC ? "jump" : "call");