Re: [PATCH v4 1/4] tls: add macros for coroutine-safe TLS variables

2022-02-23 Thread Paolo Bonzini
On 2/21/22 15:29, Stefan Hajnoczi wrote: +#define QEMU_DEFINE_CO_TLS(type, var)\ +static __thread type co_tls_##var; \ +type get_##var(void) { asm volatile(""); return co_tls_##var; } \ +void set_##

Re: [PATCH v4 1/4] tls: add macros for coroutine-safe TLS variables

2022-02-22 Thread Stefan Hajnoczi
On Mon, Feb 21, 2022 at 03:16:22PM +, Peter Maydell wrote: > On Mon, 21 Feb 2022 at 14:29, Stefan Hajnoczi wrote: > > > > 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 ne

Re: [PATCH v4 1/4] tls: add macros for coroutine-safe TLS variables

2022-02-21 Thread Peter Maydell
On Mon, 21 Feb 2022 at 14:29, Stefan Hajnoczi wrote: > > 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)) wrappe

[PATCH v4 1/4] tls: add macros for coroutine-safe TLS variables

2022-02-21 Thread Stefan Hajnoczi
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 accordin