]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86_64: Use __seg_fs qualifier to cast access to TCB in THREAD_GSCOPE_RESET_FLAG()
authorUros Bizjak <ubizjak@gmail.com>
Wed, 10 Sep 2025 18:30:56 +0000 (20:30 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Sun, 14 Sep 2025 19:50:50 +0000 (21:50 +0200)
Use the __seg_fs named address space qualifier to cast access to the
gscope_flag in the TCB as a %fs: prefixed address.  This enables the
use of the "m" operand constraint, which informs the compiler about
memory access in the inline assembly.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: H.J.Lu <hjl.tools@gmail.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
sysdeps/x86_64/nptl/tls.h

index 683f8bfdfcad45734c4cc1aeea844582a5528640..cf414300509431972d943c757ec4042c13e1be42 100644 (file)
@@ -201,9 +201,10 @@ _Static_assert (offsetof (tcbhead_t, __glibc_unused2) == 0x80,
 # define THREAD_GSCOPE_RESET_FLAG() \
   do                                                                         \
     { int __res;                                                             \
-      asm volatile ("xchgl %0, %%fs:%P1"                                     \
+      asm volatile ("xchgl %1, %0"                                           \
                    : "=r" (__res)                                            \
-                   : "i" (offsetof (struct pthread, header.gscope_flag)),    \
+                   : "m" (*(int __seg_fs *)                                  \
+                          offsetof (struct pthread, header.gscope_flag)),    \
                      "0" (THREAD_GSCOPE_FLAG_UNUSED));                       \
       if (__res == THREAD_GSCOPE_FLAG_WAIT)                                  \
        lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE);    \