]> xenbits.xensource.com Git - unikraft/libs/musl.git/commitdiff
Initialize TLS and reserve TCB space
authorDragos Iulian Argint <dragosargint21@gmail.com>
Sun, 14 Aug 2022 21:44:54 +0000 (00:44 +0300)
committerUnikraft <monkey@unikraft.io>
Thu, 24 Nov 2022 11:56:36 +0000 (11:56 +0000)
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 <dragosargint21@gmail.com>
Reviewed-by: Florin Postolache <florin.postolache80@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #9

Makefile.uk

index 27a1361415371240ab33478c193136e7bc0061d3..e0a34026dda4a5bef4e7c1b14a17b4f041325131 100644 (file)
 #  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