Sergiu Moga [Mon, 24 Mar 2025 17:27:26 +0000 (19:27 +0200)]
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.
Sergiu Moga [Mon, 24 Mar 2025 17:26:12 +0000 (19:26 +0200)]
Remove clone patches and use our own defined clone assembly wrappers
We are now using our own `__clone` assembly wrappers in the unikernel
so drop current `__clone` assembly functions that translate libc wrapper
arguments to syscall arguments 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.
WARNING: There is, however, a very notable difference.
There is a bug in our current native/musl glue code where there is
a mismatch between what we do with TLS size/alignment and what musl
does.
To avoid it (and possibly unknowingly break other things) we have to
keep the forced alignment of the child stack.
This bug has always existed, including in the clone wrapper we are
replacing which also did this alignment. The wrapper claimed something
about `movaps` that is not entirely true. Essentially, because of an
old clone patch (part of the same series that ported musl clone
to Unikraft) that also patches `pthread_create` claiming Unikraft needs
an aligned TLS (for some reason we do not yet know), the clone child
stack ends up misaligned by 8, which causes a `movaps` that somewhere
along the line tries to store something at `some_aligned_offset(%rbp)`
to generate a #GP because rbp itself is not aligned.
To workaround this, back then this was the solution: a forced child
stack alignment. So keep this workaround for now, and debug this ASAP.
As for why we have this alignment for ARM64 as well, I can not be
sure, but I guess it simply aligned itself with the implementation of
x86 since it was introduced afterwards. Besides, it also makes use
of the same pthread_create code. Thus, keep aligning stuff for ARM64
as well.
Andrei Tatar [Mon, 24 Feb 2025 11:18:16 +0000 (12:18 +0100)]
Config.uk: Add posix-tty as dependency to stdio
This change adds an explicit dependency on posix-tty and its STDIO
option for when the libstdio sub-lib of musl is enabled.
This makes musl's assumption that fds 0, 1, 2 be opened to something
meaningful an explicit configuration requirement on the kernel.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #85
Andrei Tatar [Mon, 12 Feb 2024 21:11:15 +0000 (22:11 +0100)]
libsched: Add sys/membarrier.h to provided headers
Add sys/membarrier.h to the headers provided by libsched.
This header is used by uksched, which libsched pulls in.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #75
Simon Kuenzer [Tue, 6 Feb 2024 11:54:56 +0000 (12:54 +0100)]
gethostbyname: Option to use lwIPs `gethostbyname()`
This commit introduces redirecting `gethostbyname()` (and family) calls
to lwIP's implementation. This is only enabled if musl is configured to
forward DNS related requests to lwIP.
Simon Kuenzer [Tue, 6 Feb 2024 10:11:18 +0000 (11:11 +0100)]
getnameinfo: Copy lwip adapter code from `lib/newlib`
This commit copies the lwip glue code for `getnameinfo()` from `lib/newlib`
(https://github.com/unikraft/lib-newlib/commit/727d5eabd48f329df179be4a37dd40dd5d71151b,
Commit 727d5ea) to musl. It is only enabled if musl is configured to
forward DNS related requests to lwIP.
Simon Kuenzer [Wed, 31 Jan 2024 01:36:26 +0000 (02:36 +0100)]
getaddrinfo: Option to use lwIPs `getaddrinfo()`
This commit introduces an option to use lwIP's implementation of getaddrinfo.
It can be enabled if lwip is available. It will enable lwIP's DNS and socket
interfaces.
Alexander Jung [Tue, 11 Jul 2023 21:25:56 +0000 (21:25 +0000)]
Introduce `Library.uk`
This new file represents the first step towards proper versioning support of
external microlibrary in Unikraft. The file itself acts as mechanism for
holding metadata-only values about the microlibrary. This metadata is designed
to be compatible with GNU Make whilst simultaneously being human-readable and
readable by programs that are not GNU Make (e.g. tools such as KraftKit).
An important feature of this file is the inclusion of microlibrary versions.
In a later step, once relevant integrations have been made to Unikrat's core
build system and to relevant tools such as KraftKit, the user will be able to
see and select from different versions of the microlibrary.
In this initial commit, the relevant metadata is absorbed from both Makefile.uk,
Config.uk, but also includes new information such as SPDX License identifier.
Makefile.uk.musl.exit: Patch for case insensitive file systems
Add `exit` variant to _Exit.c to prevent symbol conflicts. This
is necessary since some file systems are case insensitive, and it could
otherwise lead to a conflict with the object resulted from _exit.c
Signed-off-by: Eduard-Florin Mihailescu <mihailescu.eduard@gmail.com> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #70
It seems some steps were missing in pthread structure initialization.
This patch does the following:
- zeroes pthread memory (previously potentially contained garbage after
uk_mem_align allocation)
- initializes tsd
- sets detach_state to joinable
Signed-off-by: Aleksandr Iashchenko <Aleksandr.Iashchenko@opensynergy.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #59
Marc Rittinghaus [Wed, 17 May 2023 13:17:45 +0000 (15:17 +0200)]
Config.uk: Allow deselection of ukmmap
With posix-mmap we have an alternative implementation of the memory
management functions such as mmap, mprotect, etc. To be able to select
posix-mmap, we must deselect ukmmap. Thus, this commit removes the
hard dependency.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #52
Andrei Tatar [Wed, 19 Jul 2023 08:05:35 +0000 (10:05 +0200)]
Makefile.uk: Condition header inclusion on Kconfig
Previously musl would add its headers to the include path
unconditionally when its Makefile would be included.
This change conditions this inclusion on whether musl is enabled via
Kconfig.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #54
Andrei Tatar [Wed, 19 Jul 2023 07:57:14 +0000 (09:57 +0200)]
Condition AARCH64 TCB unreservation on Kconfig
Previously musl would unconditionally call
`aarch64_no_reserved_tcb_overlap` when building under aarch64.
This change makes this call happen only when musl is selected.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #54
Andrei Tatar [Wed, 7 Jun 2023 09:10:30 +0000 (11:10 +0200)]
Makefile.uk: Condition TCB reserve on Kconfig
Previously musl's Makefile would unconditionally reserve a TCB size,
regardless of whether musl was selected for build in Kconfig.
This change makes this reservation happen only when musl is selected.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #54
Eduard Vintilă [Wed, 26 Jul 2023 09:28:00 +0000 (12:28 +0300)]
patches: Add syscall function prototype
The `sys/syscall.h` header is missing a declaration for the `syscall()`
function, which may lead to `implicit declaration` warnings that could
be treated as errors (i.e. by the GO runtime)
We also include Unikraft's `syscall_nrs2.h` header which provides
definitions for the `__NR_` macros needed by some libraries.
Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #67
Andrei Tatar [Tue, 8 Aug 2023 10:20:07 +0000 (12:20 +0200)]
Config.uk: Select libcompiler-rt for libcomplex
The cpow* functions provided by libcomplex make use of the `__mul?c3`
functions, implemented by libcompiler-rt, when building with either
Clang or GCC.
Therefore, this change makes musl unconditionally select libcompiler-rt
when building libcomplex.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #64
Andrei Tatar [Wed, 28 Jun 2023 16:09:33 +0000 (18:09 +0200)]
Makefile.uk: Silence warnings
This commit changes several warning flags:
-Wno-error=sign-compare removed
-Wno-unused-value relegated to the glue code
-Wno-cast-function-type is sent to clang as well as GCC
-Wno-macro-redefined and -Wno-string-plus-int added for clang
-Wno-unused added for the entire library
-K&R-style declaration warnings silenced by -Wno-old-style-declaration
(GCC) or -Wno-deprecated-non-prototype (clang)
-Wno-unused-command-line-argument to silence assembler
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #61
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 <sergiu@unikraft.io> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #62
Miguel Rodrigues [Thu, 11 May 2023 13:18:14 +0000 (14:18 +0100)]
Makefile.uk: Fix gcc specific warnings
-Wno-restrict, Wno-unused-but-set-variable, -Wno-maybe-unitialized and
-Wno-format-contains-nul are gcc-specific flags, so include them only when
compiling with gcc and not with clang.
Signed-off-by: Miguel Rodrigues <migb.rodrigues@gmail.com> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #51
Andrei Tatar [Thu, 4 May 2023 08:34:06 +0000 (10:34 +0200)]
Fix typo in macro definition
Previously we defined the macro `UK_LIBC_SYSCALL`, however this is not
used anywhere in unikraft; `UK_LIBC_SYSCALLS` is most likely what was
meant. This commit fixes the typo.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Rares Miculescu <miculescur@gmail.com> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Eduard Vintilă <eduard.vintila47@gmail.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #45
The contents of the README.md file are not up-to-date. Replace them with
a short description of Musl, and point out that Musl is the default
Unikraft libc.
Signed-off-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Eduard Vintilă <eduard.vintila47@gmail.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #49
__muldc3 is implemented by lib-compiler-rt for clang, and emitting calls
to it is normal. While -ffast-math prevents these calls, it also enables
unsafe optimizations that might result in wrong results from math
functions.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #46
When using Clang to build Musl with complex numbers support, a linking
error appears: `__muldc3` symbol is undefined. For Clang, the `__muldc3`
symbol is implemented by `libcompiler-rt`.
As complex number support is not typically required by applications
(that use Musl), this commit disable it by setting the `LIBMUSL_COMPLEX`
option to `n`. If required, the application will enable
`LIBMUSL_COMPLEX` (set it to `y`) and, in the case of Clang, add
`libcompiler-rt`.
Signed-off-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Andrei Tatar <andrei@unikraft.io> Approved-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #47
Simon Kuenzer [Tue, 14 Mar 2023 16:38:49 +0000 (17:38 +0100)]
Environment variables with `lib/posix-environ`
Commit 980bf211 enabled code for managing environment variables with musl,
however they were never populated during boot. With PR ???, `posix-environ`
envrionment variables are officially supported by Unikraft. This commit
enables and integrates this implementation with musl.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #43
Marco Schlumpp [Fri, 3 Feb 2023 14:52:34 +0000 (15:52 +0100)]
Apply -ffreestanding for the musl source code
This is the corresponding commit for unikraft/unikraft#740. This
prevents a self dependency caused by compiler optimizations, because the
libc implementation cannot rely on underlying presence of a libc.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #35
Stefan Jumarea [Sat, 29 Apr 2023 18:53:22 +0000 (21:53 +0300)]
patches: Fix ioctl signature in function definition
The `ioctl()` function signature was changed to use an unsigned long as
a second argument, in order to match the definition in Linux, glibc and
our own implementation.
The function definition however was not changed, leading to build errors
due to function signature conflict.
Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Reviewed-by: Rares Miculescu <miculescur@gmail.com> Approved-by: Eduard Vintilă <eduard.vintila47@gmail.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #44
Marco Schlumpp [Tue, 18 Apr 2023 12:55:18 +0000 (14:55 +0200)]
Initialize pthread structure fields for non-pthread threads
If these fields are not initialized as expected by musl, then calls
to pthread functions such `pthread_getspecific` can return unexpected
values or even crash.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #41
Marco Schlumpp [Tue, 18 Apr 2023 12:55:03 +0000 (14:55 +0200)]
Fix the definition of the prlimit64 syscall
The `sys/resource.h` header adds #define-based redirection from
`prlimit64` to `prlimit` when `_GNU_SOURCE` is set. This causes our
`provided_syscalls` to incorrectly define `uk_syscall_r_prlimit` instead
of `uk_syscall_r_prlimit64`. By reordering, the headers we can side-step
this problem.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #41
Marco Schlumpp [Tue, 18 Apr 2023 12:54:52 +0000 (14:54 +0200)]
Forward abort calls to Unikraft's UK_CRASH
The signals are currently ignored and that causes musl to `exit` the
thread, which doesn't cause any output. Therefore, it's very unclear
what happened. By calling `UK_CRASH` there is a clear indication that
something went wrong.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #41
Marco Schlumpp [Tue, 18 Apr 2023 12:54:06 +0000 (14:54 +0200)]
Include ucontext header files
While musl doesn't provide an actual implementation for the legacy
ucontext API, the header is still useful to compile software against
musl. Also, some software only relies on the definitions in the header.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #41
Marco Schlumpp [Tue, 18 Apr 2023 12:53:56 +0000 (14:53 +0200)]
Fix dependency on fetch step
Because `fetch` was not really a file, make always tried to remake the
version file. Therefore, it also needed to recompile the file as the
mtime of the version file was updated.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #41
Marc Rittinghaus [Thu, 20 Apr 2023 10:20:56 +0000 (12:20 +0200)]
Fix ioctl signature
The signature of ioctl uses a signed int as second argument. This,
however, differs from the definition in Linux, glibc, and our own
implementation in Unikraft, which use an unsigned long. Since using
int has lead to all sorts of problems (e.g., overflow into sign bit),
this commit adopts unsigned long also for the musl imported
header.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #42
Marco Schlumpp [Fri, 9 Dec 2022 12:36:22 +0000 (13:36 +0100)]
Move _XOPEN_SOURCE define to library CFLAGS
Putting it into CFLAGS changes the behavior for all sources files in a
Unikraft build and changes them from the implicit _DEFAULT_SOURCE to
_XOPEN_SOURCE, which can break applications/libraries.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #33
When defining `getdents64` as a macro aliasing `getdents`, the
syscall shim layer complains.
This patch uses a typical C-style declaration of `getdents64()`. This,
combined with the `LFS64(getdents)`, aliasing used in
`src/dirent/__getdents.c` solves the issue with the syscall shim layer.
Signed-off-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #31
The patch properly defines `environ` as an array of pointers, the last
of which is NULL. In the previous definition, `environ` was NULL, which
is not OK. The definition is now replaced to an array of a single NULL
element.
Signed-off-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #30
Avoid `uk_syscall_set_tid_address()` for main thread
The uk_syscall_set_tid_address call should be used
to set the main thread's tid address within some
internal structures. At the moment, because it is
called before the initialization of the scheduler,
it fails causing the program to crash. A workaround
for this behavior is to set the tid to 0 if the
`__uk_sched_thread_current` variable is NULL, which
means that the scheduler is not initialized.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #29
Eduard Vintilă [Fri, 25 Nov 2022 11:22:20 +0000 (13:22 +0200)]
uk_init_tls: Change `uk_thread_tcb_fini` to `uk_thread_uktcb_fini`
This commit fixes a typo in which the function`uk_thread_uktcb_fini()`,
as declared in uksched's `tcb_impl.h`, was incorrectly referred to as
`uk_thread_tcb_fini()`.
Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #26
Razvan Virtan [Thu, 6 Oct 2022 12:52:29 +0000 (15:52 +0300)]
Enable FPSIMD support on ARM64
Some of the functions implemented in musl can't work without the
ARM64 FPSIMD registers. This will fail unikraft build with musl
when FPSIMD is not enabled.
Enable FPSIMD by default when lib-musl is selected in menuconfig.
Signed-off-by: Razvan Virtan <virtanrazvan@gmail.com> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #14
Stefan Jumarea [Thu, 27 Oct 2022 12:01:57 +0000 (15:01 +0300)]
Makefile.uk/misc: Always include the uname sources
When `LIB_POSIX_SYSINFO` is selected, the build fails
when using musl with an undefined reference to `uname`.
This commit removes the uname sources dependency of
the selection of `LIB_POSIX_SYSINFO`.
Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #18
Robert Kuban [Mon, 15 Aug 2022 13:43:34 +0000 (15:43 +0200)]
Add patch to replace open with openat with AT_FDCWD
This patch replaces calls to the open systemcall with the openat systemcall
with the AT_FDCWD argument if SYS_open is not defined, similar to the
original musl code.
This is necessary as the open systemcall is not available on aarch64.
Signed-off-by: Robert Kuban <robert.kuban@opensynergy.com> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #6
Add tgmath.h header when both complex and math sublibs are enabled.
This header unites all types of math trigonometric functions for all
types(float, double, long double and complex) under one definition.
The header is not needed by musl source files but could be required
by applications.
Signed-off-by: Florin Postolache <florin.postolache80@gmail.com> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #24
This commit ads in the Config.uk the following default selection:
`LIBPOSIX_PROCESS_INIT_PIDS`, which allows pid,tid assignation
However, there is a bug in the assignment of tids that
makes the tid of the main thread not available when the
LIBC TCB (i.e. pthread structure) is initialized. The
currently adopted solution is to hardcode the tid to 0.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Signed-off-by: Robert Kuban <robert.kuban@opensynergy.com> Reviewed-by: Florin Postolache <florin.postolache80@gmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #9
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 <dragosargint21@gmail.com> Reviewed-by: Florin Postolache <florin.postolache80@gmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #9
The clone wrapper is an assembly source file which will
invoke a `syscall` instruction. Since we want just a
function call, we need to change it accordingly.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Florin Postolache <florin.postolache80@gmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #9
The functions related to the TLS layout (like copying content)
are implemented in the unikraft core libraries.
To use them, we need to add glue source code.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Florin Postolache <florin.postolache80@gmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #9
`unmapself()` provides a detached thread the ability
to free the memory region allocated for the stack and
TLS. In the original version, this function does
`munmap()', which will deallocate the thread's stack,
after which it executes exit() (NB: SYS_exit). This
works because there is another stack in the Kernel.
Since this does not exist in Unikraft, we implement
our version of unmapself.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Florin Postolache <florin.postolache80@gmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #9
`__set_thread_area()` is a function that is usually
architecture dependent, it sets the tls pointer in the
fs register. An `arch_prctl` system call is used. We
are replacing this call with a custom version because
`arch_prctl()` is not implemented in Unikraft at the
moment.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Florin Postolache <florin.postolache80@gmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #9
Comment the sources corresponding to the functions
__unmapself() (for detached threads) and
__set_thread_area() (for setting the fs register
to the tls pointer) because they will be reintroduced
as glue code.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Florin Postolache <florin.postolache80@gmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #9
This commit adds a call in Makefile.uk to reserve the space
needed for the LIBC TCB (e.g. `pthread` structure)
and adds 3 glue code files:
`__uk_init_tls.c` - initialize an Unikraft TLS
`__uk_unmapself.c` - allows unmapping for detached threads
`__set_thread_area.c` - bypass for arch_prctl() syscall for
setting the tls pointer
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Florin Postolache <florin.postolache80@gmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #9
This patch was introduced to modify the prototype of the
`ioctl()` function when it was exported directly from vfscore.
Now, since we want to keep the wrapper in musl, we leave the
function prototype unchanged. The patch is no longer needed.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #5
Musl wrappers use a binary system call, e.g. for x86_64 the `syscall`
instruction is used which is a trap. In a single-address-space OS as an Unikraft
unikernel this is just overhead. Hence, we changed the way musl deals with
syscall handling by using some syscall shim layer macros.
Those will replace binary system calls with function calls.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #5
In the previous version, wrappers over system calls (e.g. `read ()`)
were defined in syscall shim layer. Since we want to maintain musl as
vanilla as possible, we have re-introduced these wrappers.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #5
We need to set the LIBSYSCALL_SHIM_NOWRAPPER field in the configuration
file to prevent syscall shim layer from creating system call wrappers.
These wrappers are already defined in musl.
Signed-off-by: Dragos Iulian Argint <dragosargint21@gmail.com> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #5
Robert Kuban [Tue, 25 Oct 2022 16:41:24 +0000 (18:41 +0200)]
Remove include directory from clean list
The current clean rule in the Unikraft build system can not remove
directories and terminates with an error if there is a directory in
the list of files to clean.
This commit removes the include directory inside the lib-musl build
directory from the clean list.
Since each sublibrary has a separate subdirectories in the include
directory, this change will not make headers accessible which would have
been deleted by the clean rule.
Alternatives considered:
1. Enable the build rule to remove directories.
This would lead to the uk_clean_list not containing a complete
lists of files to remove anymore and makes the potential damage
of errors in the clean list much higher.
2. Add every header file into the `LIBMUSL_CLEAN` variable.
This could be done in `_libmusl_import_lib` and would remove the
linked headers, but would still leave the directory tree.
3. Do not create the links, but include from the origin directory.
This would remove the ability to filter header files in the
sublibrary makefile.
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 <florin.postolache80@gmail.com> Reviewed-by: Dragos Iulian Argint <dragosargint21@gmail.com> Approved-by: Simon Kuenzer <simon.kuenzer@neclab.eu> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #10
The musl libc provides its own wrappers around syscalls, which we prefer
to the shim-layer-generated ones as they often do additional
bookkeeping. And we can't have both as it would lead to conflicts.
Signed-off-by: Cyril Soldani <cyril.soldani@uliege.be> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #3