From f06320b964a3c8b9af7ffdc0105f013e5599a6b9 Mon Sep 17 00:00:00 2001 From: Sergiu Moga Date: Mon, 24 Mar 2025 19:27:26 +0200 Subject: [PATCH] Remove `musl`'s `vfork` functionality and use our own asm wrappers We are now using our own `vfork` assembly wrappers in the unikernel so drop current `vfork` assembly functions that we cannot use anyway for native syscalls and instead copy/reuse those defined by us in the core repository. Do this copy-paste so that in case if int the future there will appear differences between what we do in the core in those wrappers and what we need for musl, the musl wrappers stay the same. Signed-off-by: Sergiu Moga Approved-by: Michalis Pappas Reviewed-by: Andrei Tatar Reviewed-by: Michalis Pappas GitHub-Closes: #86 --- Makefile.uk | 1 + Makefile.uk.musl.process | 9 --------- arch/arm64/vfork.S | 13 +++++++++++++ arch/x86_64/vfork.S | 13 +++++++++++++ 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 arch/arm64/vfork.S create mode 100644 arch/x86_64/vfork.S diff --git a/Makefile.uk b/Makefile.uk index 33fdab5..5a984f3 100644 --- a/Makefile.uk +++ b/Makefile.uk @@ -170,6 +170,7 @@ 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 LIBMUSLGLUE_SRCS-y += $(LIBMUSL_BASE)/arch/$(CONFIG_UK_ARCH)/__clone.S +LIBMUSLGLUE_SRCS-$(CONFIG_LIBPOSIX_PROCESS_VFORK) += $(LIBMUSL_BASE)/arch/$(CONFIG_UK_ARCH)/vfork.S LIBMUSLGLUE_COMPFLAGS-y += -I$(LIBMUSL)/src/include LIBMUSLGLUE_COMPFLAGS-y += -I$(LIBMUSL)/src/internal LIBMUSLGLUE_CINCLUDES += -I$(LIBMUSL)/src/internal diff --git a/Makefile.uk.musl.process b/Makefile.uk.musl.process index 891fa3d..aed8d9d 100644 --- a/Makefile.uk.musl.process +++ b/Makefile.uk.musl.process @@ -44,13 +44,4 @@ LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/wait.c LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/waitid.c LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/waitpid.c -ifeq (x86_32,$(CONFIG_UK_ARCH)) -LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/i386/vfork.s|i386 -else ifeq (x86_64,$(CONFIG_UK_ARCH)) -LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/x86_64/vfork.s|x86_64 -else -LIBMUSL_PROCESS_SRCS-y += $(LIBMUSL)/src/process/vfork.c -endif - - $(eval $(call _libmusl_import_lib,process,$(LIBMUSL_PROCESS_HDRS-y),$(LIBMUSL_PROCESS_SRCS-y))) diff --git a/arch/arm64/vfork.S b/arch/arm64/vfork.S new file mode 100644 index 0000000..09a1f86 --- /dev/null +++ b/arch/arm64/vfork.S @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Copyright (c) 2025, Unikraft GmbH and The Unikraft Authors. + * Licensed under the BSD-3-Clause License (the "License"). + * You may not use this file except in compliance with the License. + */ + +/* + * NOTE: This code here is replicated from the core Unikraft repository, + * since we can't use musl's vfork wrapper. + */ +.global vfork +vfork: + b uk_syscall_e_vfork diff --git a/arch/x86_64/vfork.S b/arch/x86_64/vfork.S new file mode 100644 index 0000000..9015ae4 --- /dev/null +++ b/arch/x86_64/vfork.S @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Copyright (c) 2025, Unikraft GmbH and The Unikraft Authors. + * Licensed under the BSD-3-Clause License (the "License"). + * You may not use this file except in compliance with the License. + */ + +/* + * NOTE: This code here is replicated from the core Unikraft repository, + * since we can't use musl's vfork wrapper. + */ +.global vfork +vfork: + jmp uk_syscall_e_vfork -- 2.39.5