Commit 7dce6204 authored by Josh Poimboeuf's avatar Josh Poimboeuf Committed by Peter Zijlstra

objtool: Make stack validation optional

Make stack validation an explicit cmdline option so that individual
objtool features can be enabled individually by other arches.
Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarMiroslav Benes <mbenes@suse.cz>
Link: https://lkml.kernel.org/r/52da143699574d756e65ca4c9d4acaffe9b0fe5f.1650300597.git.jpoimboe@redhat.com
parent 99c0beb5
...@@ -232,6 +232,7 @@ objtool_args = \ ...@@ -232,6 +232,7 @@ objtool_args = \
$(if $(CONFIG_UNWINDER_ORC), --orc) \ $(if $(CONFIG_UNWINDER_ORC), --orc) \
$(if $(CONFIG_RETPOLINE), --retpoline) \ $(if $(CONFIG_RETPOLINE), --retpoline) \
$(if $(CONFIG_SLS), --sls) \ $(if $(CONFIG_SLS), --sls) \
$(if $(CONFIG_STACK_VALIDATION), --stackval) \
$(if $(CONFIG_X86_SMAP), --uaccess) \ $(if $(CONFIG_X86_SMAP), --uaccess) \
$(if $(part-of-module), --module) \ $(if $(part-of-module), --module) \
$(if $(CONFIG_FRAME_POINTER),, --no-fp) \ $(if $(CONFIG_FRAME_POINTER),, --no-fp) \
......
...@@ -126,6 +126,10 @@ objtool_link() ...@@ -126,6 +126,10 @@ objtool_link()
objtoolopt="${objtoolopt} --orc" objtoolopt="${objtoolopt} --orc"
fi fi
if is_enabled CONFIG_STACK_VALIDATION; then
objtoolopt="${objtoolopt} --stackval"
fi
objtoolopt="${objtoolopt} --lto" objtoolopt="${objtoolopt} --lto"
fi fi
......
...@@ -39,6 +39,7 @@ const struct option check_options[] = { ...@@ -39,6 +39,7 @@ const struct option check_options[] = {
OPT_BOOLEAN('o', "orc", &opts.orc, "generate ORC metadata"), OPT_BOOLEAN('o', "orc", &opts.orc, "generate ORC metadata"),
OPT_BOOLEAN('r', "retpoline", &opts.retpoline, "validate and annotate retpoline usage"), OPT_BOOLEAN('r', "retpoline", &opts.retpoline, "validate and annotate retpoline usage"),
OPT_BOOLEAN('l', "sls", &opts.sls, "validate straight-line-speculation mitigations"), OPT_BOOLEAN('l', "sls", &opts.sls, "validate straight-line-speculation mitigations"),
OPT_BOOLEAN('s', "stackval", &opts.stackval, "validate stack unwinding rules"),
OPT_BOOLEAN('u', "uaccess", &opts.uaccess, "validate uaccess rules for SMAP"), OPT_BOOLEAN('u', "uaccess", &opts.uaccess, "validate uaccess rules for SMAP"),
OPT_CALLBACK_OPTARG(0, "dump", NULL, NULL, "orc", "dump metadata", parse_dump), OPT_CALLBACK_OPTARG(0, "dump", NULL, NULL, "orc", "dump metadata", parse_dump),
...@@ -92,6 +93,7 @@ static bool opts_valid(void) ...@@ -92,6 +93,7 @@ static bool opts_valid(void)
opts.orc || opts.orc ||
opts.retpoline || opts.retpoline ||
opts.sls || opts.sls ||
opts.stackval ||
opts.uaccess) { opts.uaccess) {
if (opts.dump_orc) { if (opts.dump_orc) {
fprintf(stderr, "--dump can't be combined with other options\n"); fprintf(stderr, "--dump can't be combined with other options\n");
......
...@@ -3899,25 +3899,27 @@ int check(struct objtool_file *file) ...@@ -3899,25 +3899,27 @@ int check(struct objtool_file *file)
warnings += ret; warnings += ret;
} }
ret = validate_functions(file); if (opts.stackval || opts.orc || opts.uaccess || opts.ibt || opts.sls) {
if (ret < 0) ret = validate_functions(file);
goto out; if (ret < 0)
warnings += ret; goto out;
warnings += ret;
ret = validate_unwind_hints(file, NULL);
if (ret < 0)
goto out;
warnings += ret;
if (opts.ibt) { ret = validate_unwind_hints(file, NULL);
ret = validate_ibt(file);
if (ret < 0) if (ret < 0)
goto out; goto out;
warnings += ret; warnings += ret;
if (!warnings) {
ret = validate_reachable_instructions(file);
if (ret < 0)
goto out;
warnings += ret;
}
} }
if (!warnings) { if (opts.ibt) {
ret = validate_reachable_instructions(file); ret = validate_ibt(file);
if (ret < 0) if (ret < 0)
goto out; goto out;
warnings += ret; warnings += ret;
......
...@@ -18,6 +18,7 @@ struct opts { ...@@ -18,6 +18,7 @@ struct opts {
bool orc; bool orc;
bool retpoline; bool retpoline;
bool sls; bool sls;
bool stackval;
bool uaccess; bool uaccess;
/* options: */ /* options: */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment