summary refs log tree commit diff stats
path: root/util/async.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2022-02-22 14:01:47 +0000
committerKevin Wolf <kwolf@redhat.com>2022-03-04 18:14:40 +0100
commit7d29c341c9d402cf0bcb3a3b76fce0c09dd24e94 (patch)
tree46d04234051c29163330e5bdb6e1015eca3133be /util/async.c
parent11d0c9b37e94959662f6bcd640aa33137e11dcac (diff)
downloadfocaccia-qemu-7d29c341c9d402cf0bcb3a3b76fce0c09dd24e94.tar.gz
focaccia-qemu-7d29c341c9d402cf0bcb3a3b76fce0c09dd24e94.zip
tls: add macros for coroutine-safe TLS variables
Compiler optimizations can cache TLS values across coroutine yield
points, resulting in stale values from the previous thread when a
coroutine is re-entered by a new thread.

Serge Guelton developed an __attribute__((noinline)) wrapper and tested
it with clang and gcc. I formatted his idea according to QEMU's coding
style and wrote documentation.

The compiler can still optimize based on analyzing noinline code, so an
asm volatile barrier with an output constraint is required to prevent
unwanted optimizations.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1952483
Suggested-by: Serge Guelton <sguelton@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20220222140150.27240-2-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'util/async.c')
0 files changed, 0 insertions, 0 deletions