diff options
author | Peter Zijlstra <peterz@infradead.org> | 2018-01-31 04:18:28 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-02-21 03:05:05 -0500 |
commit | ca41b97ed9124fd62323a162de5852f6e28f94b8 (patch) | |
tree | 834e3ba681fc038c7570acf9fe7ae17991a981fe /tools | |
parent | b5bc2231b8ad4387c9641f235ca0ad8cd300b6df (diff) |
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>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/objtool/builtin-check.c | 3 | ||||
-rw-r--r-- | tools/objtool/builtin.h | 2 | ||||
-rw-r--r-- | tools/objtool/check.c | 9 |
3 files changed, 12 insertions, 2 deletions
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c index dd6bcd6097f5..694abc628e9b 100644 --- a/tools/objtool/builtin-check.c +++ b/tools/objtool/builtin-check.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "builtin.h" | 29 | #include "builtin.h" |
30 | #include "check.h" | 30 | #include "check.h" |
31 | 31 | ||
32 | bool no_fp, no_unreachable, retpoline; | 32 | bool no_fp, no_unreachable, retpoline, module; |
33 | 33 | ||
34 | static const char * const check_usage[] = { | 34 | static const char * const check_usage[] = { |
35 | "objtool check [<options>] file.o", | 35 | "objtool check [<options>] file.o", |
@@ -40,6 +40,7 @@ const struct option check_options[] = { | |||
40 | OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"), | 40 | OPT_BOOLEAN('f', "no-fp", &no_fp, "Skip frame pointer validation"), |
41 | OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"), | 41 | OPT_BOOLEAN('u', "no-unreachable", &no_unreachable, "Skip 'unreachable instruction' warnings"), |
42 | OPT_BOOLEAN('r', "retpoline", &retpoline, "Validate retpoline assumptions"), | 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 | OPT_END(), | 44 | OPT_END(), |
44 | }; | 45 | }; |
45 | 46 | ||
diff --git a/tools/objtool/builtin.h b/tools/objtool/builtin.h index 7b6addfce045..28ff40e19a14 100644 --- a/tools/objtool/builtin.h +++ b/tools/objtool/builtin.h | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <subcmd/parse-options.h> | 20 | #include <subcmd/parse-options.h> |
21 | 21 | ||
22 | extern const struct option check_options[]; | 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 | extern int cmd_check(int argc, const char **argv); | 25 | extern int cmd_check(int argc, const char **argv); |
26 | extern int cmd_orc(int argc, const char **argv); | 26 | extern int cmd_orc(int argc, const char **argv); |
diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 5e5db7b4d77b..472e64e95891 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c | |||
@@ -1958,6 +1958,15 @@ static int validate_retpoline(struct objtool_file *file) | |||
1958 | if (insn->retpoline_safe) | 1958 | if (insn->retpoline_safe) |
1959 | continue; | 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 | WARN_FUNC("indirect %s found in RETPOLINE build", | 1970 | WARN_FUNC("indirect %s found in RETPOLINE build", |
1962 | insn->sec, insn->offset, | 1971 | insn->sec, insn->offset, |
1963 | insn->type == INSN_JUMP_DYNAMIC ? "jump" : "call"); | 1972 | insn->type == INSN_JUMP_DYNAMIC ? "jump" : "call"); |