x86: Assert __ASSUME_PRIVATE_FUTEX == 1
Commit Message
On Wed, May 16, 2018 at 7:28 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 05/08/2018 10:39 PM, H.J. Lu wrote:
>>
>> diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
>> index 8ca0924692..c3a0edd253 100644
>> --- a/sysdeps/i386/nptl/tls.h
>> +++ b/sysdeps/i386/nptl/tls.h
>> @@ -50,6 +50,10 @@ typedef struct
>> void *__private_tm[4];
>> /* GCC split stack support. */
>> void *__private_ss;
>> + /* Bit 0: IBT.
>> + Bit 1: SHSTK.
>> + */
>> + unsigned int feature_1;
>> } tcbhead_t;
>
>
> It might be nicer to reuse __glibc_reserved1 for that (I think
> __ASSUME_PRIVATE_FUTEX is always defined these days), in case some extern
> tools hard-code the tcbhead_t layout.
>
Good idea. How about this patch to remove __ASSUME_PRIVATE_FUTEX
checks first?
Comments
On 05/16/2018 06:36 PM, H.J. Lu wrote:
> Good idea. How about this patch to remove __ASSUME_PRIVATE_FUTEX
> checks first?
I would prefer if you removed the whole thing, including its definition.
Thanks,
Florian
From b57d23f77d0b240781b73478e75c1f833ec14bb2 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 16 May 2018 09:30:14 -0700
Subject: [PATCH] x86: Assert __ASSUME_PRIVATE_FUTEX == 1
Since __ASSUME_PRIVATE_FUTEX is always defined, this patch replaces "#if"
on __ASSUME_PRIVATE_FUTEX with _Static_assert on __ASSUME_PRIVATE_FUTEX.
* i386/nptl/tcb-offsets.sym (PRIVATE_FUTEX): Removed.
* x86_64/nptl/tcb-offsets.sym (PRIVATE_FUTEX): Likewise.
* sysdeps/i386/nptl/tls.h: Assert __ASSUME_PRIVATE_FUTEX == 1.
(tcbhead_t): Remve "#ifndef __ASSUME_PRIVATE_FUTEX".
* sysdeps/x86_64/nptl/tls.h: Assert __ASSUME_PRIVATE_FUTEX == 1.
(tcbhead_t): Remve "#ifndef __ASSUME_PRIVATE_FUTEX".
---
sysdeps/i386/nptl/tcb-offsets.sym | 3 ---
sysdeps/i386/nptl/tls.h | 7 +++----
sysdeps/x86_64/nptl/tcb-offsets.sym | 3 ---
sysdeps/x86_64/nptl/tls.h | 7 +++----
4 files changed, 6 insertions(+), 14 deletions(-)
@@ -12,6 +12,3 @@ CLEANUP offsetof (struct pthread, cleanup)
CLEANUP_PREV offsetof (struct _pthread_cleanup_buffer, __prev)
MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock)
POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
-#ifndef __ASSUME_PRIVATE_FUTEX
-PRIVATE_FUTEX offsetof (tcbhead_t, private_futex)
-#endif
@@ -30,6 +30,9 @@
# include <kernel-features.h>
# include <dl-dtv.h>
+_Static_assert (__ASSUME_PRIVATE_FUTEX == 1,
+ "__ASSUME_PRIVATE_FUTEX != 1");
+
typedef struct
{
void *tcb; /* Pointer to the TCB. Not necessarily the
@@ -41,11 +44,7 @@ typedef struct
uintptr_t stack_guard;
uintptr_t pointer_guard;
int gscope_flag;
-#ifndef __ASSUME_PRIVATE_FUTEX
- int private_futex;
-#else
int __glibc_reserved1;
-#endif
/* Reservation of some values for the TM ABI. */
void *__private_tm[4];
/* GCC split stack support. */
@@ -12,9 +12,6 @@ MUTEX_FUTEX offsetof (pthread_mutex_t, __data.__lock)
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
VGETCPU_CACHE_OFFSET offsetof (tcbhead_t, vgetcpu_cache)
-#ifndef __ASSUME_PRIVATE_FUTEX
-PRIVATE_FUTEX offsetof (tcbhead_t, private_futex)
-#endif
-- Not strictly offsets, but these values are also used in the TCB.
TCB_CANCELSTATE_BITMASK CANCELSTATE_BITMASK
@@ -30,6 +30,9 @@
# include <kernel-features.h>
# include <dl-dtv.h>
+_Static_assert (__ASSUME_PRIVATE_FUTEX == 1,
+ "__ASSUME_PRIVATE_FUTEX != 1");
+
/* Replacement type for __m128 since this file is included by ld.so,
which is compiled with -mno-sse. It must not change the alignment
of rtld_savespace_sse. */
@@ -51,11 +54,7 @@ typedef struct
uintptr_t stack_guard;
uintptr_t pointer_guard;
unsigned long int vgetcpu_cache[2];
-# ifndef __ASSUME_PRIVATE_FUTEX
- int private_futex;
-# else
int __glibc_reserved1;
-# endif
int __glibc_unused1;
/* Reservation of some values for the TM ABI. */
void *__private_tm[4];
--
2.17.0