From: Robert Kuban Date: Wed, 27 Jul 2022 11:31:44 +0000 (+0200) Subject: Add patch to modify clone wrapper. X-Git-Tag: RELEASE-0.11.0~17 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e2056bf3b192921d80b92b07e64dd3211a2a4e0c;p=unikraft%2Flibs%2Fmusl.git Add patch to modify clone wrapper. This patches substitutes the syscalls in the clone wrapper with normal function calls. Signed-off-by: Robert Kuban Reviewed-by: Eduard Vintilă Reviewed-by: Razvan Virtan Reviewed-by: Razvan Deaconescu Approved-by: Razvan Deaconescu Tested-by: Unikraft CI GitHub-Closes: #6 --- diff --git a/patches/0019-Modify-clone-wrapper.patch b/patches/0019-Modify-clone-wrapper.patch new file mode 100644 index 0000000..a4af6db --- /dev/null +++ b/patches/0019-Modify-clone-wrapper.patch @@ -0,0 +1,61 @@ +From 2ad50560ffad11f6bc1c7788ae733760f6d85f7f Mon Sep 17 00:00:00 2001 +From: Robert Kuban +Date: Thu, 11 Aug 2022 18:03:23 +0200 +Subject: [PATCH] Modify clone wrapper + +Signed-off-by: Robert Kuban +--- + src/thread/aarch64/clone.s | 24 ++++++++++++++++-------- + 1 file changed, 16 insertions(+), 8 deletions(-) + +diff --git a/src/thread/aarch64/clone.s b/src/thread/aarch64/clone.s +index 50af913c..cd1f956b 100644 +--- a/src/thread/aarch64/clone.s ++++ b/src/thread/aarch64/clone.s +@@ -1,12 +1,19 @@ + // __clone(func, stack, flags, arg, ptid, tls, ctid) + // x0, x1, w2, x3, x4, x5, x6 + +-// syscall(SYS_clone, flags, stack, ptid, tls, ctid) +-// x8, x0, x1, x2, x3, x4 ++// see: lib/posix-process/clone.c ++// uk_syscall_r_clone(flags, stack, ptid, tlsp, ctid) ++// x0, x1, x2, x3, x4 ++ ++// see: lib/posix-process/process.c ++// uk_syscall_r_exit(status) ++// x0 + + .global __clone + .type __clone,%function + __clone: ++ stp x29, x30, [sp, #-16]! ++ + // align stack and save func,arg + and x1,x1,#-16 + stp x0,x3,[x1,#-16]! +@@ -16,14 +23,15 @@ __clone: + mov x2,x4 + mov x3,x5 + mov x4,x6 +- mov x8,#220 // SYS_clone +- svc #0 ++ bl uk_syscall_r_clone + + cbz x0,1f + // parent ++ ldp x29, x30, [sp], #16 + ret +- // child ++ // child (SP is X1 from syscall now) + 1: ldp x1,x0,[sp],#16 +- blr x1 +- mov x8,#93 // SYS_exit +- svc #0 ++ blr x1 // call func(arg) ++ mov x0, xzr ++ bl uk_syscall_r_exit ++ wfi +-- +2.25.1 +