]> xenbits.xensource.com Git - unikraft/unikraft.git/log
unikraft/unikraft.git
11 months agolib/uksched: Give scheduler init higher granularity w.r.t. allocators
Sergiu Moga [Tue, 23 Apr 2024 17:33:11 +0000 (20:33 +0300)]
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.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1322

11 months agolib: Introduce generic (page guarded) stack allocator library
Sergiu Moga [Tue, 13 Feb 2024 14:15:15 +0000 (16:15 +0200)]
lib: Introduce generic (page guarded) stack allocator library

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.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1322

11 months agolib/ukvmem: Fix out of range `vma_end` found as last element of list
Sergiu Moga [Thu, 11 Apr 2024 10:21:00 +0000 (13:21 +0300)]
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.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1322

11 months agolib/ukvmem: Make stack VMA guards size configurable and end-to-end
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).

Checkpatch-Ignore: LONG_LINE_COMMENT
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1322

11 months ago{arch,lib,plat}: Align auxstack with regular stack configuration
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`.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1322

12 months agoarch/arm/arm64: Replace libc types with Unikraft defined
Rares Miculescu [Sat, 30 Mar 2024 08:44:37 +0000 (10:44 +0200)]
arch/arm/arm64: Replace libc types with Unikraft defined

Replace libc types with Unikraft defined, for `arch/` to become
independent of libc.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1369

12 months agoplat/kvm/x86: Update data types from implementation
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.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1368

12 months agoinclude/uk: Replace libc types with Unikraft defined
Rares Miculescu [Sat, 30 Mar 2024 10:05:01 +0000 (12:05 +0200)]
include/uk: Replace libc types with Unikraft defined

Replace libc types with Unikraft defined, for `include/uk/` to become
independent of libc.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1368

12 months ago.github/workflows: Tidy up unused checkpatch variables
Cezar Craciunoiu [Mon, 29 Apr 2024 15:12:12 +0000 (18:12 +0300)]
.github/workflows: Tidy up unused checkpatch variables

Those secrets were never actually set and are now baked in
into the tool itself that we use.

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1400

12 months agolib/ukvmem/arch/arm: Fix `error_code` build error with correct `esr`
Sergiu Moga [Fri, 19 Apr 2024 17:06:44 +0000 (20:06 +0300)]
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.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1388

13 months ago.github/workflows: Add catalog tests and depend on them
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

13 months ago.github/workflows: Add job to merge staging to stable
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

13 months agolib/vfscore: No-op `mkmp` on `/`
Sergiu Moga [Wed, 3 Apr 2024 09:21:06 +0000 (12:21 +0300)]
lib/vfscore: No-op `mkmp` on `/`

Issuing `mkdir` on `/` will result in `ENOTDIR` and it is also
unnecessary. Therefore, add a check for this case so that we can
ignore.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1376

13 months agolib/posix-timerfd: Add update thread destructor
Sergiu Moga [Tue, 2 Apr 2024 14:51:58 +0000 (17:51 +0300)]
lib/posix-timerfd: Add update thread destructor

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

13 months agolib/posix-timerfd: Fix thread double free on timerfd release
Sergiu Moga [Mon, 1 Apr 2024 06:49:29 +0000 (09:49 +0300)]
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

13 months agodoc: Correct links in README.md
Razvan Deaconescu [Tue, 2 Apr 2024 14:18:21 +0000 (17:18 +0300)]
doc: Correct links in README.md

Use correct links in `README.md`.

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Alexander Jung <alex@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Alexander Jung <alex@unikraft.io>
GitHub-Closes: #1374

13 months agodoc: Refactor README.md with new layout and latest info
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>
13 months agoRelease: v0.16.3 Telesto 1365/head RELEASE-0.16.3
Razvan Deaconescu [Wed, 20 Mar 2024 20:24:06 +0000 (22:24 +0200)]
Release: v0.16.3 Telesto

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
13 months agodriver/virtio/blk: Ensure request header stays in-page boundaries
Sergiu Moga [Sun, 28 Jan 2024 18:01:30 +0000 (20:01 +0200)]
driver/virtio/blk: Ensure request header stays in-page boundaries

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.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1290

13 months agolib/{uksglist,uknetdev}: Move `uk_sglist_append_netbuf` to `uknetdev`
Sergiu Moga [Sun, 28 Jan 2024 15:50:02 +0000 (17:50 +0200)]
lib/{uksglist,uknetdev}: Move `uk_sglist_append_netbuf` to `uknetdev`

Rename `uk_sglist_append_netbuf` to `uk_netbuf_sglist_append`
and move it to the libuknetdev, since that is its only client.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1290

13 months agolib/uksglist: Move scatter-gather list save/restore to header
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.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1290

13 months agolib/ukstreambuf: `uk_streambuf_memcpy()`: Note regarding last byte
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

13 months agolib/posix-environ: Deduplicate env variables during boot
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

13 months agolib/nolibc: Add prototypes for `chdir()`, `fchdir()`
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

13 months agolib/uksched: Add membarrier syscall
Andrei Tatar [Mon, 12 Feb 2024 18:54:56 +0000 (19:54 +0100)]
lib/uksched: Add membarrier syscall

This change adds the `membarrier` syscall to uksched.
Because SMP is not yet supported, the syscall is a no-op.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1321

13 months agolib/nolibc: Import `sys/membarrier.h` from musl
Andrei Tatar [Mon, 12 Feb 2024 18:48:52 +0000 (19:48 +0100)]
lib/nolibc: Import `sys/membarrier.h` from musl

Import sys/membarrier.h from musl for declarations of MEMBARRIER_CMD_*
constants.

Source:
Link: https://git.musl-libc.org/cgit/musl
Tag: v1.2.4 (f5f55d65)
Path: include/sys/membarrier.h

Checkpatch-Ignore: SPDX_LICENSE_TAG
Checkpatch-Ignore: FUNCTION_ARGUMENTS
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1321

13 months agodrivers/virtio/ring: Replace libc types with unikraft defined
Rares Miculescu [Thu, 29 Feb 2024 11:42:08 +0000 (13:42 +0200)]
drivers/virtio/ring: Replace libc types with unikraft defined

Replace libc types with Unikraft defined, for `drivers/virtio/ring/`
to become independent of libc.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1345

13 months agodrivers/virtio/pci: Replace libc types with unikraft defined
Rares Miculescu [Thu, 29 Feb 2024 11:37:10 +0000 (13:37 +0200)]
drivers/virtio/pci: Replace libc types with unikraft defined

Replace libc types with Unikraft defined, for `drivers/virtio/pci/`
to become independent of libc.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1345

13 months agodrivers/virtio/net: Replace libc types with unikraft defined
Rares Miculescu [Thu, 29 Feb 2024 10:43:37 +0000 (12:43 +0200)]
drivers/virtio/net: Replace libc types with unikraft defined

Replace libc types with Unikraft defined, for `drivers/virtio/net/`
to become independent of libc.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1345

13 months agodrivers/virtio/mmio: Replace libc types with unikraft defined
Rares Miculescu [Thu, 29 Feb 2024 10:30:19 +0000 (12:30 +0200)]
drivers/virtio/mmio: Replace libc types with unikraft defined

Replace libc types with Unikraft defined, for `drivers/virtio/mmio/`
to become independent of libc.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1345

13 months agodrivers/virtio/blk: Replace libc types with unikraft defined
Rares Miculescu [Thu, 29 Feb 2024 10:20:59 +0000 (12:20 +0200)]
drivers/virtio/blk: Replace libc types with unikraft defined

Replace libc types with Unikraft defined, for `drivers/virtio/blk/`
to become independent of libc.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1345

13 months agodrivers/virtio/9p: Replace libc types with unikraft defined
Rares Miculescu [Thu, 29 Feb 2024 09:41:43 +0000 (11:41 +0200)]
drivers/virtio/9p: Replace libc types with unikraft defined

Replace libc types with Unikraft defined, for `drivers/virtio/9p/`
to become independent of libc.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1345

13 months agodrivers/ukintctlr/gic: Replace libc types with Unikraft defined
Rares Miculescu [Wed, 28 Feb 2024 09:45:05 +0000 (11:45 +0200)]
drivers/ukintctlr/gic: Replace libc types with Unikraft defined

Replace libc types with Unikraft defined, for `drivers/ukintctlr/gic/`
to become independent of libc.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1344

13 months agodrivers/ukbus: Replace libc types with Unikraft defined
Rares Miculescu [Tue, 27 Feb 2024 08:59:46 +0000 (10:59 +0200)]
drivers/ukbus: Replace libc types with Unikraft defined

Replace libc types with Unikraft defined, for `drivers/ukbus/`
to become independent of libc.

Signed-off-by: Rares Miculescu <miculescur@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1343

13 months agolib/posix-futex: Clear thread's objects upon thread exit
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.

Clear thread's objects upon thread exit.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
Reviewed-by: Florin Postolache <florin.postolache.of@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1358

13 months agolib/ukvmem/arch: Do not print error message if demand paging disabled
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.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1334

13 months agolib/posix-poll: Fix missing epoll file locking
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.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1338

13 months agolib/posix-time: Support CLOCK_REALTIME_COARSE
Andrei Tatar [Mon, 4 Mar 2024 18:35:28 +0000 (19:35 +0100)]
lib/posix-time: Support CLOCK_REALTIME_COARSE

This change adds support for CLOCK_REALTIME_COARSE as an alias to
CLOCK_REALTIME.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1355

13 months agodrivers/ukbus/platform: Make UKBUS_PLATFORM_FDT conditional to parent
Michalis Pappas [Sun, 24 Dec 2023 10:05:46 +0000 (11:05 +0100)]
drivers/ukbus/platform: Make UKBUS_PLATFORM_FDT conditional to parent

Make UKBUS_PLATFORM_FDT conditional to UKBUS_PLATFORM to prevent that
option from being available if its parent is not selected.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1353

13 months agolib/posix-unixsocket: Fix NULL deref crash
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

13 months agoarch/arm64: Update asm constraints in mte_insert_random_tag()
Michalis Pappas [Sat, 16 Mar 2024 13:10:44 +0000 (14:10 +0100)]
arch/arm64: Update asm constraints in mte_insert_random_tag()

Update constraints of inline asm in mte_insert_random tag()
to prevent GCC from using the same register for input and
output.

Update all MTE inline asm to use positional parameters.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1361

13 months agodoc: Update kraft link in README.md
PorridgeSwim [Wed, 13 Mar 2024 18:20:06 +0000 (11:20 -0700)]
doc: Update kraft link in README.md

Update the kraft url under the Getting Start section

Signed-off-by: PorridgeSwim <yz3883@columbia.edu>
Approved-by: Alexander Jung <alex@unikraft.io>
Reviewed-by: Alexander Jung <alex@unikraft.io>
GitHub-Closes: #1359

13 months agodrivers/virtio/net: Ensure half-page alignment for netbuf
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

13 months agolib/nolibc: Provide fd functions without vfscore
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

13 months agolib/posix-socket: Add LIBPOSIX_FDIO config dependency
Michalis Pappas [Sat, 13 Jan 2024 14:29:19 +0000 (15:29 +0100)]
lib/posix-socket: Add LIBPOSIX_FDIO config dependency

Select LIBPOSIX_FDIO to resolve dependency of socket_driver.h

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1354

13 months agoscripts/checkpatch: Do not warn about symbolic permissions
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

13 months agolib/nolibc: Include htonl and ntohl functions
Marco Schlumpp [Thu, 22 Feb 2024 08:35:31 +0000 (09:35 +0100)]
lib/nolibc: Include htonl and ntohl functions

The sources files were already there and the corresponding headers declares
these two functions.

Signed-off-by: Marco Schlumpp <marco@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: #1332

13 months agolib/vfscore: Ensure we return symlink target on `namei_resolve`
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.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1320

13 months agocheckpatch: Disable C99_COMMENT_TOLERANCE
Michalis Pappas [Tue, 27 Feb 2024 05:38:12 +0000 (06:38 +0100)]
checkpatch: Disable C99_COMMENT_TOLERANCE

Add a directive to disable C99_COMMENT_TOLARANCE to retain the current
coding style that only allows block comments.

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

13 months agocheckpatch: Use block comments for SPDX identifiers in C files
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

14 months agoplat/xen/arm64: Update the interface of uk_intctlr_plat_probe()
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.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
GitHub-Closes: #1330

14 months agodrivers/ukintctlr/gic: Update the interface of uk_intctlr_plat_probe()
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.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
GitHub-Closes: #1330

14 months agolib/ukintctlr: Update the interface of uk_intctlr_plat_probe()
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.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
GitHub-Closes: #1330

14 months agolib/posix-time: Alias CLOCK_MONOTONIC_RAW to CLOCK_MONOTONIC
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

14 months agoplat/kvm/x86: Fix {XSAVE,AVX,FSGSBASE} checking/enabling behavior
Sergiu Moga [Tue, 13 Feb 2024 17:40:25 +0000 (19:40 +0200)]
plat/kvm/x86: Fix {XSAVE,AVX,FSGSBASE} checking/enabling behavior

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

14 months agolib/posix-sysinfo: Use a more Linux compatible release string
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

14 months agoRelease: v0.16.2 Telesto RELEASE-0.16.2
Alexander Jung [Wed, 14 Feb 2024 22:07:57 +0000 (23:07 +0100)]
Release: v0.16.2 Telesto

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Signed-off-by: Alexander Jung <alex@unikraft.io>
Signed-off-by: Simon Kuenzer <simon@unikraft.io>
14 months agolib/devfs: Remove stub for unmounting
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.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1282

14 months agolib/vfscore: Make automatic unmounting of filesystems independent
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.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1282

14 months agolib/vfscore: Add `ifinitrd0`, `ifnoinitrd0` to `ukopts` (fstab)
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.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1282

14 months agolib/vfscore: Introduce `ramfs` mount option for `extract`
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.

Checkpatch-Ignore: AVOID_EXTERNS
Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1282

14 months agolib/vfscore: Add missing dependency to `lib/ukatomic`
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.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1282

14 months agolib/ukargparse: Introduce `uk_strnkeycmp()`
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.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1282

14 months agolib/ukargparse: Introduce `uk_nextarg()`, `uk_nextarg_r()`
Simon Kuenzer [Fri, 19 Jan 2024 20:33:31 +0000 (21:33 +0100)]
lib/ukargparse: Introduce `uk_nextarg()`, `uk_nextarg_r()`

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.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1282

14 months agolib/ukvmem: Add informative message on stack guard page is hit
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

14 months agolib/ukvmem: Promote unhandled page fault message level
Sergiu Moga [Tue, 16 Jan 2024 19:09:35 +0000 (21:09 +0200)]
lib/ukvmem: Promote unhandled page fault message level

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

15 months ago.github/workflows: Disable 'merge' global flag
Cezar Craciunoiu [Thu, 8 Feb 2024 16:32:54 +0000 (18:32 +0200)]
.github/workflows: Disable 'merge' global flag

After this was enabled, a merge faile to execute. Disable this back
until further notice.

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1318

15 months agolib/posix-fdtab: Fix minor docstring issues
Andrei Tatar [Wed, 7 Feb 2024 10:42:52 +0000 (11:42 +0100)]
lib/posix-fdtab: Fix minor docstring issues

This change improves the docstrings in posix-fdtab, fixing minor
inconsistencies and clarifying the behavior of certain functions.

This change contains *no changes* outside of comments.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Razvan Deaconecu <razvand@unikraft.io>
GitHub-Closes: #1312

15 months ago.github/workflows: Set committer email and name globally
Cezar Craciunoiu [Wed, 7 Feb 2024 14:09:05 +0000 (16:09 +0200)]
.github/workflows: Set committer email and name globally

Because the rebase somehow, sometimes, failed, we set this now globally
in actions to ensure that there is no other missing place.

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Reviewed-by: Alexander Jung <alex@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1313

15 months agolib/posix-sysinfo: Fix sethostname off-by-1 error
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

15 months agolib/nolibc: Add get/sethostname to unistd.h
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

15 months agolib/posix-process: Add option to context switch away from clone caller
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

15 months agolib/nolibc: Solve warning of Musl imported `strstr`
Sergiu Moga [Wed, 7 Feb 2024 09:57:19 +0000 (11:57 +0200)]
lib/nolibc: Solve warning of Musl imported `strstr`

The Musl imported `strstr` had a warning about comparison
between variables of different signedness. Fix it.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
GitHub-Closes: #1311

15 months ago.github/workflows: Enable -Werror on integration builds
Michalis Pappas [Wed, 24 Jan 2024 11:00:12 +0000 (12:00 +0100)]
.github/workflows: Enable -Werror on integration builds

Add CONFIG_OPTIMIZE_WARNISERROR to the `self-test` and
`helloworld` jobs to catch warnings introduced in PRs.

Exclude the `libc` job to avoid CI errors caused by
warnings in the codebase of libmusl.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1292

15 months agoplat/xen: Remove duplicate PAGE definitions
Michalis Pappas [Sat, 3 Feb 2024 03:16:34 +0000 (04:16 +0100)]
plat/xen: Remove duplicate PAGE definitions

Remove duplicate PAGE definitions to prevent compiler warnings.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1306

15 months agolib/ukfile: pollq: Remove uk_pollq_reregister
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

15 months agolib/posix-poll: Fix EPOLL_CTL_MOD missing events
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

15 months agolib/nolibc: Expose FD_SETSIZE as Kconfig option
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

15 months agolib/nolibc: Import `strstr` from `musl`
Sergiu Moga [Thu, 11 Jan 2024 18:04:27 +0000 (20:04 +0200)]
lib/nolibc: Import `strstr` from `musl`

Import from musl the basic implementation of the widely available
string searching method `strstr`.

Additionally, do some linting/checkpatch fixes to align with our coding
style guidelines.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Florin Postolache <florin.postolache.of@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1261

15 months agoplat/kvm/x86: Remove unused variable from lxboot_entry()
Michalis Pappas [Sat, 3 Feb 2024 02:31:00 +0000 (03:31 +0100)]
plat/kvm/x86: Remove unused variable from lxboot_entry()

Remove unused variable from lxboot_entry() to prevent compiler
warnings.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
GitHub-Closes: #1305

15 months agolib/ukvmem: Use correct argument type in format string
Michalis Pappas [Thu, 1 Feb 2024 05:15:41 +0000 (06:15 +0100)]
lib/ukvmem: Use correct argument type in format string

Use the `%lx` type in format string for ctx->esr. Fixes
a GCC warning.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Sergiu Moga <sergiu@unikraft.io>
GitHub-Closes: #1300

15 months agolib/ukboot: Ensure the auxiliary stack is backed by physical memory
Michalis Pappas [Mon, 29 Jan 2024 08:49:04 +0000 (09:49 +0100)]
lib/ukboot: Ensure the auxiliary stack is backed by physical memory

Call madvise() after allocating the auxiliary stack of the init
thread so that it is backed by physical memory.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1291

15 months agolib/posix-fdtab: Add comments for posix-fdtab
Delia Pavel [Sun, 7 Jan 2024 20:23:29 +0000 (22:23 +0200)]
lib/posix-fdtab: Add comments for posix-fdtab

Signed-off-by: Delia-Maria Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
GitHub-Closes: #1241

15 months agoAdd README for posix-pipe library
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

15 months agolib/posix-poll: Fix poll() ignoring fd 0
Andrei Tatar [Wed, 10 Jan 2024 12:52:25 +0000 (13:52 +0100)]
lib/posix-poll: Fix poll() ignoring fd 0

This change fixes a bug where poll() would ignore fd 0 as if it were a
negative fd, which are explicitly allowed as NOP entries.

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: #1255

15 months agolib/posix-fdio: ENOTTY for unsupported tty ioctls
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

15 months agolib/vfscore: Prevent superfluous slashes in working directory
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

15 months agolib/posix-time: Add support for CLOCK_BOOTTIME
Andrei Tatar [Thu, 1 Feb 2024 15:31:07 +0000 (16:31 +0100)]
lib/posix-time: Add support for CLOCK_BOOTTIME

This change adds rudimentary support for CLOCK_BOOTTIME, implemented as
a synonym for CLOCK_MONOTONIC.

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: #1304

15 months agolib/ukfile: Split poll chain initializers from values
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

15 months agolib/ukfile: Split file state initializer from value
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

15 months agolib/ukfile: Split pollqueue initializer from value
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

15 months ago{include,lib/*}: Split refcount initializers from values
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

15 months agolib/posix-poll: Fix select on files w/o epoll support
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.

Checkpatch-Ignore: SPACING
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1258

15 months agolib/posix-poll: Fix poll on files w/o epoll support
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.

Checkpatch-Ignore: ENOSYS
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1258

15 months agolib/posix-poll: Fix vfscore files w/o epoll support
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.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1258

15 months agolib/posix-poll: Fix epoll crash on NULL event arg
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

15 months agolib/posix-mmap: Round-up madvise length to page size
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.

[1] https://man7.org/linux/man-pages/man2/madvise.2.html

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Reviewed-by: Florin Postolache <florin.postolache.of@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1273

15 months ago.github/workflows: Append AVOID_BUG to GOVERN_IGNORES
Michalis Pappas [Fri, 2 Feb 2024 04:57:48 +0000 (05:57 +0100)]
.github/workflows: Append AVOID_BUG to GOVERN_IGNORES

Get in sync with .checkpatch.conf

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1289

15 months agocheckpatch: Enable strict checks
Michalis Pappas [Fri, 26 Jan 2024 09:41:26 +0000 (10:41 +0100)]
checkpatch: Enable strict checks

Add `--strict` to checkpatch options to enable additional checks.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1289

15 months agocheckpatch: Retain 80 chars limit
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.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1289