From 0dd44206dad243b940c5cdabc516e0854fdbb546 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Tue, 9 Apr 2019 14:59:30 -0700 Subject: [PATCH] [LibOS] glibc: make shim_tcb_t in glibc tcb compile time option This is a follow up patch of #556. https://github.com/oscarlab/graphene/pull/556 With #556, LibOS doesn't always stash libos tcb into glibc tcb depending on compile time option. This patch makes it compile time option to add shim_tcb_t to glibc tcb. So make it optional to embed shim_tcb_t into glibc tcb. Signed-off-by: Isaku Yamahata --- LibOS/Makefile | 8 ++++++++ LibOS/glibc-2.19.patch | 19 ------------------- LibOS/glibc-add-shim-tcb.patch | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 LibOS/glibc-add-shim-tcb.patch diff --git a/LibOS/Makefile b/LibOS/Makefile index b99a67f9..e0191905 100644 --- a/LibOS/Makefile +++ b/LibOS/Makefile @@ -59,6 +59,14 @@ GLIBC_PATCHES = \ glibc-fix-warning.patch \ glibc-no-pie.patch +# TODO: configuration +# SHIM_TCB_USE_GS=yes +SHIM_TCB_USE_GS= +ifneq (SHIM_THREAD_USE_GS, "yes") +GLIBC_PATCHES += \ + glibc-add-shim-tcb.patch +endif + $(GLIBC_SRC)/configure: $(GLIBC_PATCHES) Makefile [ -f $(GLIBC_SRC).tar.gz ] || \ for MIRROR in $(GLIBC_MIRRORS); do \ diff --git a/LibOS/glibc-2.19.patch b/LibOS/glibc-2.19.patch index c3ae7724..5711beb3 100644 --- a/LibOS/glibc-2.19.patch +++ b/LibOS/glibc-2.19.patch @@ -1350,25 +1350,6 @@ index cbb5e9e..9b87e25 100644 /* Replacement type for __m128 since this file is included by ld.so, which is compiled with -mno-sse. It must not change the alignment -@@ -67,6 +69,10 @@ typedef struct - # else - int __glibc_reserved1; - # endif -+ -+ shim_tcb_t shim_tcb; /* For graphene, we allocate a shim_tcb -+ in the real tcb. */ -+ - int rtld_must_xmm_save; - /* Reservation of some values for the TM ABI. */ - void *__private_tm[4]; -@@ -137,7 +143,6 @@ typedef struct - # define GET_DTV(descr) \ - (((tcbhead_t *) (descr))->dtv) - -- - /* Code to initially initialize the thread pointer. This might need - special attention since 'errno' is not yet available and if the - operation can cause a failure 'errno' must not be touched. @@ -154,7 +159,7 @@ typedef struct _head->self = _thrdescr; \ \ diff --git a/LibOS/glibc-add-shim-tcb.patch b/LibOS/glibc-add-shim-tcb.patch new file mode 100644 index 00000000..ddba08c2 --- /dev/null +++ b/LibOS/glibc-add-shim-tcb.patch @@ -0,0 +1,15 @@ +diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h +index cbb5e9e..9b87e25 100644 +--- a/nptl/sysdeps/x86_64/tls.h ++++ b/nptl/sysdeps/x86_64/tls.h +@@ -67,6 +67,10 @@ typedef struct + # else + int __glibc_reserved1; + # endif ++ ++ shim_tcb_t shim_tcb; /* For graphene, we allocate a shim_tcb ++ in the real tcb. */ ++ + int rtld_must_xmm_save; + /* Reservation of some values for the TM ABI. */ + void *__private_tm[4];