From 041151f4399ff0dcd200aa3fe4f745b28d67d71c Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Wed, 10 Sep 2025 20:43:06 +0200 Subject: [PATCH] i386: Use __seg_gs qualifier to cast access to TCB in THREAD_GSCOPE_RESET_FLAG() Use the __seg_gs named address space qualifier to cast access to the gscope_flag in the TCB as a %gs: 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 Cc: H.J.Lu Cc: Florian Weimer Cc: Carlos O'Donell --- sysdeps/i386/nptl/tls.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h index 35202b0964..5c266c7191 100644 --- a/sysdeps/i386/nptl/tls.h +++ b/sysdeps/i386/nptl/tls.h @@ -255,9 +255,10 @@ tls_fill_user_desc (union user_desc_init *desc, #define THREAD_GSCOPE_RESET_FLAG() \ do \ { int __res; \ - asm volatile ("xchgl %0, %%gs:%P1" \ + asm volatile ("xchgl %1, %0" \ : "=r" (__res) \ - : "i" (offsetof (struct pthread, header.gscope_flag)), \ + : "m" (*(int __seg_gs *) \ + 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); \