lib/uksched: Give scheduler init higher granularity w.r.t. allocators
Instead of using the same allocator for stack, auxiliary stack, TLS
and other structures, allow a caller of the scheduler initialization
function to pass different allocators for these if they want to.
Implement a generic stack allocation wrapper over a given Unikraft
memory allocator. The library receives as arguments an allocator and,
if libukvmem is enabled, a virtual address space and an initial size.
The library works in three ways:
1. If libukvmem is disabled, the library will make use of the allocator
received as argument to allocate the initial allocator structure and
Unikraft compliant stacks.
2. If libukvmem is enabled, the library will make use of the allocator
received as argument to allocate the initial allocator structure and
Unikraft compliant stacks. The difference from 1. is that the virtual
address space and the initial size arguments are now available. The
two arguments will hint how much of the stack to premap whenever they
are allocated first, i.e. what is the initial stack size before
on-demand paging kicks in.
3. If libukvmem is enabled AND the configuration option of the library
integrating page guards is enabled, the allocator given as argument
will only be used once when allocating the initial allocator structure,
while the virtual address space and initial size arguments will be used
to create stack VMA's, specific to libukvmem.
lib/ukvmem: Fix out of range `vma_end` found as last element of list
Consider the following case:
+------------+
|VMA to unmap|
+------------+ next VMA
+----------+ +----------+
|mapped VMA| |mapped VMA|
+----------+ +----------+
The current state of the code would simply assign `vma_end` to the
next mapped VMA without checking if the end of the VMA to unmap is
within its range. Fix this by adding this check and ensure we do
not assign `vma_end` to the next VMA if it does not meet the
requirements.
Sergiu Moga [Mon, 19 Feb 2024 09:24:59 +0000 (11:24 +0200)]
lib/ukvmem: Make stack VMA guards size configurable and end-to-end
Add end-to-end page guards to stack VMAs and make their size be
configurable: default 4 pages for top (to counter stack declared arrays)
and 1 page for bottom (to counter too many pop instructions).
Sergiu Moga [Tue, 13 Feb 2024 14:06:56 +0000 (16:06 +0200)]
{arch,lib,plat}: Align auxstack with regular stack configuration
Everything stack size or alignment related is defined in `arch/`.
Therefore, move everything auxiliary stack related there and rename
related definitions/configurations to have them aligned with the
normal stacks. Additionally, remove the no longer useful related
method `ukplat_auxsp_alloc`.
Rares Miculescu [Sat, 30 Mar 2024 10:06:40 +0000 (12:06 +0200)]
plat/kvm/x86: Update data types from implementation
`plat/kvm/x86/time.c` includes `include/uk/plat/time.h`, where data
types are updated. Update data types from `plat/kvm/x86/time.c`, so
they match with the data types from declaration.
lib/ukvmem/arch/arm: Fix `error_code` build error with correct `esr`
Commit 4d973417284a ("lib/ukvmem/arch: Do not print error message if demand paging disabled")
introduced a build error and a warning by copy-pasting the change from
x86 to Arm. This is incorrect as the trap context from Arm does not have
the `error_code` but the `esr` field instead. Fix this by using using the
corect field and correct string format.
Cezar Craciunoiu [Thu, 28 Mar 2024 10:40:31 +0000 (12:40 +0200)]
.github/workflows: Add catalog tests and depend on them
This adds a new job that will start all catalog 'core_merge' workflows
and poll once every 30s for the results. If at least one of them fails
then it will mark it as failed, otherwise all succeeding means a pass.
Test will fail if there are other ongoing catalog 'core_merge'
workflows, to protect again concurrency problems. Rerun if necessary.
After this runs and everything passes, staging is merged into stable.
This runs only on pushes to staging.
Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com> Reviewed-by: Alexander Jung <alex@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1363
Cezar Craciunoiu [Thu, 21 Mar 2024 15:09:14 +0000 (17:09 +0200)]
.github/workflows: Add job to merge staging to stable
If all tests pass on a push, this should move the commits from staging
to stable. This should allow for the default branch to become
'stable' afterwards.
Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com> Reviewed-by: Alexander Jung <alex@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1363
Compensate for the fact that some subsystems end up terminating
threads without being timerfd aware.
For example, posix-process may try to terminate all threads of a
given process without being aware that a thread may have open fd's.
In this case, a closed thread with an open timerfd results in the
timerfd still holding a reference to the released thread to terminate
it when it is closed, resulting in a double termination or memory
corruption.
Fix this by adding a destructor that, when called, uses the `priv` field
of `struct uk_thread`, initially assigned to the timerfd structure
holding this reference, to mark this reference as NULL so that double
termination is avoided.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1375
lib/posix-timerfd: Fix thread double free on timerfd release
Whenever a timer fd is released, the thread associated with its update
function is also released through a combination of `uk_thread_terminate`
and `uk_thread_release`. However, if the released thread is different
from the current thread then `uk_thread_terminate` also calls
`uk_thread_release` on its own, leading to a double free. This is always
the case as the release function is impossible to be called from the
update function.
Therefore, fix this by deleting the explicit call to `uk_thread_release`
and rely on the one implicitly called by `uk_thread_terminate`.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1375
Alexander Jung [Wed, 27 Mar 2024 16:39:13 +0000 (17:39 +0100)]
doc: Refactor README.md with new layout and latest info
This commit includes a large refactor to the top-level README.md
which aims to significantly improve initial understanding of
the Unikraft project, its capabilities, ways to get started,
how to get invovled and additional information about latest
cloud deployment options with KraftCloud.
Signed-off-by: Alexander Jung <alex@unikraft.io> Reviewed-by: Felipe Huici <felipe@unikraft.io> Approved-by: Felipe Huici <felipe@unikraft.io>
The header (first descriptor) of the virtio-blk request must always
come in one piece! By aligning to its size (16), we ensure that
it will be contained entirely in one page only, i.e. the
scatter-gather list will not process it as two segments, which
would result in two descriptors.
E.g. If the address ends something like 0x...ff8 then the header
will span 0x...ff8 -> 0x...008 crossing the next page and resulting
in the scatter-gather list splitting it into two segments and
thus into two descriptors, which QEMU seems to not like.
To help with this, declare the request header at the beginning
of the virtio-blk request structure and make its allocation
16-byte aligned, guaranteeing its length will never cross the page
boundary.
Sergiu Moga [Sun, 28 Jan 2024 15:52:51 +0000 (17:52 +0200)]
lib/uksglist: Move scatter-gather list save/restore to header
It may come in handy to do scatter-gather list save and restore
in places other than the scatter-gather library. Therefore, allow
others to see the corresponding definitions by placing them in
the header.
Simon Kuenzer [Mon, 4 Mar 2024 16:15:37 +0000 (17:15 +0100)]
lib/ukstreambuf: `uk_streambuf_memcpy()`: Note regarding last byte
A streambuffer that is initialized with `UK_STREAMBUF_C_TERMSHIFT` has a
special behaviour with regard to the last byte. It is intended to carry the
C-string termination symbol `\0`.
If `uk_streambuf_memcpy()` is used, the last byte is overwritten by
subsequent calls. This can be avoided by the subsequent call of
`uk_streambuf_reserve()` by shifting the end position by one byte. However,
if `UK_STREAMBUF_C_TERMSHIFT` is set, `uk_streambuf_reserve()` must be
called with 2 bytes: 1 for the shift and another to hold the termination
symbol.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1352
Simon Kuenzer [Mon, 4 Mar 2024 15:52:03 +0000 (16:52 +0100)]
lib/posix-environ: Deduplicate env variables during boot
This commit removes duplicate variable entries within the `environ` array.
Duplicate entries occur
1) at compile time, if the same variable has been preconfigured several
times
2) at runtime via the library parameter `env.vars`. A variable can be
declared multiple times if a value has already been set at compile time
or if a value has been set multiple times via the parameters.
Deduplication goes through each `environ` array entry and checks whether an
entry for the same variable already exists in the previous entries (lower
positions). If this is the case, the entry is written to the position of
the found entry. Since preconfigured values (compile time) are at the low
positions and, preconfigured values can be overwritten with library
parameters. The algorithm is designed not to rely on any memory allocators,
as we have to analyze and unify the entries very early during boot.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1352
Simon Kuenzer [Mon, 4 Mar 2024 15:51:07 +0000 (16:51 +0100)]
lib/nolibc: Add prototypes for `chdir()`, `fchdir()`
Introduces the prototypes for `chdir()`, `fchdir()` with `<unistd.h>`
if `lib/vfscore` is part of the build. `lib/vfscore` is providing
the libc wrapper implementation.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1352
Michalis Pappas [Wed, 13 Mar 2024 10:41:50 +0000 (11:41 +0100)]
lib/posix-futex: Clear thread's objects upon thread exit
If a thread creates a futex that is not cleared upon application exit
that futex will remain in futex_list after the unmap of the thread's
stack causing an abort on the next iteration of the list.
Sergiu Moga [Tue, 20 Feb 2024 10:43:32 +0000 (12:43 +0200)]
lib/ukvmem/arch: Do not print error message if demand paging disabled
In cases such as those of `lib/uknofault`, pafe faults may actually be
intentional. So, to avoid unnecessarily throwing out error messages,
check if on-demand paging was disabled prior to faulting.
Andrei Tatar [Fri, 23 Feb 2024 14:06:13 +0000 (15:06 +0100)]
lib/posix-poll: Fix missing epoll file locking
This fix adds missing epoll file locking/unlocking in
eventpoll_notify_close, which is called by legacy vfscore files on close
in order to remove them from the monitored list.
Andrei Tatar [Wed, 14 Feb 2024 15:38:21 +0000 (16:38 +0100)]
lib/posix-unixsocket: Fix NULL deref crash
Previously `unix_socket_recvfrom` would not check its `fromlen` argument
before dereferencing it, even though the API allows for it to be NULL.
This change fixes this oversight, eliminating a potential crash.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1326
Sergiu Moga [Mon, 19 Feb 2024 09:16:49 +0000 (11:16 +0200)]
drivers/virtio/net: Ensure half-page alignment for netbuf
Currently there is a bug where if the net buffer (of size 2048) is split
into more than one descriptor the VMM reports the vring as full and
leading to us returning an error and wasting IRQs. The buffer would
be split in multiple virtio descriptors if the scatter-gather list
notices its span crosses more than one page (i.e. the buffer is not
entirely contained in one page) since it is not guaranteed that the two
virtually contiguous pages are also contiguous physically. To avoid
having this happen make sure that the buffer is always contained in one
page by having it aligned to half a page: if the buffer is half a page
in size and it is also half a page aligned it is mathematically
guaranteed to be entirely contained in one single page.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1328
Andrei Tatar [Wed, 14 Feb 2024 15:43:42 +0000 (16:43 +0100)]
lib/nolibc: Provide fd functions without vfscore
This change makes nolibc provide file descriptor-related functions in
`unistd.h` when the corresponding syscalls are provided by posix-fd*
libraries, even without vfscore 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>
GitHub-Closes: #1327
Simon Kuenzer [Fri, 8 Mar 2024 13:10:14 +0000 (14:10 +0100)]
scripts/checkpatch: Do not warn about symbolic permissions
This commit switches the checkpatch warning for symbolic permissions off
(Examples are `S_IXUSR`, `S_IFREG`). Such a warning makes sense for a Linux
kernel but less for us: We normally compile our kernel code together with a
fully featured libc and even bind application logic directly to kernel
code. We do not have the classical user-/kernel- code separation and rather
prefer using symbolic values over numeric values.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1351
Sergiu Moga [Sat, 10 Feb 2024 11:08:37 +0000 (13:08 +0200)]
lib/vfscore: Ensure we return symlink target on `namei_resolve`
The `namei_resolve` method is different from its `*_no_follow` variants
as in it is supposed to follow the symbolic links and eventually return
the dentry of the final symlink target. However, if the first dentry
hit in the cache is a symlink, we no longer check if it is a symlink
or not and simply return it. To fix this, simply add a check: if current
dentry pointer is a symlink, jump to the symlink logic.
Michalis Pappas [Mon, 19 Feb 2024 06:26:41 +0000 (07:26 +0100)]
checkpatch: Use block comments for SPDX identifiers in C files
The linux kernel's convention is to use inline comments for SPDX
identifiers in C files for reasons related to tooling. According
to https://www.kernel.org/doc/html/next/process/license-rules.html
```
If a specific tool cannot handle the standard comment style, then the
appropriate comment mechanism which the tool accepts shall be used.
This is the reason for having the “/* */” style comment in C header
files. There was build breakage observed with generated .lds files
where ‘ld’ failed to parse the C++ comment. This has been fixed by
now, but there are still older assembler tools which cannot handle
C++ style comments.
```
Update checkpatch to retain Unikraft's convention to use block
comments on C files, as at the time of writing there is no
use-case of supporting legacy tools in Unikraft.
Signed-off-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1342
Michalis Pappas [Sat, 17 Feb 2024 08:05:11 +0000 (09:05 +0100)]
plat/xen/arm64: Update the interface of uk_intctlr_plat_probe()
Adapt Xen's implementation of uk_intctlr_plat_prob() to its updated
interface. The function now receives a pointer to `struct _gic_dev`
which is updated in-place.
Michalis Pappas [Sat, 17 Feb 2024 08:04:34 +0000 (09:04 +0100)]
drivers/ukintctlr/gic: Update the interface of uk_intctlr_plat_probe()
Adapt the call to uk_intctlr_plat_probe() to its updated interface.
The GIC driver now passes a reference to `struct _gic_dev` that is
updated in-place.
Michalis Pappas [Sat, 17 Feb 2024 06:30:12 +0000 (07:30 +0100)]
lib/ukintctlr: Update the interface of uk_intctlr_plat_probe()
Update the interface of uk_intctlr_plat_probe() to receive a pointer
to a single driver-defined mutable object. This fixes an issue on
platforms that use the default implementation where drivers updating
their data to the output of uk_intctlr_plat_probe() will use
uninitialized data.
Marco Schlumpp [Thu, 8 Feb 2024 14:46:10 +0000 (15:46 +0100)]
lib/posix-time: Alias CLOCK_MONOTONIC_RAW to CLOCK_MONOTONIC
We do not have time adjustments so the clocks are equivalent.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1324
During early 64-bit long mode boot entry we check for XSAVE, AVX and
FSGSBASE. Make sure that we fail booting if we configured Unikraft to
use these and they are not supported. However, if Unikraft is still not
configured for these, but other runtimes/apps may still benefit from
using them (e.g. Java using FSGSBASE), still check and try enabling
them but don't fail booting if they are not supported.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1323
Marco Schlumpp [Thu, 8 Feb 2024 14:49:15 +0000 (15:49 +0100)]
lib/posix-sysinfo: Use a more Linux compatible release string
Some software checks for the linux version number in the release string.
Just including a '5' at the beginning is not enough in some cases.
Therefore, just include some more digits.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1325
Simon Kuenzer [Thu, 25 Jan 2024 01:27:21 +0000 (02:27 +0100)]
lib/devfs: Remove stub for unmounting
This commit removes the stub for unmounting devfs during shutdown because
1) this is covered by the automatic unmount option of `lib/vfscore`,
2) or - if not taken care of - does not harm when not cleanly unmounted.
Simon Kuenzer [Thu, 25 Jan 2024 01:26:45 +0000 (02:26 +0100)]
lib/vfscore: Make automatic unmounting of filesystems independent
This commit makes the automatic unmounting of filesystems during shutdown
independent of the automatic mounting of filesystems. Only in the case that
automatic mounting is enabled, the unmounting option is activated.
Simon Kuenzer [Tue, 23 Jan 2024 15:08:16 +0000 (16:08 +0100)]
lib/vfscore: Add `ifinitrd0`, `ifnoinitrd0` to `ukopts` (fstab)
This commit introduces the Unikraft fstab options `ifinitrd0` and
`ifnotinitrd0`. These options make an fstab entry conditional to the case
if an initrd module exists and was loaded by the bootloader or virtual
machine monitor (VMM).
This can be used to hide or only activate certain fstab entries on the
presence or absence of an initrd.
Simon Kuenzer [Tue, 23 Jan 2024 11:43:06 +0000 (12:43 +0100)]
lib/vfscore: Introduce `ramfs` mount option for `extract`
This commit introduces a mount option for the simulated `extract`
filesystem driver. It can be set to one of the following values:
* 0: Do not mount an underlying ramfs
(same behavior as if ramfs option is absent)
* 1: Mount an underlying ramfs volume before extraction
(default if present without value)
* 2: Only mount underlying ramfs volume if nothing else is mounted
NOTE: This parameter only works meaningful for a mountpoint to
root (`/`) because in case mounting should happen, a submountpoint
cannot be created.
Simon Kuenzer [Tue, 23 Jan 2024 11:39:26 +0000 (12:39 +0100)]
lib/vfscore: Add missing dependency to `lib/ukatomic`
Unfortunately, `<uk/list.h>` has a dependency to `lib/ukatomic`. Because
we use `<uk/list.h>` in `lib/vfscore` we need to temporarily add this
dependency until a cleaner solution is found. Headers under `/include`
should never force a library dependency.
Simon Kuenzer [Tue, 23 Jan 2024 11:38:24 +0000 (12:38 +0100)]
lib/ukargparse: Introduce `uk_strnkeycmp()`
`uk_strnkeycmp()` is a helper function for parsing key-value pairs
that are represented in a C-string. The function returns with success
if the keyword matches with the one in a given C-string. In such a
case, it returns the byte offset of the beginning of the value. This
information can be used for further processing.
The functions `uk_nextarg()` and `uk_netxarg_r()` are helper functions
to process C-strings containing a list of arguments where the arguments
are separated by a special character (e.g., colon-separated).
The function is intended to be used to iterate over such arguments
strings.
This commit also adopts `lib/vfscore` to use the functions for fstab
parsing and `lib/uknetdev` to use the functions for kernel parameter
parsing. This is done for code deduplication.
Sergiu Moga [Tue, 16 Jan 2024 19:15:35 +0000 (21:15 +0200)]
lib/ukvmem: Add informative message on stack guard page is hit
There is no explicit message in case the guard page of a stack VMA is
hit, therefore add one. This is obviously useful to know right away
on an exception.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1263
Generally, unhandled page fault messages are very helpful to have.
Therefore, make it so that the message is printed with the lowest
debugging message: `CRIT`.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1263
Andrei Tatar [Mon, 5 Feb 2024 15:23:08 +0000 (16:23 +0100)]
lib/posix-sysinfo: Fix sethostname off-by-1 error
This change fixes an off-by-1 error in sethostname when checking the
length of the new hostname, leading to a missing terminating NUL byte in
the `nodename` field of `struct utsname`, contrary to the expected Linux
ABI.
Additionally, strncpy is replaced with a more appropriate memcpy call.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1307
Andrei Tatar [Mon, 5 Feb 2024 11:00:21 +0000 (12:00 +0100)]
lib/nolibc: Add get/sethostname to unistd.h
This change adds declarations of gethostname and sethostname to nolibc's
unistd.h when CONFIG_LIBPOSIX_SYSINFO is enabled.
Additionally, the sysinfo declarations are moved after shared includes.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1307
Marco Schlumpp [Thu, 1 Feb 2024 09:20:45 +0000 (10:20 +0100)]
lib/posix-process: Add option to context switch away from clone caller
Some applications are expecting to run on a cooperative scheduler and will
naively assume that the new thread will do some progress even if the clone
caller does not context-switch by blocking/yielding.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
GitHub-Closes: #1303
Andrei Tatar [Tue, 6 Feb 2024 17:58:36 +0000 (18:58 +0100)]
lib/ukfile: pollq: Remove uk_pollq_reregister
This change removes the `uk_pollq_reregister` function from the ukfile
pollqueue API, motivated by several factors:
- implementation is ugly and not obviously correct
- does not handle events already set on the target pollqueue
- it is no longer used by core unikraft or 3rd party libs
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
GitHub-Closes: #1310
Andrei Tatar [Tue, 6 Feb 2024 17:53:15 +0000 (18:53 +0100)]
lib/posix-poll: Fix EPOLL_CTL_MOD missing events
Previously a epoll_ctl(EPOLL_CTL_MOD) call that added new events to be
monitored would miss events already present on the target file.
This was due to a design error misunderstanding the semantics.
This change fixes this issue by making MOD behave as a pair of DEL & ADD
operations performed atomically on the epoll file, while minimizing
redundant work.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
GitHub-Closes: #1310
Andrei Tatar [Tue, 6 Feb 2024 19:11:26 +0000 (20:11 +0100)]
lib/nolibc: Expose FD_SETSIZE as Kconfig option
This change adds a Kconfig option to select the desired value for
FD_SETSIZE, defaulting to 64.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io>
GitHub-Closes: #1309
Radu Nichita [Wed, 24 Jan 2024 01:12:35 +0000 (03:12 +0200)]
Add README for posix-pipe library
Signed-off-by: Radu Nichita <radunichita99@gmail.com> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Approved-by: Stefan Jumarea <stefanjumarea02@gmail.com>
GitHub-Closes: #1275
Andrei Tatar [Wed, 31 Jan 2024 16:28:00 +0000 (17:28 +0100)]
lib/posix-fdio: ENOTTY for unsupported tty ioctls
This change makes ioctl universally return -ENOTTY for tty-specific
ioctls that are not supported by the file driver, which it in turn
signals by returning -ENOSYS.
Checkpatch-Ignore: ENOSYS Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1301
Marco Schlumpp [Thu, 1 Feb 2024 08:57:46 +0000 (09:57 +0100)]
lib/vfscore: Prevent superfluous slashes in working directory
The mount point can contain a trailing slash (for example the root mount
point has a path of "/"). The path that is concatenated to the mount point
also contains a slash at the beginning. Therefore, extra care must be taken
to prevent two slashes from appearing besides each other.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1302
Andrei Tatar [Thu, 4 Jan 2024 16:10:22 +0000 (17:10 +0100)]
lib/ukfile: Split poll chain initializers from values
This change splits the pollqueue chain ticket initializer macros into
explicit initializers and assignable anonymous values, allowing the
former to be used in static initializations, and the latter in variable
assignments. Dependant code is also updated.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1245
Andrei Tatar [Thu, 4 Jan 2024 16:00:01 +0000 (17:00 +0100)]
lib/ukfile: Split file state initializer from value
This change splits the file state initializer macro into an explicit
initializer and an assignable initial value, allowing the former to be
used in static initializations, and the latter in variable assignments.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1245
Andrei Tatar [Thu, 4 Jan 2024 15:49:15 +0000 (16:49 +0100)]
lib/ukfile: Split pollqueue initializer from value
This change splits the pollqueue initializer macro into an explicit
initializer and an assignable initial value, allowing the former to be
used in static initializations, and the latter in variable assignments.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1245
Andrei Tatar [Thu, 4 Jan 2024 15:38:12 +0000 (16:38 +0100)]
{include,lib/*}: Split refcount initializers from values
Previously refcount types defined in uk/refcount.h and uk/swrefcount.h
provided initializer macros in the form of anonymous struct values (i.e.
designated initializers cast to the struct type). This prevented them
from being used to initialize static variables with nested structs on
some compilers, most notably GCC up to version 12.
This change separates initializers from initial values as two different
macros, the first to be used for initializing (static) variables, with
the second meant for direct assignment to already declared structs.
In addition, all uses of refcount initializers in variable assignments
have been changed to correctly use initial value macros.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1245
Andrei Tatar [Thu, 11 Jan 2024 14:39:30 +0000 (15:39 +0100)]
lib/posix-poll: Fix select on files w/o epoll support
Previously calling select with an unpollable file one of the fd_sets
would immediately propagate the error from epoll. This is contrary to
behavior on Linux, where unpollable files in the read or write sets are
immediately returned as available, and ones in the except set are ignored.
This change corrects this behavior and brings it in line with Linux.
Andrei Tatar [Thu, 11 Jan 2024 14:31:44 +0000 (15:31 +0100)]
lib/posix-poll: Fix poll on files w/o epoll support
Previously calling poll() on a file not supporting epoll would propagate
the -EPERM error from epoll(); this is contrary to behavior on Linux,
where poll immediately returns with POLLIN|POLLOUT masked with the
requested events.
This change fixes this behavior, correctly handling unpollable files.
Andrei Tatar [Thu, 11 Jan 2024 14:25:23 +0000 (15:25 +0100)]
lib/posix-poll: Fix vfscore files w/o epoll support
This change makes epoll correctly handle vfscore files that do not
support being polled, such as filesystem files. Previously these would
be silently ignored, leading to hangs in epoll_wait.
Now epoll_ctl correctly errors out with -EPERM when attempting to
register a file descriptor from an unpollable vfscore file.
Andrei Tatar [Thu, 11 Jan 2024 15:47:17 +0000 (16:47 +0100)]
lib/posix-poll: Fix epoll crash on NULL event arg
Previously epoll_ctl would crash on EPOLL_CTL_ADD and EPOLL_CTL_MOD if
its event arg was NULL. No global checking is done since event==NULL is
a valid case for EPOLL_CTL_DEL.
This change fixes this oversight, safely returning -EFAULT on a NULL arg
for the add and mod operations.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Maria Pana <maria.pana4@gmail.com>
GitHub-Closes: #1259
Michalis Pappas [Tue, 23 Jan 2024 04:52:01 +0000 (05:52 +0100)]
lib/posix-mmap: Round-up madvise length to page size
According to [1] madvise() rounds up the length to a
multiple of page size. Round up the length to avoid
returning an error when the caller passes an unaligned
length value.
Michalis Pappas [Mon, 29 Jan 2024 12:54:47 +0000 (13:54 +0100)]
checkpatch: Retain 80 chars limit
The updated versio of checkpatch bumps the max line length to 100
characters. Pass `--max-line-length` to .checkpatch.conf to retain
the previously used 80 char limit.