Skip to content

Commit 882a0db

Browse files
Peter ZijlstraKAGA-KOKO
authored andcommitted
objtool: Improve UACCESS coverage
A clang build reported an (obvious) double CLAC while a GCC build did not; it turns out that objtool only re-visits instructions if the first visit was with AC=0. If OTOH the first visit was with AC=1, it completely ignores any subsequent visit, even when it has AC=0. Fix this by using a visited mask instead of a boolean, and (explicitly) mark the AC state. $ ./objtool check -b --no-fp --retpoline --uaccess drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: .altinstr_replacement+0x22: redundant UACCESS disable drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: eb_copy_relocations.isra.34()+0xea: (alt) drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: .altinstr_replacement+0xffffffffffffffff: (branch) drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: eb_copy_relocations.isra.34()+0xd9: (alt) drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: eb_copy_relocations.isra.34()+0xb2: (branch) drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: eb_copy_relocations.isra.34()+0x39: (branch) drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: eb_copy_relocations.isra.34()+0x0: <=== (func) Reported-by: Josh Poimboeuf <[email protected]> Reported-by: Thomas Gleixner <[email protected]> Reported-by: Sedat Dilek <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Tested-by: Nick Desaulniers <[email protected]> Tested-by: Sedat Dilek <[email protected]> Link: ClangBuiltLinux#617 Link: https://lkml.kernel.org/r/5359166aad2d53f3145cd442d83d0e5115e0cd17.1564007838.git.jpoimboe@redhat.com
1 parent b68b990 commit 882a0db

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

tools/objtool/check.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
19461946
struct alternative *alt;
19471947
struct instruction *insn, *next_insn;
19481948
struct section *sec;
1949+
u8 visited;
19491950
int ret;
19501951

19511952
insn = first;
@@ -1972,12 +1973,12 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
19721973
return 1;
19731974
}
19741975

1976+
visited = 1 << state.uaccess;
19751977
if (insn->visited) {
19761978
if (!insn->hint && !insn_state_match(insn, &state))
19771979
return 1;
19781980

1979-
/* If we were here with AC=0, but now have AC=1, go again */
1980-
if (insn->state.uaccess || !state.uaccess)
1981+
if (insn->visited & visited)
19811982
return 0;
19821983
}
19831984

@@ -2024,7 +2025,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
20242025
} else
20252026
insn->state = state;
20262027

2027-
insn->visited = true;
2028+
insn->visited |= visited;
20282029

20292030
if (!insn->ignore_alts) {
20302031
bool skip_orig = false;

tools/objtool/check.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ struct instruction {
3333
unsigned int len;
3434
enum insn_type type;
3535
unsigned long immediate;
36-
bool alt_group, visited, dead_end, ignore, hint, save, restore, ignore_alts;
36+
bool alt_group, dead_end, ignore, hint, save, restore, ignore_alts;
3737
bool retpoline_safe;
38+
u8 visited;
3839
struct symbol *call_dest;
3940
struct instruction *jump_dest;
4041
struct instruction *first_jump_src;

0 commit comments

Comments
 (0)