diff options
author | Julien Thierry <jthierry@redhat.com> | 2020-09-04 18:30:22 +0300 |
---|---|---|
committer | Josh Poimboeuf <jpoimboe@redhat.com> | 2020-09-10 18:43:13 +0300 |
commit | eda3dc905834dc9c99132f987f77b68cf53a8682 (patch) | |
tree | cfbdd2d47ee9f477ff25f80518cfd6071e87b2d6 /tools/objtool/special.c | |
parent | c8ea0d672521ef663f0f9a77faa94d0d47102d77 (diff) | |
download | linux-eda3dc905834dc9c99132f987f77b68cf53a8682.tar.xz |
objtool: Abstract alternative special case handling
Some alternatives associated with a specific feature need to be treated
in a special way. Since the features and how to treat them vary from one
architecture to another, move the special case handling to arch specific
code.
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Julien Thierry <jthierry@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Diffstat (limited to 'tools/objtool/special.c')
-rw-r--r-- | tools/objtool/special.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/tools/objtool/special.c b/tools/objtool/special.c index b04f395de5de..1a2420febd08 100644 --- a/tools/objtool/special.c +++ b/tools/objtool/special.c @@ -16,9 +16,6 @@ #include "warn.h" #include "arch_special.h" -#define X86_FEATURE_POPCNT (4*32+23) -#define X86_FEATURE_SMAP (9*32+20) - struct special_entry { const char *sec; bool group, jump_or_nop; @@ -54,6 +51,10 @@ struct special_entry entries[] = { {}, }; +void __weak arch_handle_alternative(unsigned short feature, struct special_alt *alt) +{ +} + static int get_alt_entry(struct elf *elf, struct special_entry *entry, struct section *sec, int idx, struct special_alt *alt) @@ -78,30 +79,7 @@ static int get_alt_entry(struct elf *elf, struct special_entry *entry, feature = *(unsigned short *)(sec->data->d_buf + offset + entry->feature); - - /* - * It has been requested that we don't validate the !POPCNT - * feature path which is a "very very small percentage of - * machines". - */ - if (feature == X86_FEATURE_POPCNT) - alt->skip_orig = true; - - /* - * If UACCESS validation is enabled; force that alternative; - * otherwise force it the other way. - * - * What we want to avoid is having both the original and the - * alternative code flow at the same time, in that case we can - * find paths that see the STAC but take the NOP instead of - * CLAC and the other way around. - */ - if (feature == X86_FEATURE_SMAP) { - if (uaccess) - alt->skip_orig = true; - else - alt->skip_alt = true; - } + arch_handle_alternative(feature, alt); } orig_reloc = find_reloc_by_dest(elf, sec, offset + entry->orig); |