This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] x86: Assert __ASSUME_PRIVATE_FUTEX == 1


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?


-- 
H.J.
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(-)

diff --git a/sysdeps/i386/nptl/tcb-offsets.sym b/sysdeps/i386/nptl/tcb-offsets.sym
index 695a810386..7d7fe5e71c 100644
--- a/sysdeps/i386/nptl/tcb-offsets.sym
+++ b/sysdeps/i386/nptl/tcb-offsets.sym
@@ -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
diff --git a/sysdeps/i386/nptl/tls.h b/sysdeps/i386/nptl/tls.h
index 8ca0924692..2ee451a4ac 100644
--- a/sysdeps/i386/nptl/tls.h
+++ b/sysdeps/i386/nptl/tls.h
@@ -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.  */
diff --git a/sysdeps/x86_64/nptl/tcb-offsets.sym b/sysdeps/x86_64/nptl/tcb-offsets.sym
index 8a25c482cb..be63404a16 100644
--- a/sysdeps/x86_64/nptl/tcb-offsets.sym
+++ b/sysdeps/x86_64/nptl/tcb-offsets.sym
@@ -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
diff --git a/sysdeps/x86_64/nptl/tls.h b/sysdeps/x86_64/nptl/tls.h
index 059f9675a0..d942b7446c 100644
--- a/sysdeps/x86_64/nptl/tls.h
+++ b/sysdeps/x86_64/nptl/tls.h
@@ -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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]