linux-stable/tools/include/linux
Linus Torvalds 4356e9f841 work around gcc bugs with 'asm goto' with outputs
We've had issues with gcc and 'asm goto' before, and we created a
'asm_volatile_goto()' macro for that in the past: see commits
3f0116c323 ("compiler/gcc4: Add quirk for 'asm goto' miscompilation
bug") and a9f180345f ("compiler/gcc4: Make quirk for
asm_volatile_goto() unconditional").

Then, much later, we ended up removing the workaround in commit
43c249ea0b ("compiler-gcc.h: remove ancient workaround for gcc PR
58670") because we no longer supported building the kernel with the
affected gcc versions, but we left the macro uses around.

Now, Sean Christopherson reports a new version of a very similar
problem, which is fixed by re-applying that ancient workaround.  But the
problem in question is limited to only the 'asm goto with outputs'
cases, so instead of re-introducing the old workaround as-is, let's
rename and limit the workaround to just that much less common case.

It looks like there are at least two separate issues that all hit in
this area:

 (a) some versions of gcc don't mark the asm goto as 'volatile' when it
     has outputs:

        https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98619
        https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110420

     which is easy to work around by just adding the 'volatile' by hand.

 (b) Internal compiler errors:

        https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110422

     which are worked around by adding the extra empty 'asm' as a
     barrier, as in the original workaround.

but the problem Sean sees may be a third thing since it involves bad
code generation (not an ICE) even with the manually added 'volatile'.

but the same old workaround works for this case, even if this feels a
bit like voodoo programming and may only be hiding the issue.

Reported-and-tested-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/all/20240208220604.140859-1-seanjc@google.com/
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Uros Bizjak <ubizjak@gmail.com>
Cc: Jakub Jelinek <jakub@redhat.com>
Cc: Andrew Pinski <quic_apinski@quicinc.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-02-09 15:57:48 -08:00
..
sched XArray: Add calls to might_alloc() 2022-07-10 21:17:30 -04:00
unaligned
arm-smccc.h tools: Import ARM SMCCC definitions 2022-05-03 21:30:19 +01:00
atomic.h tools/include: Update atomic definitions 2022-02-20 08:44:37 +02:00
bitfield.h tools: Copy bitfield.h from the kernel sources 2022-11-10 19:10:27 +00:00
bitmap.h tools: Drop conflicting non-atomic test_and_{clear,set}_bit() helpers 2022-12-02 13:22:34 -05:00
bitops.h bitops: wrap non-atomic bitops with a transparent macro 2022-06-30 19:52:41 -07:00
bits.h tools headers: Synchronize {linux,vdso}/bits.h with the kernel sources 2023-03-03 22:34:15 -03:00
btf_ids.h bpf: Fix BTF_ID symbol generation collision in tools/ 2023-09-15 12:08:27 -07:00
bug.h
build_bug.h tools headers: Syncronize linux/build_bug.h with the kernel sources 2023-01-18 10:31:11 -03:00
cache.h tools/include: Add cache.h stub 2022-02-20 08:44:37 +02:00
compiler-gcc.h tools: Rename __fallthrough to fallthrough 2023-04-06 21:41:00 -03:00
compiler.h compiler.h: move __is_constexpr() to compiler.h 2023-10-18 14:43:22 -07:00
compiler_types.h work around gcc bugs with 'asm goto' with outputs 2024-02-09 15:57:48 -08:00
const.h compiler.h: move __is_constexpr() to compiler.h 2023-10-18 14:43:22 -07:00
coresight-pmu.h perf cs-etm: Copy kernel coresight-pmu.h header 2023-05-26 16:03:27 -03:00
ctype.h
debugfs.h tools/include: Add debugfs.h stub 2022-02-20 08:44:37 +02:00
delay.h
err.h docs: move x86 documentation into Documentation/arch/ 2023-03-30 12:58:51 -06:00
export.h
filter.h
find.h tools: sync find_bit() implementation 2022-09-21 12:21:44 -07:00
ftrace.h
gfp.h tools: fix compilation after gfp_types.h split 2022-09-11 16:22:31 -07:00
gfp_types.h tools: fix compilation after gfp_types.h split 2022-09-11 16:22:31 -07:00
hash.h hash.h: remove unused define directive 2022-01-20 08:52:54 +02:00
hashtable.h
interrupt.h
interval_tree_generic.h objtool: Fix find_{symbol,func}_containing() 2022-10-17 16:41:08 +02:00
io.h tools/include: Add io.h stub 2022-02-20 08:44:37 +02:00
jhash.h
kallsyms.h kallsyms: increase maximum kernel symbol length to 512 2022-09-28 08:56:25 +02:00
kconfig.h
kern_levels.h
kernel.h tools/include: Add _RET_IP_ and math definitions to kernel.h 2022-02-20 08:44:37 +02:00
linkage.h
list.h tools lib: Add list_last_entry_or_null() 2022-07-26 16:02:13 -03:00
list_sort.h tools lib: Adopt list_sort() from the kernel sources 2021-10-20 10:30:59 -03:00
log2.h
math.h tools: Fix math.h breakage 2021-11-30 09:14:42 -08:00
math64.h
mm.h memblock tests: fix warning: "__ALIGN_KERNEL" redefined 2023-09-14 09:26:14 +03:00
module.h
mutex.h
nmi.h
numa.h
objtool_types.h x86,objtool: Split UNWIND_HINT_EMPTY in two 2023-03-23 23:18:58 +01:00
overflow.h
pfn.h tools/include: Add pfn.h stub 2022-02-20 08:44:37 +02:00
poison.h
rbtree.h
rbtree_augmented.h
rcu.h
refcount.h
ring_buffer.h
rwsem.h maple_tree: update check_forking() and bench_forking() 2023-12-10 16:51:33 -08:00
seq_file.h memblock tests: fix warning ‘struct seq_file’ declared inside parameter list 2023-09-14 10:51:28 +03:00
sizes.h
slab.h radix tree test suite: add support for slab bulk APIs 2022-09-26 19:46:14 -07:00
spinlock.h maple_tree: introduce {mtree,mas}_lock_nested() 2023-12-10 16:51:31 -08:00
static_call_types.h
string.h
stringify.h
time64.h
types.h tools/virtio: fix build caused by virtio_ring changes 2023-04-21 03:02:35 -04:00
zalloc.h