From bef98ef6b40be5b664ce3b6985b80f333b5ee3a1 Mon Sep 17 00:00:00 2001 From: Clement Dieperink Date: Wed, 17 Dec 2025 17:37:15 +0100 Subject: [PATCH] allow for syscall with empty implementation to hide warning message --- so3/kernel/syscalls.c | 12 ++++++++++++ so3/scripts/syscall_gen.sh | 15 +++++++++++---- so3/syscall.tbl | 6 ++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/so3/kernel/syscalls.c b/so3/kernel/syscalls.c index 251dc1430..2c17dc43f 100644 --- a/so3/kernel/syscalls.c +++ b/so3/kernel/syscalls.c @@ -36,12 +36,24 @@ extern uint32_t __get_syscall_stack_arg(uint32_t nr); extern void test_malloc(int test_no); +static long __sys_empty(syscall_args_t *args); + static const syscall_fn_t syscall_table[NR_SYSCALLS] = { [0 ... NR_SYSCALLS - 1] = NULL, /* Generated file with table element matching number to functions. */ #include }; +/** + * Callback for syscalls with empty implementation to remove the unhandled message for them. + * This is useful as MUSL will use some syscalls that aren't implemented in SO3 due to simplification + * over Linux. + */ +static long __sys_empty(syscall_args_t *args) +{ + return -ENOSYS; +} + /* * Process syscalls according to the syscall number passed in r7 on ARM and x8 on ARM64. * According to SO3 ABI, the syscall arguments are passed in r0-r5 on ARM and x0-x5 on ARM64. diff --git a/so3/scripts/syscall_gen.sh b/so3/scripts/syscall_gen.sh index 8adec6935..bfd557716 100755 --- a/so3/scripts/syscall_gen.sh +++ b/so3/scripts/syscall_gen.sh @@ -24,6 +24,9 @@ # - syscall.tbl: Declares all syscalls available on SO3 without taking into # account the CPU arch. This also provides configuration # requirement for a given syscall. +# Requirement can be set to EMPTY_IMPLEMENTATION, which will +# set a default function returning -ENOSYS for syscalls that +# are intentionally not implemented. # - syscall.h.in: Contains all syscall number which are necessary implemented # in SO3. This is a copy of the same file from musl library. # @@ -81,9 +84,13 @@ file_header "__SYSCALL_TABLE_H__" > "$outfile_table" valid_syscalls="$(grep -E "^[^#]" "$infile_table")" while read name requirement; do sys_cond["$name"]="$requirement" - + echo "#ifdef SYSCALL_$name" - echo -e "\t[SYSCALL_$name] = &__sys_$name," + if [ "$requirement" = "EMPTY_IMPLEMENTATION" ]; then + echo -e "\t[SYSCALL_$name] = &__sys_empty," + else + echo -e "\t[SYSCALL_$name] = &__sys_$name," + fi echo "#endif" done < <(echo "$valid_syscalls") >> "$outfile_table" @@ -100,13 +107,13 @@ grep -E "^#define " "$infile_number" | sed "s/^#define __NR_//" | { continue fi - if [ -n "${sys_cond[$name]}" ]; then + if [ -n "${sys_cond[$name]}" -a "${sys_cond[$name]}" != "EMPTY_IMPLEMENTATION" ]; then echo "#ifdef CONFIG_${sys_cond[$name]}" fi echo "#define SYSCALL_$name $number" - if [ -n "${sys_cond[$name]}" ]; then + if [ -n "${sys_cond[$name]}" -a "${sys_cond[$name]}" != "EMPTY_IMPLEMENTATION" ]; then echo "#endif" fi done diff --git a/so3/syscall.tbl b/so3/syscall.tbl index b60972a7c..639dd82af 100644 --- a/so3/syscall.tbl +++ b/so3/syscall.tbl @@ -68,3 +68,9 @@ send NET sendto NET setsockopt NET brk PROC_ENV + +# TODO: implement. Heavily used in MUSL, so remove warning about it for now. +munmap EMPTY_IMPLEMENTATION + +# mprotect allows to set memory protection (read/write/execute), which isn't supported. +mprotect EMPTY_IMPLEMENTATION