Don't set external __sysinfo in runtime This removes the assumption in the runtime that a __vsyscall references to a virtual syscall handler must be set by the runtime in an external libc. To ensure that musl can still initialise, there is a reference made to the vsyscall handler in the stack of the root task if one exists (otherwise the stack references a dummy). Signed-off-by: Curtis Millar <curtis@curtism.me>
diff --git a/CMakeLists.txt b/CMakeLists.txt index b9bf3bc..3296e25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -95,6 +95,7 @@ src/init.c src/memset.c src/memcpy.c + src/vsyscall.c ) if(("${KernelSel4Arch}" STREQUAL "aarch32") OR ("${KernelSel4Arch}" STREQUAL "arm_hyp")) list(
diff --git a/src/env.c b/src/env.c index 16124fb..ed627f8 100644 --- a/src/env.c +++ b/src/env.c
@@ -24,9 +24,6 @@ #define MIN_ALIGN_BYTES 16 #define MIN_ALIGNED __attribute__((aligned (MIN_ALIGN_BYTES))) -// Global vsyscall handler (defined in musllibc) -extern sel4runtime_size_t __sysinfo; - // Static TLS for initial thread. static char static_tls[CONFIG_SEL4RUNTIME_STATIC_TLS] MIN_ALIGNED = {}; @@ -304,10 +301,6 @@ env.program_header.headers = auxv[i].a_un.a_ptr; break; } - case AT_SYSINFO: { - __sysinfo = (sel4runtime_size_t)(auxv[i].a_un.a_ptr); - break; - } case AT_SEL4_BOOT_INFO: { seL4_BootInfo *bootinfo = auxv[i].a_un.a_ptr; if (bootinfo == SEL4RUNTIME_NULL) {
diff --git a/src/vsyscall.c b/src/vsyscall.c new file mode 100644 index 0000000..de07ad9 --- /dev/null +++ b/src/vsyscall.c
@@ -0,0 +1,19 @@ +/* + * Copyright 2020, Data61 + * Commonwealth Scientific and Industrial Research Organisation (CSIRO) + * ABN 41 687 119 230. + * + * This software may be distributed and modified according to the terms of + * the BSD 2-Clause license. Note that NO WARRANTY is provided. + * See "LICENSE_BSD2.txt" for details. + * + * @TAG(DATA61_BSD) + */ + +/* If no vsyscall implementation is provided, this dummy one is used. */ +long __sel4runtime_vsyscall(long sysnum, ...) +{ + return -1; +} + +long __attribute__((weak, alias("__sel4runtime_vsyscall"))) sel4_vsyscall(long sysnum, ...);