qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Stefan Hajnoczi
Subject: Re: [RFC v2 1/4] tls: add macros for coroutine-safe TLS variables
Date: Thu, 2 Dec 2021 09:53:46 +0000

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"@tpoff(%0), %0" : "=r"(ret))
> > +#endif
> 
> RDFSBASE needs quite recent kernels.  I think you should use
> 
>   movq %%fs:0, %0
> 
> instead, which is equivalent for the x86-64 psABI.

Nice trick! I remember reading that the address of the thread data is
stored in the first element of the thread data itself, so this makes
sense :).

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]