diff options
author | Nick Desaulniers <ndesaulniers@google.com> | 2022-02-02 21:55:53 +0100 |
---|---|---|
committer | Josh Poimboeuf <jpoimboe@redhat.com> | 2022-02-02 23:41:04 +0100 |
commit | bfb1a7c91fb7758273b4a8d735313d9cc388b502 (patch) | |
tree | 7e20e37463f61c78bbca3fc04ea3dbc67a494f15 /tools/lib/traceevent/Makefile | |
parent | objtool: Fix truncated string warning (diff) | |
download | linux-bfb1a7c91fb7758273b4a8d735313d9cc388b502.tar.xz linux-bfb1a7c91fb7758273b4a8d735313d9cc388b502.zip |
x86/bug: Merge annotate_reachable() into _BUG_FLAGS() asm
In __WARN_FLAGS(), we had two asm statements (abbreviated):
asm volatile("ud2");
asm volatile(".pushsection .discard.reachable");
These pair of statements are used to trigger an exception, but then help
objtool understand that for warnings, control flow will be restored
immediately afterwards.
The problem is that volatile is not a compiler barrier. GCC explicitly
documents this:
> Note that the compiler can move even volatile asm instructions
> relative to other code, including across jump instructions.
Also, no clobbers are specified to prevent instructions from subsequent
statements from being scheduled by compiler before the second asm
statement. This can lead to instructions from subsequent statements
being emitted by the compiler before the second asm statement.
Providing a scheduling model such as via -march= options enables the
compiler to better schedule instructions with known latencies to hide
latencies from data hazards compared to inline asm statements in which
latencies are not estimated.
If an instruction gets scheduled by the compiler between the two asm
statements, then objtool will think that it is not reachable, producing
a warning.
To prevent instructions from being scheduled in between the two asm
statements, merge them.
Also remove an unnecessary unreachable() asm annotation from BUG() in
favor of __builtin_unreachable(). objtool is able to track that the ud2
from BUG() terminates control flow within the function.
Link: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile
Link: https://github.com/ClangBuiltLinux/linux/issues/1483
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220202205557.2260694-1-ndesaulniers@google.com
Diffstat (limited to 'tools/lib/traceevent/Makefile')
0 files changed, 0 insertions, 0 deletions