On Thu, Dec 02, 2021 at 02:44:42PM +, Peter Maydell wrote:
> On Wed, 1 Dec 2021 at 17:19, 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
* Peter Maydell:
> On Thu, 2 Dec 2021 at 14:44, Peter Maydell wrote:
>> My compiler-developer colleagues present the following case where
>> 'noinline' is not sufficient for the compiler to definitely
>> use different values of the address-of-the-TLS-var across an
>> intervening function call:
>>
On Wed, 1 Dec 2021 at 17:19, 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)) wrapper
On Thu, 2 Dec 2021 at 14:44, Peter Maydell wrote:
> My compiler-developer colleagues present the following case where
> 'noinline' is not sufficient for the compiler to definitely
> use different values of the address-of-the-TLS-var across an
> intervening function call:
>
> __thread int i;
>
>
On Wed, Dec 01, 2021 at 07:24:33PM +0100, Florian Weimer wrote:
> * Stefan Hajnoczi:
>
> > +#elif defined(__x86_64__)
> > +#define QEMU_CO_TLS_ADDR(ret, var) \
> > +asm volatile("rdfsbase %0\n\t" \
> > + "lea "#var"@tpof
* Stefan Hajnoczi:
> +#elif defined(__x86_64__)
> +#define QEMU_CO_TLS_ADDR(ret, var) \
> +asm volatile("rdfsbase %0\n\t" \
> + "lea "#var"@tpoff(%0), %0" : "=r"(ret))
> +#endif
RDFSBASE needs quite recent kernels. I t
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