From: Dragos Iulian Argint Date: Sun, 14 Aug 2022 21:44:54 +0000 (+0300) Subject: Initialize TLS and reserve TCB space X-Git-Tag: RELEASE-0.11.0~30 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c3afcb8cf78141d96cee13754b78cf8b35268397;p=unikraft%2Flibs%2Fmusl.git Initialize TLS and reserve TCB space This commit adds a call in Makefile.uk to reserve the space needed for the LIBC TCB (e.g. `pthread` structure) and adds 3 glue code files: `__uk_init_tls.c` - initialize an Unikraft TLS `__uk_unmapself.c` - allows unmapping for detached threads `__set_thread_area.c` - bypass for arch_prctl() syscall for setting the tls pointer Signed-off-by: Dragos Iulian Argint Reviewed-by: Florin Postolache Reviewed-by: Simon Kuenzer Reviewed-by: Cezar Craciunoiu Reviewed-by: Razvan Deaconescu Reviewed-by: Robert Kuban Approved-by: Simon Kuenzer Tested-by: Unikraft CI GitHub-Closes: #9 --- diff --git a/Makefile.uk b/Makefile.uk index 27a1361..e0a3402 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -32,6 +32,14 @@ # POSSIBILITY OF SUCH DAMAGE. # +################################################################################ +# This will reserve space within `uk_tls` for the pthread structure in Musl. +# Please refer to ./arch/Makefile.rules for more details. +# For this version of Musl the size of "struct pthread" is 280. +################################################################################ +$(eval $(call ukarch_tls_tcb_reserve,280)) + + ################################################################################ # Library registration ################################################################################ @@ -82,7 +90,7 @@ $(LIBMUSL)/arch/$(ARCH)/bits/alltypes.h: $(LIBMUSL_BUILD)/.patched $(TOUCH) $@) # generate version.h -$(LIBMUSL)/src/internal/version.h: +$(LIBMUSL)/src/internal/version.h: $(call verbose_cmd,CONFIGURE,libmusl: $(notdir $@),\ printf '#define VERSION "%s"\n' "$$(cd $(LIBMUSL); sh tools/version.sh)" > $@ \ $(TOUCH) $@) @@ -126,6 +134,9 @@ CXXFLAGS += $(LIBMUSL_HDRS_FLAGS-y) # OS dependencies code - Glue between Unicore and musl ################################################################################ LIBMUSLGLUE_SRCS-y += $(LIBMUSL_BASE)/mem.c +LIBMUSLGLUE_SRCS-y += $(LIBMUSL_BASE)/__uk_init_tls.c +LIBMUSLGLUE_SRCS-y += $(LIBMUSL_BASE)/__uk_unmapself.c +LIBMUSLGLUE_SRCS-y += $(LIBMUSL_BASE)/__set_thread_area.c ################################################################################ # Core Standard Library