From: Sergiu Moga Date: Thu, 13 Jul 2023 16:17:59 +0000 (+0300) Subject: patches: Delete patching of `ioctl` call in `isatty` X-Git-Tag: RELEASE-0.14.0~15 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=f54ef2a58ae65713e591a165ae3ae4766a93f173;p=unikraft%2Flibs%2Fmusl.git patches: Delete patching of `ioctl` call in `isatty` Application such as `python3` use `isatty()`, which does an `ioctl()` with `TIOCGWINSZ` as an argument for checking whether it should invoke the interactive interpretor or just start interpreting a given file. Therefore, we may want to allow such function call to return an error if called upon a file from a non-pseudo filesystem such as `ramfs` or `9pfs`. Furthermore, since this patch is the middle one among the existing patches from an order standpoint, rename the starting index of the other patches to reflect the removal. Signed-off-by: Sergiu Moga Reviewed-by: Radu Nichita Reviewed-by: Stefan Jumarea Reviewed-by: Razvan Virtan Approved-by: Simon Kuenzer Tested-by: Unikraft CI GitHub-Closes: #62 --- diff --git a/patches/0010-Fix-stdio_write-output.patch b/patches/0010-Fix-stdio_write-output.patch new file mode 100644 index 0000000..7e428d9 --- /dev/null +++ b/patches/0010-Fix-stdio_write-output.patch @@ -0,0 +1,26 @@ +From 120d042546de02e005e668306ff4022bdaf784b4 Mon Sep 17 00:00:00 2001 +From: gaulthier gain +Date: Fri, 9 Oct 2020 15:32:04 +0000 +Subject: [PATCH] Fix stdio_write output + +Signed-off-by: gaulthier gain +--- + src/stdio/__stdio_write.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c +index d2d8947..cae0ea9 100644 +--- a/src/stdio/__stdio_write.c ++++ b/src/stdio/__stdio_write.c +@@ -24,7 +24,7 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) + return iovcnt == 2 ? 0 : len-iov[0].iov_len; + } + rem -= cnt; +- if (cnt > iov[0].iov_len) { ++ if (cnt >= iov[0].iov_len) { + cnt -= iov[0].iov_len; + iov++; iovcnt--; + } +-- +2.17.1 + diff --git a/patches/0010-Stub-istty-by-ignoring-ioctl.patch b/patches/0010-Stub-istty-by-ignoring-ioctl.patch deleted file mode 100644 index 825a144..0000000 --- a/patches/0010-Stub-istty-by-ignoring-ioctl.patch +++ /dev/null @@ -1,26 +0,0 @@ -From ab6c1cf39135f9b11524267a0d3b517b88f4ff27 Mon Sep 17 00:00:00 2001 -From: gaulthier gain -Date: Fri, 9 Oct 2020 15:18:24 +0000 -Subject: [PATCH] Stub istty by ignoring ioctl - -Signed-off-by: gaulthier gain ---- - src/unistd/isatty.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/unistd/isatty.c b/src/unistd/isatty.c -index 75a9c18..960a588 100644 ---- a/src/unistd/isatty.c -+++ b/src/unistd/isatty.c -@@ -6,7 +6,7 @@ - int isatty(int fd) - { - struct winsize wsz; -- unsigned long r = syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz); -+ unsigned long r = 0; //__syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz); - if (r == 0) return 1; - if (errno != EBADF) errno = ENOTTY; - return 0; --- -2.38.1 - diff --git a/patches/0011-Fix-stdio_write-output.patch b/patches/0011-Fix-stdio_write-output.patch deleted file mode 100644 index 7e428d9..0000000 --- a/patches/0011-Fix-stdio_write-output.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 120d042546de02e005e668306ff4022bdaf784b4 Mon Sep 17 00:00:00 2001 -From: gaulthier gain -Date: Fri, 9 Oct 2020 15:32:04 +0000 -Subject: [PATCH] Fix stdio_write output - -Signed-off-by: gaulthier gain ---- - src/stdio/__stdio_write.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c -index d2d8947..cae0ea9 100644 ---- a/src/stdio/__stdio_write.c -+++ b/src/stdio/__stdio_write.c -@@ -24,7 +24,7 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) - return iovcnt == 2 ? 0 : len-iov[0].iov_len; - } - rem -= cnt; -- if (cnt > iov[0].iov_len) { -+ if (cnt >= iov[0].iov_len) { - cnt -= iov[0].iov_len; - iov++; iovcnt--; - } --- -2.17.1 - diff --git a/patches/0011-add-SC_LEVEL1_DCACHE_LINESIZE-unistd_h.patch b/patches/0011-add-SC_LEVEL1_DCACHE_LINESIZE-unistd_h.patch new file mode 100644 index 0000000..23f1533 --- /dev/null +++ b/patches/0011-add-SC_LEVEL1_DCACHE_LINESIZE-unistd_h.patch @@ -0,0 +1,26 @@ +From 1ea6a69be49facc99b969831a4e27e954ae05da5 Mon Sep 17 00:00:00 2001 +From: gaulthier gain +Date: Tue, 6 Oct 2020 07:55:19 +0000 +Subject: [PATCH] Add _SC_LEVEL1_DCACHE_LINESIZE to unistd + +Signed-off-by: gaulthier gain +--- + include/unistd.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/unistd.h b/include/unistd.h +index 3e6356a..31729fe 100644 +--- a/include/unistd.h ++++ b/include/unistd.h +@@ -258,7 +258,7 @@ pid_t gettid(void); + + #include + +- ++#define _SC_LEVEL1_DCACHE_LINESIZE 130 + + #define _PC_LINK_MAX 0 + #define _PC_MAX_CANON 1 +-- +2.38.1 + diff --git a/patches/0012-Change-some-things-in-pthread_create.c.patch b/patches/0012-Change-some-things-in-pthread_create.c.patch new file mode 100644 index 0000000..9ff509b --- /dev/null +++ b/patches/0012-Change-some-things-in-pthread_create.c.patch @@ -0,0 +1,90 @@ +From cab8414305bdbb07a9adfa72682d110fd7365da9 Mon Sep 17 00:00:00 2001 +From: Dragos Iulian Argint +Date: Sun, 14 Aug 2022 20:14:33 +0300 +Subject: [PATCH] Change some things in pthread_create.c + +This patch replaces 2 function calls from musl with +2 custom ones and introduces an additional size +when allocating the map for a thread, `libc.tls_align`. +It is needed because Unikraft demands that the tls be aligned. + +Signed-off-by: Dragos Iulian Argint +--- + src/thread/pthread_create.c | 29 ++++++++++++++++++++++------- + 1 file changed, 22 insertions(+), 7 deletions(-) + +diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c +index 6f187ee..d6dd4c9 100644 +--- a/src/thread/pthread_create.c ++++ b/src/thread/pthread_create.c +@@ -7,6 +7,11 @@ + #include + #include + ++/* ++ * Unikraft version of `__unmapself()`. See `__uk_unmapself.c` ++ */ ++void __uk_unmapself(void *base, size_t size); ++ + static void dummy_0() + { + } +@@ -149,10 +154,15 @@ _Noreturn void __pthread_exit(void *result) + * processed above, so unregister it with the kernel. */ + if (self->robust_list.off) + __syscall(SYS_set_robust_list, 0, 3*sizeof(long)); +- +- /* The following call unmaps the thread's stack mapping +- * and then exits without touching the stack. */ +- __unmapself(self->map_base, self->map_size); ++ /* ++ * In the original code `__unampself()` was called here. ++ * That call unmaps the thread's stack mapping and then ++ * exits without touching the stack. However, we cannot ++ * do this since we don't have a kernel stack. We use ++ * a different approach and let the `idle` thread do the ++ * cleaning. Please refer to the `__uk_unampself.c` file. ++ */ ++ __uk_unmapself(self->map_base, self->map_size); + } + + /* Wake any joiner. */ +@@ -230,6 +240,11 @@ static void init_file_lock(FILE *f) + if (f && f->lock<0) f->lock = 0; + } + ++/* ++ * Unikraft version of `__copy_tls()` ++ */ ++void *__uk_copy_tls(unsigned char *); ++ + int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attrp, void *(*entry)(void *), void *restrict arg) + { + int ret, c11 = (attrp == __ATTRP_C11_THREAD); +@@ -283,7 +298,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att + } else { + guard = ROUND(attr._a_guardsize); + size = guard + ROUND(attr._a_stacksize +- + libc.tls_size + __pthread_tsd_size); ++ + libc.tls_size + libc.tls_align + __pthread_tsd_size); + } + + if (!tsd) { +@@ -301,12 +316,12 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att + } + tsd = map + size - __pthread_tsd_size; + if (!stack) { +- stack = tsd - libc.tls_size; ++ stack = tsd - libc.tls_size - libc.tls_align; + stack_limit = map + guard; + } + } + +- new = __copy_tls(tsd - libc.tls_size); ++ new = __uk_copy_tls(tsd - libc.tls_size); + new->map_base = map; + new->map_size = size; + new->stack = stack; +-- +2.38.1 + diff --git a/patches/0012-add-SC_LEVEL1_DCACHE_LINESIZE-unistd_h.patch b/patches/0012-add-SC_LEVEL1_DCACHE_LINESIZE-unistd_h.patch deleted file mode 100644 index 23f1533..0000000 --- a/patches/0012-add-SC_LEVEL1_DCACHE_LINESIZE-unistd_h.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 1ea6a69be49facc99b969831a4e27e954ae05da5 Mon Sep 17 00:00:00 2001 -From: gaulthier gain -Date: Tue, 6 Oct 2020 07:55:19 +0000 -Subject: [PATCH] Add _SC_LEVEL1_DCACHE_LINESIZE to unistd - -Signed-off-by: gaulthier gain ---- - include/unistd.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/include/unistd.h b/include/unistd.h -index 3e6356a..31729fe 100644 ---- a/include/unistd.h -+++ b/include/unistd.h -@@ -258,7 +258,7 @@ pid_t gettid(void); - - #include - -- -+#define _SC_LEVEL1_DCACHE_LINESIZE 130 - - #define _PC_LINK_MAX 0 - #define _PC_MAX_CANON 1 --- -2.38.1 - diff --git a/patches/0013-Change-some-things-in-pthread_create.c.patch b/patches/0013-Change-some-things-in-pthread_create.c.patch deleted file mode 100644 index 9ff509b..0000000 --- a/patches/0013-Change-some-things-in-pthread_create.c.patch +++ /dev/null @@ -1,90 +0,0 @@ -From cab8414305bdbb07a9adfa72682d110fd7365da9 Mon Sep 17 00:00:00 2001 -From: Dragos Iulian Argint -Date: Sun, 14 Aug 2022 20:14:33 +0300 -Subject: [PATCH] Change some things in pthread_create.c - -This patch replaces 2 function calls from musl with -2 custom ones and introduces an additional size -when allocating the map for a thread, `libc.tls_align`. -It is needed because Unikraft demands that the tls be aligned. - -Signed-off-by: Dragos Iulian Argint ---- - src/thread/pthread_create.c | 29 ++++++++++++++++++++++------- - 1 file changed, 22 insertions(+), 7 deletions(-) - -diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c -index 6f187ee..d6dd4c9 100644 ---- a/src/thread/pthread_create.c -+++ b/src/thread/pthread_create.c -@@ -7,6 +7,11 @@ - #include - #include - -+/* -+ * Unikraft version of `__unmapself()`. See `__uk_unmapself.c` -+ */ -+void __uk_unmapself(void *base, size_t size); -+ - static void dummy_0() - { - } -@@ -149,10 +154,15 @@ _Noreturn void __pthread_exit(void *result) - * processed above, so unregister it with the kernel. */ - if (self->robust_list.off) - __syscall(SYS_set_robust_list, 0, 3*sizeof(long)); -- -- /* The following call unmaps the thread's stack mapping -- * and then exits without touching the stack. */ -- __unmapself(self->map_base, self->map_size); -+ /* -+ * In the original code `__unampself()` was called here. -+ * That call unmaps the thread's stack mapping and then -+ * exits without touching the stack. However, we cannot -+ * do this since we don't have a kernel stack. We use -+ * a different approach and let the `idle` thread do the -+ * cleaning. Please refer to the `__uk_unampself.c` file. -+ */ -+ __uk_unmapself(self->map_base, self->map_size); - } - - /* Wake any joiner. */ -@@ -230,6 +240,11 @@ static void init_file_lock(FILE *f) - if (f && f->lock<0) f->lock = 0; - } - -+/* -+ * Unikraft version of `__copy_tls()` -+ */ -+void *__uk_copy_tls(unsigned char *); -+ - int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attrp, void *(*entry)(void *), void *restrict arg) - { - int ret, c11 = (attrp == __ATTRP_C11_THREAD); -@@ -283,7 +298,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att - } else { - guard = ROUND(attr._a_guardsize); - size = guard + ROUND(attr._a_stacksize -- + libc.tls_size + __pthread_tsd_size); -+ + libc.tls_size + libc.tls_align + __pthread_tsd_size); - } - - if (!tsd) { -@@ -301,12 +316,12 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att - } - tsd = map + size - __pthread_tsd_size; - if (!stack) { -- stack = tsd - libc.tls_size; -+ stack = tsd - libc.tls_size - libc.tls_align; - stack_limit = map + guard; - } - } - -- new = __copy_tls(tsd - libc.tls_size); -+ new = __uk_copy_tls(tsd - libc.tls_size); - new->map_base = map; - new->map_size = size; - new->stack = stack; --- -2.38.1 - diff --git a/patches/0013-This-is-the-clone-wrapper-that-musl-uses-for-x86_64.patch b/patches/0013-This-is-the-clone-wrapper-that-musl-uses-for-x86_64.patch new file mode 100644 index 0000000..76baba9 --- /dev/null +++ b/patches/0013-This-is-the-clone-wrapper-that-musl-uses-for-x86_64.patch @@ -0,0 +1,94 @@ +From c43bbea2beabc6a19da64db250d2fef4a71d760a Mon Sep 17 00:00:00 2001 +From: Dragos Iulian Argint +Date: Sun, 14 Aug 2022 13:44:32 +0300 +Subject: [PATCH] This is the clone wrapper that musl uses for x86_64. + +Three crucial changes are in this patch. The first is +the use of function calls instead of system calls. The +second is placing the function pointer of the thread onto +the child's stack. The third is aligning the parent's stack. + +Signed-off-by: Dragos Iulian Argint +--- + src/thread/x86_64/clone.s | 67 +++++++++++++++++++++++++-------------- + 1 file changed, 44 insertions(+), 23 deletions(-) + +diff --git a/src/thread/x86_64/clone.s b/src/thread/x86_64/clone.s +index 6e47bc0..b917159 100644 +--- a/src/thread/x86_64/clone.s ++++ b/src/thread/x86_64/clone.s +@@ -2,27 +2,48 @@ + .global __clone + .hidden __clone + .type __clone,@function ++/* call conv: rdi rsi rdx rcx r8 r9 8(%rsp) */ ++/* clone wrap: func stack flags arg ptid tls ctid */ ++/* sys_clone: flags stack ptid ctid tls */ ++ + __clone: +- xor %eax,%eax +- mov $56,%al +- mov %rdi,%r11 +- mov %rdx,%rdi +- mov %r8,%rdx +- mov %r9,%r8 +- mov 8(%rsp),%r10 +- mov %r11,%r9 +- and $-16,%rsi +- sub $8,%rsi +- mov %rcx,(%rsi) +- syscall +- test %eax,%eax +- jnz 1f +- xor %ebp,%ebp +- pop %rdi +- call *%r9 +- mov %eax,%edi +- xor %eax,%eax +- mov $60,%al +- syscall +- hlt +-1: ret ++ mov %rdi,%r11 ++ mov %rdx,%rdi /* rdi=flags */ ++ mov %r8,%rdx /* rdx=&ptid */ ++ mov %r9,%r8 /* r8=tls */ ++ mov 8(%rsp),%r10 ++ mov %r11,%r9 ++ and $-16,%rsi /* rsi=stack */ ++ sub $16,%rsi ++ mov %rcx,8(%rsi) /* push the argument onto the child’s stack */ ++ mov %r9,0(%rsi) /* push the function pointer */ ++ mov %r10,%rcx /* rcx=&ctid */ ++ /* ++ * Normally this wrapper will execute the clone system call. ++ * In Linux, when switching to kernel mode, the instructions ++ * are executed on another stack, the "kernel stack". In Unikraft ++ * we use the same stack, that's the beauty of single address ++ * space operating systems. However, there is a catch here. What ++ * if when we execute `uk_syscall_r_clone()' a `movaps` instruction ++ * (https://www.felixcloutier.com/x86/movaps) is used. These type ++ * of instructions assume the stack is aligned. A big error will ++ * appear in our case because we would not have the stack aligned. ++ * The function that calls this wrapper puts an argument on the stack, ++ * i.e. only 8 bytes. To make everyone happy, we align the stack to ++ * 16 bytes. Please note that we are talking here about the parent's ++ * stack, not the child's stack which we clearly aligned before. ++ */ ++ sub $8,%rsp ++ call uk_syscall_r_clone ++ test %eax,%eax ++ jnz 1f /* the parent jumps, the child doesn’t */ ++ xor %ebp,%ebp ++ pop %r9 /* extract the function in child context */ ++ pop %rdi /* extract the argument */ ++ call *%r9 /* call function */ ++ mov %eax,%edi ++ xor %eax,%eax ++ call uk_syscall_r_exit ++ hlt ++1: add $8,%rsp ++ ret +-- +2.38.1 + diff --git a/patches/0014-Comment-macros-to-stop-using-VDSO.patch b/patches/0014-Comment-macros-to-stop-using-VDSO.patch new file mode 100644 index 0000000..ec4227d --- /dev/null +++ b/patches/0014-Comment-macros-to-stop-using-VDSO.patch @@ -0,0 +1,64 @@ +From 52d58e37701b1433b45721107fa4c143a35ce7d0 Mon Sep 17 00:00:00 2001 +From: Florin Postolache +Date: Mon, 18 Jul 2022 20:39:32 +0300 +Subject: [PATCH] Comment macros to stop using VDSO + +The VDSO is responsible for the virtual system calls in a basic +linux application and makes so that some system calls will be faster +because the transition between kernel mode and user mode is eliminated. +Therefore, it shouldn't be used in Unikraft. At the moment, in musl +this feature is enabled and functions like __clock_gettime will generate +a segfault. + +Signed-off-by: Florin Postolache +--- + arch/aarch64/syscall_arch.h | 2 +- + arch/i386/syscall_arch.h | 4 ++-- + arch/x86_64/syscall_arch.h | 4 ++-- + 3 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/arch/aarch64/syscall_arch.h b/arch/aarch64/syscall_arch.h +index 504983a..699df67 100644 +--- a/arch/aarch64/syscall_arch.h ++++ b/arch/aarch64/syscall_arch.h +@@ -72,7 +72,7 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo + } + + #define VDSO_USEFUL +-#define VDSO_CGT_SYM "__kernel_clock_gettime" ++//#define VDSO_CGT_SYM "__kernel_clock_gettime" + #define VDSO_CGT_VER "LINUX_2.6.39" + + #define IPC_64 0 +diff --git a/arch/i386/syscall_arch.h b/arch/i386/syscall_arch.h +index f92b7aa..b0238ba 100644 +--- a/arch/i386/syscall_arch.h ++++ b/arch/i386/syscall_arch.h +@@ -83,7 +83,7 @@ static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a + } + + #define VDSO_USEFUL +-#define VDSO_CGT32_SYM "__vdso_clock_gettime" ++//#define VDSO_CGT32_SYM "__vdso_clock_gettime" + #define VDSO_CGT32_VER "LINUX_2.6" +-#define VDSO_CGT_SYM "__vdso_clock_gettime64" ++//#define VDSO_CGT_SYM "__vdso_clock_gettime64" + #define VDSO_CGT_VER "LINUX_2.6" +diff --git a/arch/x86_64/syscall_arch.h b/arch/x86_64/syscall_arch.h +index 92d5c17..e99279e 100644 +--- a/arch/x86_64/syscall_arch.h ++++ b/arch/x86_64/syscall_arch.h +@@ -62,9 +62,9 @@ static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long + } + + #define VDSO_USEFUL +-#define VDSO_CGT_SYM "__vdso_clock_gettime" ++//#define VDSO_CGT_SYM "__vdso_clock_gettime" + #define VDSO_CGT_VER "LINUX_2.6" +-#define VDSO_GETCPU_SYM "__vdso_getcpu" ++//#define VDSO_GETCPU_SYM "__vdso_getcpu" + #define VDSO_GETCPU_VER "LINUX_2.6" + + #define IPC_64 0 +-- +2.38.1 diff --git a/patches/0014-This-is-the-clone-wrapper-that-musl-uses-for-x86_64.patch b/patches/0014-This-is-the-clone-wrapper-that-musl-uses-for-x86_64.patch deleted file mode 100644 index 76baba9..0000000 --- a/patches/0014-This-is-the-clone-wrapper-that-musl-uses-for-x86_64.patch +++ /dev/null @@ -1,94 +0,0 @@ -From c43bbea2beabc6a19da64db250d2fef4a71d760a Mon Sep 17 00:00:00 2001 -From: Dragos Iulian Argint -Date: Sun, 14 Aug 2022 13:44:32 +0300 -Subject: [PATCH] This is the clone wrapper that musl uses for x86_64. - -Three crucial changes are in this patch. The first is -the use of function calls instead of system calls. The -second is placing the function pointer of the thread onto -the child's stack. The third is aligning the parent's stack. - -Signed-off-by: Dragos Iulian Argint ---- - src/thread/x86_64/clone.s | 67 +++++++++++++++++++++++++-------------- - 1 file changed, 44 insertions(+), 23 deletions(-) - -diff --git a/src/thread/x86_64/clone.s b/src/thread/x86_64/clone.s -index 6e47bc0..b917159 100644 ---- a/src/thread/x86_64/clone.s -+++ b/src/thread/x86_64/clone.s -@@ -2,27 +2,48 @@ - .global __clone - .hidden __clone - .type __clone,@function -+/* call conv: rdi rsi rdx rcx r8 r9 8(%rsp) */ -+/* clone wrap: func stack flags arg ptid tls ctid */ -+/* sys_clone: flags stack ptid ctid tls */ -+ - __clone: -- xor %eax,%eax -- mov $56,%al -- mov %rdi,%r11 -- mov %rdx,%rdi -- mov %r8,%rdx -- mov %r9,%r8 -- mov 8(%rsp),%r10 -- mov %r11,%r9 -- and $-16,%rsi -- sub $8,%rsi -- mov %rcx,(%rsi) -- syscall -- test %eax,%eax -- jnz 1f -- xor %ebp,%ebp -- pop %rdi -- call *%r9 -- mov %eax,%edi -- xor %eax,%eax -- mov $60,%al -- syscall -- hlt --1: ret -+ mov %rdi,%r11 -+ mov %rdx,%rdi /* rdi=flags */ -+ mov %r8,%rdx /* rdx=&ptid */ -+ mov %r9,%r8 /* r8=tls */ -+ mov 8(%rsp),%r10 -+ mov %r11,%r9 -+ and $-16,%rsi /* rsi=stack */ -+ sub $16,%rsi -+ mov %rcx,8(%rsi) /* push the argument onto the child’s stack */ -+ mov %r9,0(%rsi) /* push the function pointer */ -+ mov %r10,%rcx /* rcx=&ctid */ -+ /* -+ * Normally this wrapper will execute the clone system call. -+ * In Linux, when switching to kernel mode, the instructions -+ * are executed on another stack, the "kernel stack". In Unikraft -+ * we use the same stack, that's the beauty of single address -+ * space operating systems. However, there is a catch here. What -+ * if when we execute `uk_syscall_r_clone()' a `movaps` instruction -+ * (https://www.felixcloutier.com/x86/movaps) is used. These type -+ * of instructions assume the stack is aligned. A big error will -+ * appear in our case because we would not have the stack aligned. -+ * The function that calls this wrapper puts an argument on the stack, -+ * i.e. only 8 bytes. To make everyone happy, we align the stack to -+ * 16 bytes. Please note that we are talking here about the parent's -+ * stack, not the child's stack which we clearly aligned before. -+ */ -+ sub $8,%rsp -+ call uk_syscall_r_clone -+ test %eax,%eax -+ jnz 1f /* the parent jumps, the child doesn’t */ -+ xor %ebp,%ebp -+ pop %r9 /* extract the function in child context */ -+ pop %rdi /* extract the argument */ -+ call *%r9 /* call function */ -+ mov %eax,%edi -+ xor %eax,%eax -+ call uk_syscall_r_exit -+ hlt -+1: add $8,%rsp -+ ret --- -2.38.1 - diff --git a/patches/0015-Comment-macros-to-stop-using-VDSO.patch b/patches/0015-Comment-macros-to-stop-using-VDSO.patch deleted file mode 100644 index ec4227d..0000000 --- a/patches/0015-Comment-macros-to-stop-using-VDSO.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 52d58e37701b1433b45721107fa4c143a35ce7d0 Mon Sep 17 00:00:00 2001 -From: Florin Postolache -Date: Mon, 18 Jul 2022 20:39:32 +0300 -Subject: [PATCH] Comment macros to stop using VDSO - -The VDSO is responsible for the virtual system calls in a basic -linux application and makes so that some system calls will be faster -because the transition between kernel mode and user mode is eliminated. -Therefore, it shouldn't be used in Unikraft. At the moment, in musl -this feature is enabled and functions like __clock_gettime will generate -a segfault. - -Signed-off-by: Florin Postolache ---- - arch/aarch64/syscall_arch.h | 2 +- - arch/i386/syscall_arch.h | 4 ++-- - arch/x86_64/syscall_arch.h | 4 ++-- - 3 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/arch/aarch64/syscall_arch.h b/arch/aarch64/syscall_arch.h -index 504983a..699df67 100644 ---- a/arch/aarch64/syscall_arch.h -+++ b/arch/aarch64/syscall_arch.h -@@ -72,7 +72,7 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo - } - - #define VDSO_USEFUL --#define VDSO_CGT_SYM "__kernel_clock_gettime" -+//#define VDSO_CGT_SYM "__kernel_clock_gettime" - #define VDSO_CGT_VER "LINUX_2.6.39" - - #define IPC_64 0 -diff --git a/arch/i386/syscall_arch.h b/arch/i386/syscall_arch.h -index f92b7aa..b0238ba 100644 ---- a/arch/i386/syscall_arch.h -+++ b/arch/i386/syscall_arch.h -@@ -83,7 +83,7 @@ static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a - } - - #define VDSO_USEFUL --#define VDSO_CGT32_SYM "__vdso_clock_gettime" -+//#define VDSO_CGT32_SYM "__vdso_clock_gettime" - #define VDSO_CGT32_VER "LINUX_2.6" --#define VDSO_CGT_SYM "__vdso_clock_gettime64" -+//#define VDSO_CGT_SYM "__vdso_clock_gettime64" - #define VDSO_CGT_VER "LINUX_2.6" -diff --git a/arch/x86_64/syscall_arch.h b/arch/x86_64/syscall_arch.h -index 92d5c17..e99279e 100644 ---- a/arch/x86_64/syscall_arch.h -+++ b/arch/x86_64/syscall_arch.h -@@ -62,9 +62,9 @@ static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long - } - - #define VDSO_USEFUL --#define VDSO_CGT_SYM "__vdso_clock_gettime" -+//#define VDSO_CGT_SYM "__vdso_clock_gettime" - #define VDSO_CGT_VER "LINUX_2.6" --#define VDSO_GETCPU_SYM "__vdso_getcpu" -+//#define VDSO_GETCPU_SYM "__vdso_getcpu" - #define VDSO_GETCPU_VER "LINUX_2.6" - - #define IPC_64 0 --- -2.38.1 diff --git a/patches/0015-Modify-clone-wrapper.patch b/patches/0015-Modify-clone-wrapper.patch new file mode 100644 index 0000000..762121b --- /dev/null +++ b/patches/0015-Modify-clone-wrapper.patch @@ -0,0 +1,62 @@ +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 e3c8339..0b8abeb 100644 +--- a/src/thread/aarch64/clone.s ++++ b/src/thread/aarch64/clone.s +@@ -1,13 +1,20 @@ + // __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 + .hidden __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]! +@@ -17,14 +24,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.38.1 + diff --git a/patches/0016-Modify-clone-wrapper.patch b/patches/0016-Modify-clone-wrapper.patch deleted file mode 100644 index 762121b..0000000 --- a/patches/0016-Modify-clone-wrapper.patch +++ /dev/null @@ -1,62 +0,0 @@ -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 e3c8339..0b8abeb 100644 ---- a/src/thread/aarch64/clone.s -+++ b/src/thread/aarch64/clone.s -@@ -1,13 +1,20 @@ - // __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 - .hidden __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]! -@@ -17,14 +24,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.38.1 - diff --git a/patches/0017-include-Use-function-declaration-for-getdents64.patch b/patches/0017-include-Use-function-declaration-for-getdents64.patch new file mode 100644 index 0000000..79514d9 --- /dev/null +++ b/patches/0017-include-Use-function-declaration-for-getdents64.patch @@ -0,0 +1,33 @@ +From 40feadbd7fb360033089787a60b7d58deaae4892 Mon Sep 17 00:00:00 2001 +Message-Id: <40feadbd7fb360033089787a60b7d58deaae4892.1669764551.git.razvand@unikraft.io> +From: Razvan Deaconescu +Date: Wed, 30 Nov 2022 01:27:36 +0200 +Subject: [PATCH] include: Use function declaration for getdents64() + +When defining `getdents64` as a macro aliasing `getdents`, the syscall +shim layer complains. + +The declaration of `getdents64()`, combined with the `LFS64(getdents)` +aliasing used in `src/dirent/__getdents.c` solves this. + +Signed-off-by: Razvan Deaconescu +--- + include/dirent.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/dirent.h b/include/dirent.h +index 650ecf6..b72acaf 100644 +--- a/include/dirent.h ++++ b/include/dirent.h +@@ -65,7 +65,7 @@ int versionsort(const struct dirent **, const struct dirent **); + #define versionsort64 versionsort + #define off64_t off_t + #define ino64_t ino_t +-#define getdents64 getdents ++int getdents64(int, struct dirent64 *, size_t); + #endif + + #ifdef __cplusplus +-- +2.38.1 + diff --git a/patches/0018-Use-uk_syscall_r_for_alt_socketcall-patch.patch b/patches/0018-Use-uk_syscall_r_for_alt_socketcall-patch.patch new file mode 100644 index 0000000..581ebd6 --- /dev/null +++ b/patches/0018-Use-uk_syscall_r_for_alt_socketcall-patch.patch @@ -0,0 +1,34 @@ +From e9ad1e7f22c64e6b7a26084ba61c51c45b09a5ca Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Eduard=20Vintil=C4=83?= +Date: Fri, 9 Dec 2022 23:28:05 +0200 +Subject: [PATCH 1/2] uk_syscall_r-patch +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Use the `uk_syscall_r()` variant for system call numbers +known only at runtime. + +Signed-off-by: Eduard Vintilă +--- + src/internal/syscall.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/internal/syscall.h b/src/internal/syscall.h +index 9419ea9..83fa584 100644 +--- a/src/internal/syscall.h ++++ b/src/internal/syscall.h +@@ -45,8 +45,8 @@ long __syscall_ret(unsigned long), __syscall(uk_syscall_arg_t, ...), + static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, long c, long d, long e, long f) + { + long r; +- if (cp) r = __syscall_cp(sys, a, b, c, d, e, f); +- else r = __syscall(sys, a, b, c, d, e, f); ++ if (cp) r = uk_syscall_r(sys, a, b, c, d, e, f); ++ else r = uk_syscall_r(sys, a, b, c, d, e, f); + if (r != -ENOSYS) return r; + #ifdef SYS_socketcall + if (cp) r = __syscall_cp(SYS_socketcall, sock, ((long[6]){a, b, c, d, e, f})); +-- +2.38.1 + diff --git a/patches/0018-include-Use-function-declaration-for-getdents64.patch b/patches/0018-include-Use-function-declaration-for-getdents64.patch deleted file mode 100644 index 79514d9..0000000 --- a/patches/0018-include-Use-function-declaration-for-getdents64.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 40feadbd7fb360033089787a60b7d58deaae4892 Mon Sep 17 00:00:00 2001 -Message-Id: <40feadbd7fb360033089787a60b7d58deaae4892.1669764551.git.razvand@unikraft.io> -From: Razvan Deaconescu -Date: Wed, 30 Nov 2022 01:27:36 +0200 -Subject: [PATCH] include: Use function declaration for getdents64() - -When defining `getdents64` as a macro aliasing `getdents`, the syscall -shim layer complains. - -The declaration of `getdents64()`, combined with the `LFS64(getdents)` -aliasing used in `src/dirent/__getdents.c` solves this. - -Signed-off-by: Razvan Deaconescu ---- - include/dirent.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/include/dirent.h b/include/dirent.h -index 650ecf6..b72acaf 100644 ---- a/include/dirent.h -+++ b/include/dirent.h -@@ -65,7 +65,7 @@ int versionsort(const struct dirent **, const struct dirent **); - #define versionsort64 versionsort - #define off64_t off_t - #define ino64_t ino_t --#define getdents64 getdents -+int getdents64(int, struct dirent64 *, size_t); - #endif - - #ifdef __cplusplus --- -2.38.1 - diff --git a/patches/0019-Use-uk_syscall_r_for_alt_socketcall-patch.patch b/patches/0019-Use-uk_syscall_r_for_alt_socketcall-patch.patch deleted file mode 100644 index 581ebd6..0000000 --- a/patches/0019-Use-uk_syscall_r_for_alt_socketcall-patch.patch +++ /dev/null @@ -1,34 +0,0 @@ -From e9ad1e7f22c64e6b7a26084ba61c51c45b09a5ca Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Eduard=20Vintil=C4=83?= -Date: Fri, 9 Dec 2022 23:28:05 +0200 -Subject: [PATCH 1/2] uk_syscall_r-patch -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Use the `uk_syscall_r()` variant for system call numbers -known only at runtime. - -Signed-off-by: Eduard Vintilă ---- - src/internal/syscall.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/internal/syscall.h b/src/internal/syscall.h -index 9419ea9..83fa584 100644 ---- a/src/internal/syscall.h -+++ b/src/internal/syscall.h -@@ -45,8 +45,8 @@ long __syscall_ret(unsigned long), __syscall(uk_syscall_arg_t, ...), - static inline long __alt_socketcall(int sys, int sock, int cp, long a, long b, long c, long d, long e, long f) - { - long r; -- if (cp) r = __syscall_cp(sys, a, b, c, d, e, f); -- else r = __syscall(sys, a, b, c, d, e, f); -+ if (cp) r = uk_syscall_r(sys, a, b, c, d, e, f); -+ else r = uk_syscall_r(sys, a, b, c, d, e, f); - if (r != -ENOSYS) return r; - #ifdef SYS_socketcall - if (cp) r = __syscall_cp(SYS_socketcall, sock, ((long[6]){a, b, c, d, e, f})); --- -2.38.1 - diff --git a/patches/0019-Use-ulong-in-ioctl.patch b/patches/0019-Use-ulong-in-ioctl.patch new file mode 100644 index 0000000..5765944 --- /dev/null +++ b/patches/0019-Use-ulong-in-ioctl.patch @@ -0,0 +1,13 @@ +diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h +index a9a2346..fed6b30 100644 +--- a/include/sys/ioctl.h ++++ b/include/sys/ioctl.h +@@ -112,7 +112,7 @@ extern "C" { + #define SIOCDEVPRIVATE 0x89F0 + #define SIOCPROTOPRIVATE 0x89E0 + +-int ioctl (int, int, ...); ++int ioctl (int, unsigned long, ...); + + #ifdef __cplusplus + } diff --git a/patches/0020-Use-ulong-in-ioctl-definition.patch b/patches/0020-Use-ulong-in-ioctl-definition.patch new file mode 100644 index 0000000..f3636b0 --- /dev/null +++ b/patches/0020-Use-ulong-in-ioctl-definition.patch @@ -0,0 +1,30 @@ +From 99e8a77e67e5a032f7e299d3c7466de00618d926 Mon Sep 17 00:00:00 2001 +From: Stefan Jumarea +Date: Sat, 29 Apr 2023 21:47:59 +0300 +Subject: [PATCH] [PATCH]: Change signature for ioctl + +The `ioctl()` function signature should be modified to match the definition +in Linux, glibc and our own implementation, since using `int` has lead +to a lot of problems (e.g. overflow into sign bit). + +Signed-off-by: Stefan Jumarea +--- + src/misc/ioctl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/misc/ioctl.c b/src/misc/ioctl.c +index 35804f02..ea4e9111 100644 +--- a/src/misc/ioctl.c ++++ b/src/misc/ioctl.c +@@ -125,7 +125,7 @@ static void convert_ioctl_struct(const struct ioctl_compat_map *map, char *old, + else memcpy(new+new_offset, old+old_offset, old_size-old_offset); + } + +-int ioctl(int fd, int req, ...) ++int ioctl(int fd, unsigned long req, ...) + { + void *arg; + va_list ap; +-- +2.25.1 + diff --git a/patches/0020-Use-ulong-in-ioctl.patch b/patches/0020-Use-ulong-in-ioctl.patch deleted file mode 100644 index 5765944..0000000 --- a/patches/0020-Use-ulong-in-ioctl.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h -index a9a2346..fed6b30 100644 ---- a/include/sys/ioctl.h -+++ b/include/sys/ioctl.h -@@ -112,7 +112,7 @@ extern "C" { - #define SIOCDEVPRIVATE 0x89F0 - #define SIOCPROTOPRIVATE 0x89E0 - --int ioctl (int, int, ...); -+int ioctl (int, unsigned long, ...); - - #ifdef __cplusplus - } diff --git a/patches/0020-locale-iconv-Add-character-map-option.patch b/patches/0020-locale-iconv-Add-character-map-option.patch new file mode 100644 index 0000000..757d695 --- /dev/null +++ b/patches/0020-locale-iconv-Add-character-map-option.patch @@ -0,0 +1,119 @@ +From 9bde85765c75459a1a43060a69d8dc39e1eaeba0 Mon Sep 17 00:00:00 2001 +From: Tu Dinh Ngoc +Date: Tue, 4 Apr 2023 20:07:08 +0000 +Subject: [PATCH] locale/iconv: Add character map option + +Musl's `iconv` includes lots of character sets by default. Provide an option +to disable most of them. + +Signed-off-by: Tu Dinh Ngoc +--- + src/locale/codepages.h | 3 ++- + src/locale/iconv.c | 10 ++++++++++ + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/src/locale/codepages.h b/src/locale/codepages.h +index 4e236ef..bec76af 100644 +--- a/src/locale/codepages.h ++++ b/src/locale/codepages.h +@@ -2,6 +2,7 @@ + "latin1\0" + "\0\100" + ++#if CONFIG_LIBMUSL_LOCALE_LEGACY + "iso88592\0" + "\0\50" + "\240\20\364\127\116\244\334\364\324\51\250\124\65\125\126\156\265\42\27\134" +@@ -317,4 +318,4 @@ + "\115\70\361\4\24\121\110\221\313\76\374\344\243\317\77\134\334\63\5\25" + "\125\130\161\5\26\131\150\41\13\65\326\110\63\115\65\60\304\40\303\14" + "\64\324\140\303\15\70\344\60\313\66\334\144\243\315\47" +- ++#endif +diff --git a/src/locale/iconv.c b/src/locale/iconv.c +index 3047c27..0d17ace 100644 +--- a/src/locale/iconv.c ++++ b/src/locale/iconv.c +@@ -48,6 +48,7 @@ static const unsigned char charmaps[] = + "utf16\0\0\312" + "ucs4\0utf32\0\0\313" + "ucs2\0\0\314" ++#if CONFIG_LIBMUSL_LOCALE_LEGACY + "eucjp\0\0\320" + "shiftjis\0sjis\0\0\321" + "iso2022jp\0\0\322" +@@ -56,6 +57,7 @@ static const unsigned char charmaps[] = + "gb2312\0\0\332" + "big5\0bigfive\0cp950\0big5hkscs\0\0\340" + "euckr\0ksc5601\0ksx1001\0cp949\0\0\350" ++#endif + #include "codepages.h" + ; + +@@ -66,6 +68,7 @@ static const unsigned short legacy_chars[] = { + #include "legacychars.h" + }; + ++#if CONFIG_LIBMUSL_LOCALE_LEGACY + static const unsigned short jis0208[84][94] = { + #include "jis0208.h" + }; +@@ -89,6 +92,7 @@ static const unsigned short ksc[93][94] = { + static const unsigned short rev_jis[] = { + #include "revjis.h" + }; ++#endif + + static int fuzzycmp(const unsigned char *a, const unsigned char *b) + { +@@ -205,6 +209,7 @@ static unsigned legacy_map(const unsigned char *map, unsigned c) + return x < 256 ? x : legacy_chars[x-256]; + } + ++#if CONFIG_LIBMUSL_LOCALE_LEGACY + static unsigned uni_to_jis(unsigned c) + { + unsigned nel = sizeof rev_jis / sizeof *rev_jis; +@@ -223,6 +228,7 @@ static unsigned uni_to_jis(unsigned c) + } + } + } ++#endif + + size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restrict out, size_t *restrict outb) + { +@@ -319,6 +325,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri + } + type = scd->state; + continue; ++#if CONFIG_LIBMUSL_LOCALE_LEGACY + case SHIFT_JIS: + if (c < 128) break; + if (c-0xa1 <= 0xdf-0xa1) { +@@ -518,6 +525,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri + c = ksc[c][d]; + if (!c) goto ilseq; + break; ++#endif + default: + if (!c) break; + c = legacy_map(map, c); +@@ -559,6 +567,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri + } + } + goto subst; ++#if CONFIG_LIBMUSL_LOCALE_LEGACY + case SHIFT_JIS: + if (c < 128) goto revout; + if (c == 0xa5) { +@@ -632,6 +641,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri + *(*out)++ = 'B'; + *outb -= 8; + break; ++#endif + case UCS2: + totype = UCS2BE; + case UCS2BE: +-- +2.34.1 + diff --git a/patches/0020-prlimit64_conflict.patch b/patches/0020-prlimit64_conflict.patch new file mode 100644 index 0000000..a554f85 --- /dev/null +++ b/patches/0020-prlimit64_conflict.patch @@ -0,0 +1,11 @@ +diff --git a/src/linux/prlimit.c b/src/linux/prlimit.c +--- a/src/linux/prlimit.c ++++ b/src/linux/prlimit.c (date 1680775764222) +@@ -1,6 +1,6 @@ + #define _GNU_SOURCE +-#include + #include "syscall.h" ++#include + + #define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0) + diff --git a/patches/0021-Use-ulong-in-ioctl-definition.patch b/patches/0021-Use-ulong-in-ioctl-definition.patch deleted file mode 100644 index f3636b0..0000000 --- a/patches/0021-Use-ulong-in-ioctl-definition.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 99e8a77e67e5a032f7e299d3c7466de00618d926 Mon Sep 17 00:00:00 2001 -From: Stefan Jumarea -Date: Sat, 29 Apr 2023 21:47:59 +0300 -Subject: [PATCH] [PATCH]: Change signature for ioctl - -The `ioctl()` function signature should be modified to match the definition -in Linux, glibc and our own implementation, since using `int` has lead -to a lot of problems (e.g. overflow into sign bit). - -Signed-off-by: Stefan Jumarea ---- - src/misc/ioctl.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/misc/ioctl.c b/src/misc/ioctl.c -index 35804f02..ea4e9111 100644 ---- a/src/misc/ioctl.c -+++ b/src/misc/ioctl.c -@@ -125,7 +125,7 @@ static void convert_ioctl_struct(const struct ioctl_compat_map *map, char *old, - else memcpy(new+new_offset, old+old_offset, old_size-old_offset); - } - --int ioctl(int fd, int req, ...) -+int ioctl(int fd, unsigned long req, ...) - { - void *arg; - va_list ap; --- -2.25.1 - diff --git a/patches/0021-locale-iconv-Add-character-map-option.patch b/patches/0021-locale-iconv-Add-character-map-option.patch deleted file mode 100644 index 757d695..0000000 --- a/patches/0021-locale-iconv-Add-character-map-option.patch +++ /dev/null @@ -1,119 +0,0 @@ -From 9bde85765c75459a1a43060a69d8dc39e1eaeba0 Mon Sep 17 00:00:00 2001 -From: Tu Dinh Ngoc -Date: Tue, 4 Apr 2023 20:07:08 +0000 -Subject: [PATCH] locale/iconv: Add character map option - -Musl's `iconv` includes lots of character sets by default. Provide an option -to disable most of them. - -Signed-off-by: Tu Dinh Ngoc ---- - src/locale/codepages.h | 3 ++- - src/locale/iconv.c | 10 ++++++++++ - 2 files changed, 12 insertions(+), 1 deletion(-) - -diff --git a/src/locale/codepages.h b/src/locale/codepages.h -index 4e236ef..bec76af 100644 ---- a/src/locale/codepages.h -+++ b/src/locale/codepages.h -@@ -2,6 +2,7 @@ - "latin1\0" - "\0\100" - -+#if CONFIG_LIBMUSL_LOCALE_LEGACY - "iso88592\0" - "\0\50" - "\240\20\364\127\116\244\334\364\324\51\250\124\65\125\126\156\265\42\27\134" -@@ -317,4 +318,4 @@ - "\115\70\361\4\24\121\110\221\313\76\374\344\243\317\77\134\334\63\5\25" - "\125\130\161\5\26\131\150\41\13\65\326\110\63\115\65\60\304\40\303\14" - "\64\324\140\303\15\70\344\60\313\66\334\144\243\315\47" -- -+#endif -diff --git a/src/locale/iconv.c b/src/locale/iconv.c -index 3047c27..0d17ace 100644 ---- a/src/locale/iconv.c -+++ b/src/locale/iconv.c -@@ -48,6 +48,7 @@ static const unsigned char charmaps[] = - "utf16\0\0\312" - "ucs4\0utf32\0\0\313" - "ucs2\0\0\314" -+#if CONFIG_LIBMUSL_LOCALE_LEGACY - "eucjp\0\0\320" - "shiftjis\0sjis\0\0\321" - "iso2022jp\0\0\322" -@@ -56,6 +57,7 @@ static const unsigned char charmaps[] = - "gb2312\0\0\332" - "big5\0bigfive\0cp950\0big5hkscs\0\0\340" - "euckr\0ksc5601\0ksx1001\0cp949\0\0\350" -+#endif - #include "codepages.h" - ; - -@@ -66,6 +68,7 @@ static const unsigned short legacy_chars[] = { - #include "legacychars.h" - }; - -+#if CONFIG_LIBMUSL_LOCALE_LEGACY - static const unsigned short jis0208[84][94] = { - #include "jis0208.h" - }; -@@ -89,6 +92,7 @@ static const unsigned short ksc[93][94] = { - static const unsigned short rev_jis[] = { - #include "revjis.h" - }; -+#endif - - static int fuzzycmp(const unsigned char *a, const unsigned char *b) - { -@@ -205,6 +209,7 @@ static unsigned legacy_map(const unsigned char *map, unsigned c) - return x < 256 ? x : legacy_chars[x-256]; - } - -+#if CONFIG_LIBMUSL_LOCALE_LEGACY - static unsigned uni_to_jis(unsigned c) - { - unsigned nel = sizeof rev_jis / sizeof *rev_jis; -@@ -223,6 +228,7 @@ static unsigned uni_to_jis(unsigned c) - } - } - } -+#endif - - size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restrict out, size_t *restrict outb) - { -@@ -319,6 +325,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri - } - type = scd->state; - continue; -+#if CONFIG_LIBMUSL_LOCALE_LEGACY - case SHIFT_JIS: - if (c < 128) break; - if (c-0xa1 <= 0xdf-0xa1) { -@@ -518,6 +525,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri - c = ksc[c][d]; - if (!c) goto ilseq; - break; -+#endif - default: - if (!c) break; - c = legacy_map(map, c); -@@ -559,6 +567,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri - } - } - goto subst; -+#if CONFIG_LIBMUSL_LOCALE_LEGACY - case SHIFT_JIS: - if (c < 128) goto revout; - if (c == 0xa5) { -@@ -632,6 +641,7 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri - *(*out)++ = 'B'; - *outb -= 8; - break; -+#endif - case UCS2: - totype = UCS2BE; - case UCS2BE: --- -2.34.1 - diff --git a/patches/0021-prlimit64_conflict.patch b/patches/0021-prlimit64_conflict.patch deleted file mode 100644 index a554f85..0000000 --- a/patches/0021-prlimit64_conflict.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff --git a/src/linux/prlimit.c b/src/linux/prlimit.c ---- a/src/linux/prlimit.c -+++ b/src/linux/prlimit.c (date 1680775764222) -@@ -1,6 +1,6 @@ - #define _GNU_SOURCE --#include - #include "syscall.h" -+#include - - #define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0) -