]> xenbits.xensource.com Git - unikraft/unikraft.git/log
unikraft/unikraft.git
23 months agolib/vfscore: Initialize lists for stdio_vnode init-stdio-list 889/head
Razvan Deaconescu [Fri, 12 May 2023 22:28:57 +0000 (01:28 +0300)]
lib/vfscore: Initialize lists for stdio_vnode

The VFS `struct vnode` structure has two `uk_list_head` members:
`v_link` and `v_names`. These need to be initialized by a dedicated
macro / function, such as `UK_LIST_HEAD_INIT`.

The `stdio_vnode` variable (of type `struct vnode`) is not initializing
these members (they are filled with zeros). This will cause crashes when
using them.

This commit fixes that by properly initializing the `v_link` and
`v_names` members of the `stdio_vnode` variable.

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
23 months agolib/nolibc: Add -ffreestanding flag
Razvan Deaconescu [Fri, 3 Feb 2023 11:41:38 +0000 (13:41 +0200)]
lib/nolibc: Add -ffreestanding flag

GCC optimizes the use of `memcmp()` if the `-ffreestanding` flag is
missing. In the current configuration, the flag is missing for GCC <= 9.
The resulting optimization causes in an infinite loop for `lib/nolibc`.

This commit fixes the issue by adding the `-ffreestanding` flag for
`lib/nolibc`, irrespective of the GCC version.

GitHub-Fixes: #728

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #740

23 months agolib/posix-process: Fix debug printing of TIDs
Florin Postolache [Thu, 11 May 2023 19:48:53 +0000 (22:48 +0300)]
lib/posix-process: Fix debug printing of TIDs

This commit makes so that the correct info will be printed when the current
thread gets killed. Before, instead of the actual TID, the empty TID from
the iterator would be printed.

Signed-off-by: Florin Postolache <florin.postolache.of@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Andra Paraschiv <andra@unikraft.org>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #885

23 months agolib/posix-process: Reserve PID/TID 0 for kernel
Florin Postolache [Thu, 11 May 2023 10:07:48 +0000 (13:07 +0300)]
lib/posix-process: Reserve PID/TID 0 for kernel

This commit marks the TID/PID as unavailable to mimic the behaviour of
other kernels. This change also make pthread_rwlocks from glibc work in
binary compatibility mode.

Signed-off-by: Florin Postolache <florin.postolache.of@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Andra Paraschiv <andra@unikraft.org>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #885

23 months agolib/posix-process: Correct MAX_PID config option
Florin Postolache [Thu, 11 May 2023 09:44:58 +0000 (12:44 +0300)]
lib/posix-process: Correct MAX_PID config option

This commit changes the tid_map size to reflect the kernel
reservation of the 0 TID/PID value. Before, the first thread
would set the 0 position in all used structures. Now, because
it will be already set, we need to make room for another.

Signed-off-by: Florin Postolache <florin.postolache.of@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Andra Paraschiv <andra@unikraft.org>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #885

23 months agolib/vfscore: Fix file path resolution for 9pfs setup
Andra Paraschiv [Wed, 10 May 2023 10:40:27 +0000 (13:40 +0300)]
lib/vfscore: Fix file path resolution for 9pfs setup

The path resolution doesn't correctly work for a set of file cases
(e.g. symlinks to binaries or shared libraries).

One setup example is using 9pfs and the entire root local filesystem,
while running the "ls" binary and loading the shared libraries:

unikraft/support/scripts/qemu-guest -k build/app-elfloader_qemu-x86_64
-e / -a "/bin/ls /"

A "/" character is omitted from the last part of the path e.g. "/binls"
instead of "/bin/ls". Update the logic to include the missing character.

Signed-off-by: Andra Paraschiv <andra@unikraft.org>
Reviewed-by: Florin Postolache <florin.postolache.of@gmail.com>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #883

23 months agolib/vfscore: `fs0` as default device name for 9PFS
Simon Kuenzer [Fri, 5 May 2023 13:44:28 +0000 (15:44 +0200)]
lib/vfscore: `fs0` as default device name for 9PFS

This commit changes the default device/tag name for an automatically
mounted 9pfs root volume from `rootfs` to `fs0`. This is done for
convenience because `fs0` is the tag name that the `qemu-guest` support
script uses to name the first 9pfs share.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #875

23 months agobuild: Disable compiler control flow protection
Andrei Tatar [Mon, 8 May 2023 09:02:45 +0000 (11:02 +0200)]
build: Disable compiler control flow protection

Compiler flag -fcf-protection sets control-flow integrity measures
that improve security, and sometimes defaults to enabled on distro
compilers. Some aspects of this feature are implemented in the compiler
header <cet.h> for e.g., stack unwinders. If this header is missing some
programs fail to compile.
Since we don't (yet) support pulling compiler headers into unikraft
build, this change disables cf-protection globally.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #881

23 months agoplat/kvm/x86: Fix register names for clang
Stefan Jumarea [Sun, 7 May 2023 10:53:19 +0000 (13:53 +0300)]
plat/kvm/x86: Fix register names for clang

`clang` does not understand the `rflags` register name, so the build
will fail. On the other hand, `gcc` does not understand `flags`, so the
register naming needs to be placed inside `#ifdef` guards.

Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #877

23 months agoplat/*, lib/ukalloc: Use PAGE_ALIGN_UP(), PAGE_ALIGN_DOWN()
Hugo Lefeuvre [Sun, 16 Apr 2023 13:08:17 +0000 (15:08 +0200)]
plat/*, lib/ukalloc: Use PAGE_ALIGN_UP(), PAGE_ALIGN_DOWN()

We have PAGE_ALIGN_DOWN, PAGE_ALIGN_UP, and PAGE_ALIGN macros, but don't
use them consistently. At places we still have code that does custom
ALIGN_DOWN, ALIGN_UP, and masks. Use appropriate macros everywhere.

This patch was generated by the following Coccinelle rule:

    @@
    expression E;
    @@

    - ALIGN_DOWN(E, __PAGE_SIZE)
    + PAGE_ALIGN_DOWN(E)

    @@
    expression E;
    type T;
    @@

    - ALIGN_DOWN(E, (T) __PAGE_SIZE)
    + PAGE_ALIGN_DOWN(E)

    @@
    expression E;
    @@

    - ALIGN_UP(E, __PAGE_SIZE)
    + PAGE_ALIGN_UP(E)

    @@
    expression E;
    type T;
    @@

    - ALIGN_UP(E, (T) __PAGE_SIZE)
    + PAGE_ALIGN_UP(E)

    @@
    expression E;
    @@

    - (E + PAGE_SIZE - 1) & PAGE_MASK
    + PAGE_ALIGN(E)

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Reviewed-by: Dragos Petre <dragos.petre27@gmailcom>
Reviewed-by: Alexandru Calciu <alxcalciu@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #842

23 months agolib/{nolibc,isrlib}: Modify pointer comparison
Maria Sfiraiala [Mon, 8 May 2023 07:49:43 +0000 (10:49 +0300)]
lib/{nolibc,isrlib}: Modify pointer comparison

This commit typecasts `src` and `dst` strings from `memmove()` to ensure
that their values are treated as pointers.

It also modifies the function implementation to handle overlapping.

Co-authored-by: Soumya Ranjan <ranjan42069@gmail.com>
Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Signed-off-by: Soumya Ranjan <ranjan42069@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #880

23 months agobuild: Do not use segment annotations on linuxu
Marco Schlumpp [Wed, 12 Apr 2023 09:09:26 +0000 (11:09 +0200)]
build: Do not use segment annotations on linuxu

For the linuxu platform we rely on the default linker script and only
add some additional sections on top of that one. That also means that
there aren't any segments defined. This makes the segment specification
opt-in instead of assuming the segments are always defined.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Checkpatch-Ignore: SPACING
Checkpatch-Ignore: COMPLEX_MACRO
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #833

23 months agolib/ukdebug: Mark tracepoint sections as unallocated notes
Marco Schlumpp [Wed, 12 Apr 2023 09:06:17 +0000 (11:06 +0200)]
lib/ukdebug: Mark tracepoint sections as unallocated notes

At runtime we don't care about the content of them, and we only need
them on host side to decode the trace buffer.
This also prevents the linker from adding a segment for these sections.
Because the resulting segment sometimes only contained these two
sections, the final `strip` step would end up with an empty segment.
And in the case of the linuxu platform the resulting image was not
working anymore.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #833

23 months agoplat/linuxu: Avoid re-initialization of the `heap` and `initrd`
Diego Alejandro Parra Guzman [Wed, 10 May 2023 11:12:39 +0000 (14:12 +0300)]
plat/linuxu: Avoid re-initialization of the `heap` and `initrd`

Keep a locally declared static variable `init` to cache the
current amount of memory region descriptors. This way, whenever
`ukplat_memregion_count` is called, `__linuxu_plat_heap_init` and
`__linuxu_plat_initrd_init` do not have to be executed more than
once.

Co-authored-by: Sergiu Moga <sergiu.moga@protonmail.com>
Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Signed-off-by: Diego Alejandro Parra Guzman <diego-alejandro.parra-guzman@tttech.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #878

23 months agoplat/linuxu: Add check for memory region index out of range
Diego Alejandro Parra Guzman [Wed, 10 May 2023 11:12:01 +0000 (14:12 +0300)]
plat/linuxu: Add check for memory region index out of range

Ensure that we do not try to fetch a memory region descriptor by an
index that is larger than our current memory region descriptor count.

Furthermore, this guarantees that `ukplat_memregion_count` is always
called before `ukplat_memregion_get` is executed fully. This way we
will always have the memory region descriptors as well as their count
set up and available before we try to fetch one.

Co-authored-by: Sergiu Moga <sergiu.moga@protonmail.com>
Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Signed-off-by: Diego Alejandro Parra Guzman <diego-alejandro.parra-guzman@tttech.com>
GitHub-Fixes: #766
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #878

23 months agosupport/scripts: Add additional recognised Git trailers to checkpatch
Alexander Jung [Mon, 8 May 2023 07:43:37 +0000 (07:43 +0000)]
support/scripts: Add additional recognised Git trailers to checkpatch

This commit introduces 3 additional Git trailers to be recognised by the
checkpatch program:

 - GitHub-Fixes   - Used to reference and address an open issue, often
                    a specific bug or problem. GitHub will automatically
                    close the issue once the commit with this Git
                    trailer is merged.
 - GitHub-Closes  - Used to reference an open issue or PR, which is not
                    specific to a particular bug.  For example, it can
                    be used to supercede another PR.  GitHub will
                    automatically close the referenced issue or PR once
                    a commit with this Git trailer is merged.
 - Co-authored-by - Similar to providing additional Signed-off-by's,
                    this trailer is recognised by GitHub and helps
                    attribute authorship, making the user's profile
                    more visible.
 - Approved-by    - Signifies the authoritive representative (usually a
                    project maintainer) who approved the commit.

Additional adjustments to the checkpatch script are made in order to
recognise non-standard Git trailer values (those from GitHub).

Signed-off-by: Alexander Jung <alex@unikraft.io>
Reviewed-by: Gabi Mocanu <gabi.mocanu98@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Gabi Mocanu <gabi.mocanu98@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #879

23 months agodoc: Add Codacy code quality status badge to README.md
Aryan Verma [Thu, 16 Feb 2023 09:49:32 +0000 (15:19 +0530)]
doc: Add Codacy code quality status badge to README.md

GitHub-Fixes: #650
Signed-off-by: Aryan Verma <aryanvarma7272@gmail.com>
Co-authored-by: Alexander Jung <alex@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #764

23 months agolib/uklibparam: Fixes for review PR #867
Simon Kuenzer [Mon, 8 May 2023 14:38:14 +0000 (16:38 +0200)]
lib/uklibparam: Fixes for review PR #867

Commits
 - 7741af97 "`UK_LIBPARAM_PARAM_ALIAS()`,`UK_LIBPARAM_PARAM_ARR_ALIAS()`"
 - 1cc3a2f6 "Rewrite of parser"
 - 243f0c45 "Declare __LIBNAME__, __BASENAME__ and __VARIANT__ for .lds.S"
 - 910b9bef "Add linker scripts to link dependencies"
should have been included with PR #867 but got merged by mistake with
PR #868 due to a dependency.

This commit addresses the comments provided with the review for PR #867.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #882

23 months agoplat/xen: Fix unchecked uk_palloc() value in x86/mm.c
Hugo Lefeuvre [Sun, 16 Apr 2023 09:57:44 +0000 (11:57 +0200)]
plat/xen: Fix unchecked uk_palloc() value in x86/mm.c

The return value of uk_palloc is not checked in _arch_init_p2m.

Allocation failure at that point should never happen, but it's not a
reason not to check.

At this stage, in the event of a failure, we should probably abort the
boot altogether.

This bug was detected using the following Coccinelle spatch:

    @call@
    expression ptr;
    position p;
    @@

    ptr@p = uk_palloc(...);

    @ok@
    expression ptr;
    position call.p;
    @@

    ptr@p = uk_palloc(...);
    ... when != ptr
    (
     (ptr == NULL || ...)
    |
     (ptr != NULL || ...)
    )

    @depends on !ok@
    expression ptr;
    position call.p;
    @@

    ptr@p = uk_palloc(...);
    + if (ptr == NULL) return;

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #839

23 months agolib/vfscore: Handle `FIONBIO` command in `pipe_ioctl()`
Eduard Vintilă [Mon, 1 May 2023 16:13:55 +0000 (19:13 +0300)]
lib/vfscore: Handle `FIONBIO` command in `pipe_ioctl()`

The current `ioctl` implementation for pipes does not handle
the `FIONBIO` command, which leads to a negative error value being
returned. This commit introduces a simple case which sets the FNONBLOCK
flag when such a command is passed.

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Tu Dinh Ngoc <dinhngoc.tu@irit.fr>
Reviewed-by: Eduard-Florin Mihailescu <mihailescu.eduard@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #874

23 months agoplat/common: Add firecracker shutdown signal
Andrei Tudor TOPALĂ (101668) [Thu, 14 Apr 2022 21:36:51 +0000 (00:36 +0300)]
plat/common: Add firecracker shutdown signal

Firecracker emulates a PS/2 controller and detects attempted writes to
the CPU reset line.

Co-authored-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoplat/kvm: Include target hypervisor in image name
Marco Schlumpp [Mon, 17 Apr 2023 09:19:33 +0000 (11:19 +0200)]
plat/kvm: Include target hypervisor in image name

This makes it more clear on what hypervisor the image works on.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoplat/kvm/x86: Use position independent code for lxboot
Marco Schlumpp [Tue, 11 Apr 2023 15:58:08 +0000 (17:58 +0200)]
plat/kvm/x86: Use position independent code for lxboot

This should make it easier in the future to extend the entry point to
support proper boot loaders such as the one in QEMU.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoplat/kvm/x86: Workaround re-mapping low-mem areas
Marco Schlumpp [Thu, 9 Feb 2023 13:47:36 +0000 (14:47 +0100)]
plat/kvm/x86: Workaround re-mapping low-mem areas

The paging code currently does not unmap the memory area before the
kernel image, but then tries to re-map any region in that area.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoplat/kvm/x86: Add an entry point for the firecracker hypervisor
Marco Schlumpp [Thu, 9 Feb 2023 13:43:51 +0000 (14:43 +0100)]
plat/kvm/x86: Add an entry point for the firecracker hypervisor

This is currently not conforming to the actual Linux boot protocol and
only suitable for firecracker. The kernel image would have to include a
proper Linux boot protocol header to allow loading with proper
bootloaders such as the one in QEMU.

Co-authored-by: Marc Rittinghaus <marc@unikraft.io>
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoplat/kvm/x86: Add structures/definitions for the linux boot protocol
Marco Schlumpp [Thu, 9 Feb 2023 13:41:00 +0000 (14:41 +0100)]
plat/kvm/x86: Add structures/definitions for the linux boot protocol

This defines the necessary structures to parse the information passed by
a linux boot protocol compatible bootloader.

Co-authored-by: Marc Rittinghaus <marc@unikraft.io>
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoplat/kvm: Add hypervisor/boot protocol configuration
Marco Schlumpp [Thu, 9 Feb 2023 13:38:27 +0000 (14:38 +0100)]
plat/kvm: Add hypervisor/boot protocol configuration

This allows the configuration of a target hypervisor. Depending on the
hypervisor a suitable boot protocol is selected.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoplat/common: Extract non-multiboot specific memory region helpers
Marco Schlumpp [Mon, 13 Feb 2023 15:58:19 +0000 (16:58 +0100)]
plat/common: Extract non-multiboot specific memory region helpers

The multiboot entry point had a few internal functions that are also
useful for other entry points.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoinclude/uk: Simplify RANGE_OVERLAP macro
Marco Schlumpp [Tue, 25 Apr 2023 08:05:41 +0000 (10:05 +0200)]
include/uk: Simplify RANGE_OVERLAP macro

We can simplify the check by observing that there are only two
conditions necessary to check whether a range does *not* overlap:
 - the end of range 0 is before the start of range 1
   [--0--) [--1--)
 - OR the start of range 0 is after the end of range 1
   [--1--) [--0--)
Inverting this gives us a simple condition for checking whether ranges
*do* overlap.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoplat/*: Introduce cmdline length to bootinfo
Marco Schlumpp [Thu, 9 Feb 2023 13:34:39 +0000 (14:34 +0100)]
plat/*: Introduce cmdline length to bootinfo

Some boot protocols already have the length information and the internal
command line handling works with non-null terminated strings anyway.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoplat/kvm/x86: Don't create fine-grained mapping for low memory
Marco Schlumpp [Thu, 9 Feb 2023 12:09:03 +0000 (13:09 +0100)]
plat/kvm/x86: Don't create fine-grained mapping for low memory

Mapping all memory makes the page table more independent of the actual
boot protocol. Firecracker currently puts the protocol information at a
very low address (0x7000).

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #760

23 months agoplat/kvm: Remove intermediate relocatable object step
Marco Schlumpp [Fri, 24 Feb 2023 16:18:55 +0000 (17:18 +0100)]
plat/kvm: Remove intermediate relocatable object step

This object was previously used to hide all symbols except the entry
point. But this step was removed making the relocatable object creation
unnecessary.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #789

23 months agoplat/drivers/ofw: Fix search in `fdt_node_offset_by_compatible_list`
Eduard Vintilă [Thu, 16 Mar 2023 12:13:06 +0000 (14:13 +0200)]
plat/drivers/ofw: Fix search in `fdt_node_offset_by_compatible_list`

The current implementation returns as soon as a node that matches a
compatible string is found. However, we should iterate through all of
the compatible list to make sure that we return the node with the least
offset value such that future searches will not skip any matching nodes.

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #805

23 months agoplat/drivers/ofw: Fix incorrect offset in `fdt_translate_one`
Eduard Vintilă [Thu, 16 Mar 2023 12:10:46 +0000 (14:10 +0200)]
plat/drivers/ofw: Fix incorrect offset in `fdt_translate_one`

When a node is missing the "ranges" property, offset should be set to 0.
The current implementation sets offset to the address to be translated,
which ignores the fact that `fdt_default_translate`  is later called.
The latter function adds the offset to the same address,
resulting in doubling the effective address, when in fact a 1-to-1
mapping is necessary.

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #805

23 months agolib/nolibc: Remove warnings of timespec
Takeru Wada [Mon, 13 Mar 2023 14:37:51 +0000 (14:37 +0000)]
lib/nolibc: Remove warnings of timespec

This commit fixes the definition of pointer arguments in GCC >= 11.

Signed-off-by: Takeru Wada <takew@asg.cs.tuat.ac.jp>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #800

23 months agolib/ukboot: Print environment variables before entering main
Simon Kuenzer [Thu, 16 Mar 2023 16:31:42 +0000 (17:31 +0100)]
lib/ukboot: Print environment variables before entering main

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

23 months agolib/posix-environ: Symbol aliases for `environ`
Simon Kuenzer [Tue, 14 Mar 2023 14:18:12 +0000 (15:18 +0100)]
lib/posix-environ: Symbol aliases for `environ`

In order to comply with common libc behavior, we provide the following
symbol aliases for environ`: `_environ`, `__environ`, `___environ`.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

23 months agolib/posix-environ: Variables from kernel command line
Simon Kuenzer [Fri, 24 Feb 2023 00:45:52 +0000 (01:45 +0100)]
lib/posix-environ: Variables from kernel command line

Introduces the ability to populate additional environment variables via the
kernel command line.

Checkpatch-Ignore: SPACING
Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

23 months agolib/posix-environ: Compiled-in environment variables
Simon Kuenzer [Tue, 14 Feb 2023 23:32:29 +0000 (00:32 +0100)]
lib/posix-environ: Compiled-in environment variables

We introduce the ability to compile-in up to 16 environment variables.
The values can be set via `menuconfig`. The initial `environ` array is
automatically sized to match the number of compiled-in values.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

23 months agolib/posix-environ: Register and make it compile
Simon Kuenzer [Thu, 9 Feb 2023 20:54:40 +0000 (21:54 +0100)]
lib/posix-environ: Register and make it compile

This commit integrates and enables compiling of the imported environment
helper functions (see previous commit).

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

23 months agolib/posix-environ: Import from musl 1.2.3
Simon Kuenzer [Wed, 8 Feb 2023 16:01:41 +0000 (17:01 +0100)]
lib/posix-environ: Import from musl 1.2.3

This commit imports needed code from musl 1.2.3. This concentrates mostly
on the following helper functions for environment variables:
 - `clearenv()`
 - `getenv()`
 - `putenv()`
 - `setenv()`
 - `unsetenv()`

Checkpatch-Ignore: FUNCTION_WITHOUT_ARGS
Checkpatch-Ignore: LINE_SPACING
Checkpatch-Ignore: SPACING
Checkpatch-Ignore: TRAILING_STATEMENTS
Checkpatch-Ignore: SIZEOF_PARENTHESIS
Checkpatch-Ignore: TYPO_SPELLING
Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

23 months agolib/uklibparam: `UK_LIBPARAM_PARAM_ALIAS()`,`UK_LIBPARAM_PARAM_ARR_ALIAS()`
Simon Kuenzer [Fri, 24 Feb 2023 00:42:55 +0000 (01:42 +0100)]
lib/uklibparam: `UK_LIBPARAM_PARAM_ALIAS()`,`UK_LIBPARAM_PARAM_ARR_ALIAS()`

This commit provides `UK_LIBPARAM_PARAM_ALIAS()` and
`UK_LIBPARAM_PARAM_ARR_ALIAS()` which are variants of `UK_LIBPARAM_PARAM()`
and `UK_LIBPARAM_PARAM_ARR()`. These registration macros allow to set a
custom parameter name instead of deriving it from the variable name.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

23 months agolib/uklibparam: Rewrite of parser
Simon Kuenzer [Thu, 23 Feb 2023 23:42:29 +0000 (00:42 +0100)]
lib/uklibparam: Rewrite of parser

This commit introduces a rewrite of `lib/uklibparam`. The rewrite ensures
that it is errno-free, malloc-free, and TLS-free. This makes it ideal for
processing library parameters early during boot. It includes an own and
modified version of `strtoull` function that is used for parsing integer
values from the command line.
Additionally, the parser can handle arrays more intuitively (and for any
data type of the elements) while fully utilizing pre-processed argument
vectors. It relies on the fact that whitespacing and quoting is already
handled (e.g., by `lib/ukargparse`). There are new types that are more
inline with the ones defined by ukstore.

This rewrite introduces the ability to provide a parameter description
with updated parameter registration macros:
  UK_LIBPARAM_PARAM(variable, type, description)
  UK_LIBPARAM_PARAM_ARR(variable, type, count, description)
The description is printed on the help output.

The previous interfaces are kept for backwards compatibility. However,
it is planned to remove them as soon as the code base is completely
adopted.

Checkpatch-Ignore: SPACING
Checkpatch-Ignore: OPEN_BRACE
Checkpatch-Ignore: MACRO_WITH_FLOW_CONTROL
Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

23 months agobuild: Declare __LIBNAME__, __BASENAME__ and __VARIANT__ for .lds.S
Simon Kuenzer [Thu, 23 Feb 2023 21:21:04 +0000 (22:21 +0100)]
build: Declare __LIBNAME__, __BASENAME__ and __VARIANT__ for .lds.S

.lds.S files are linker script files that use the C preprocessor in order
to generate the final .lds file. This commit provides Unikraft's common
declarations of `__LIBNAME__`, `__BASENAME__`, `__VARIANT__` to this
pre-processing step so that they can be used for generating linker scripts.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

23 months agoplat/*: Add linker scripts to link dependencies
Simon Kuenzer [Thu, 23 Feb 2023 20:47:59 +0000 (21:47 +0100)]
plat/*: Add linker scripts to link dependencies

This commit adds needed linker scripts as dependency to the linking rule
of the final image. This dependency was mostly indirectly covered via
libraries. However, updates to platform linker scripts did not trigger
relinking the final image.
Additionally, pure API libraries (like `lib/ukfalloc`) would not even cause
building a linker script that is shipped with the library or injected with
an `EACHOLIB_SRCS` declaration. The library buildrule is generated but
because no library object is generated, the linker script was never be part
of a dependency list.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868

23 months agolib/nolibc: Add README.md
calex257 [Sat, 25 Feb 2023 15:53:56 +0000 (17:53 +0200)]
lib/nolibc: Add README.md

Add a brief description of nolibc, providing an overview
of its purpose, usage and limitations.

This commit also shows a relevant example of how to configure
an application to use Unikraft-specific assertions or the ones
implemented in nolibc.

Signed-off-by: Alexandru Calciu <alexandru.calciu@stud.acs.upb.ro>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #778

2 years agolib/vfscore: Cleanup sys_symlink
Marc Rittinghaus [Tue, 25 Apr 2023 10:24:08 +0000 (12:24 +0200)]
lib/vfscore: Cleanup sys_symlink

This commit cleans up sys_symlink() according to the current coding
conventions and uses separate jump labels for exits depending on
if the vnode lock needs to be released or not.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #866

2 years agolib/vfscore: Do not copy oldpath in symlink
Marc Rittinghaus [Tue, 25 Apr 2023 10:19:05 +0000 (12:19 +0200)]
lib/vfscore: Do not copy oldpath in symlink

With the changes to the vnode ops definitions the symlink operation
takes a constant string. We can thus just pass the input string on
without having to copy it.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #866

2 years agolib/ramfs: Switch to const strings for vnops
Marc Rittinghaus [Tue, 25 Apr 2023 10:16:06 +0000 (12:16 +0200)]
lib/ramfs: Switch to const strings for vnops

This commit changes all vnode operations to accept constant
string parameters to be inline with the changed definitions.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #866

2 years agolib/devfs: Switch to const strings for vnops
Marc Rittinghaus [Tue, 25 Apr 2023 10:14:49 +0000 (12:14 +0200)]
lib/devfs: Switch to const strings for vnops

This commit changes all vnode operations to accept constant
string parameters to be inline with the changed definitions.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #866

2 years agolib/9pfs: Switch to const strings for vnops
Marc Rittinghaus [Tue, 25 Apr 2023 10:14:11 +0000 (12:14 +0200)]
lib/9pfs: Switch to const strings for vnops

This commit changes all vnode operations to accept constant
string parameters to be inline with the changed definitions.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #866

2 years agolib/vfscore: Make vnops strings constant
Marc Rittinghaus [Tue, 25 Apr 2023 10:12:09 +0000 (12:12 +0200)]
lib/vfscore: Make vnops strings constant

The current vnode operations define strings as mutable, which
makes it more difficult to do optimizations. Since no buffer size
is supplied the strings can only be modified on a char-for-char
basis anyways, which also limits the use-cases. In addition, no
implementation of the vnode operations makes use of the
mutability of the strings.

This commit thus introduces the `const` keyword for all strings
passed to vnode operations.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #866

2 years agolib/posix-futex: Check for proper FUTEX_CLOCK_REALTIME usage
Marco Schlumpp [Mon, 17 Apr 2023 08:04:04 +0000 (10:04 +0200)]
lib/posix-futex: Check for proper FUTEX_CLOCK_REALTIME usage

The documentation specifies a list of operations which support this
flag. This adds a check that explicitly rejects all invalid combinations
and returns `ENOSYS` according to the documentation.

Checkpatch-Ignore: ENOSYS
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Adina Smeu <adina.smeu@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #758

2 years agolib/posix-futex: Ignore FUTEX_PRIVATE_FLAG
Marco Schlumpp [Mon, 17 Apr 2023 07:57:45 +0000 (09:57 +0200)]
lib/posix-futex: Ignore FUTEX_PRIVATE_FLAG

The flag can be specified for all operations and does not make a
difference in the context of a single-process scenario. Therefore, we
can ignore it.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Adina Smeu <adina.smeu@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #758

2 years agolib/posix-futex: Implement subset of FUTEX_WAIT_BITSET
Marco Schlumpp [Thu, 9 Feb 2023 15:44:35 +0000 (16:44 +0100)]
lib/posix-futex: Implement subset of FUTEX_WAIT_BITSET

Many modern applications use FUTEX_WAIT_BITSET to be able to set an
absolute timeout. To accomplish that they set all bits in the val3/mask
parameter, which makes the operation equivalent to a normal FUTEX_WAIT
(except the absolute timeout value).

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Adina Smeu <adina.smeu@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #758

2 years agolib/uksched: Expose uk_thread_block_until
Marco Schlumpp [Thu, 9 Feb 2023 14:57:30 +0000 (15:57 +0100)]
lib/uksched: Expose uk_thread_block_until

This allows external API clients to specify an absolute deadline for
waking up. This is potentially more precise because the `timeout` is
relative to whenever uk_thread_block_timeout is actually taking the
"current" time.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Adina Smeu <adina.smeu@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #758

2 years agolib/uksched: fix docs
Nour-eddine Taleb [Sat, 25 Mar 2023 19:56:47 +0000 (19:56 +0000)]
lib/uksched: fix docs

Signed-off-by: Nour-eddine Taleb <contact@noureddine.xyz>
Reviewed-by: Adina Smeu <adina.smeu@gmail.com>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #809

2 years agolib/posix-futex/test: port the test cases to the new sched apis
Nour-eddine Taleb [Thu, 23 Mar 2023 23:15:24 +0000 (23:15 +0000)]
lib/posix-futex/test: port the test cases to the new sched apis

due to the changes in scheduling apis, it was necessary to update
posix-futex tests which still relays on the old apis.

GitHub-Fixes: #630
Signed-off-by: Nour-eddine Taleb <contact@noureddine.xyz>
Reviewed-by: Adina Smeu <adina.smeu@gmail.com>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #809

2 years agoplat/kvm/x86: Stop unwinding at _libkvmplat_entry2
Marco Schlumpp [Mon, 2 Jan 2023 10:22:18 +0000 (11:22 +0100)]
plat/kvm/x86: Stop unwinding at _libkvmplat_entry2

The _libkvmplat_entry2 function is called using assembler code that
switches stacks. Therefore, a debugger can't unwind its frame. This
inserts a CFI that marks the previous instruction pointer as undefined.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #700

2 years agoplat/kvm/x86: Add unwinding information to interrupt/exception handlers
Marco Schlumpp [Mon, 2 Jan 2023 14:15:52 +0000 (15:15 +0100)]
plat/kvm/x86: Add unwinding information to interrupt/exception handlers

This allows debuggers and profilers to unwind past interrupt/exception
handlers.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #700

2 years agoplat/x86: Add unwind information to system call handler
Marco Schlumpp [Wed, 21 Dec 2022 10:01:34 +0000 (11:01 +0100)]
plat/x86: Add unwind information to system call handler

Without this information debugging tools do not know how to properly
unwind the _ukplat_syscall frame. For example, this causes them to
output garbage output for back traces.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #700

2 years agoarch/x86: Add helpers for CFI in assembler code
Marco Schlumpp [Mon, 2 Jan 2023 10:40:13 +0000 (11:40 +0100)]
arch/x86: Add helpers for CFI in assembler code

This introduces helpers for maintaining frame information when using
push and pop in assembler code.

Checkpatch-Ignore: SPACING
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #700

2 years agolib/nolibc: Define u_(long|int|short_char) for _DEFAULT_SOURCE files
Marco Schlumpp [Tue, 24 May 2022 18:17:14 +0000 (20:17 +0200)]
lib/nolibc: Define u_(long|int|short_char) for _DEFAULT_SOURCE files

These typedefs are commonly used in BSD code. Most libc libraries define
them by default or for _DEFAULT_SOURCE files. Because unikraft is
usually closer to Linux, this adopts the later approach.

Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agolib/nolibc: Implement fputs and puts functions
Marco Schlumpp [Tue, 29 Mar 2022 15:32:46 +0000 (17:32 +0200)]
lib/nolibc: Implement fputs and puts functions

These functions were still missing from nolibc.

Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agolib/nolibc: Implement syslog functions
Marco Schlumpp [Tue, 29 Mar 2022 13:25:17 +0000 (15:25 +0200)]
lib/nolibc: Implement syslog functions

These functions forward the messages to the ukdebug library.

Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agolib/nolibc: Implement strsep function
Marco Schlumpp [Tue, 29 Mar 2022 12:23:52 +0000 (14:23 +0200)]
lib/nolibc: Implement strsep function

This function is an improvement of strtok that originates from BSD.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agolib/nolibc: Implement random/srandom
Marco Schlumpp [Fri, 25 Mar 2022 16:23:57 +0000 (17:23 +0100)]
lib/nolibc: Implement random/srandom

These functions provide a PRNG and are based on the musl libc library.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agolib/nolibc: Implement exit function
Marco Schlumpp [Fri, 25 Mar 2022 15:40:15 +0000 (16:40 +0100)]
lib/nolibc: Implement exit function

The behaviour is similar to returning a value from main.

Checkpatch-Ignore: EMBEDDED_FUNCTION_NAME
Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agolib/nolibc: Export abort function
Marco Schlumpp [Fri, 25 Mar 2022 15:31:43 +0000 (16:31 +0100)]
lib/nolibc: Export abort function

This function was already declared in the public stdlib header, but the
symbol name was missing in the exportsyms.uk file.

Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agolib/nolibc: Implement isblank function
Marco Schlumpp [Fri, 25 Mar 2022 15:07:17 +0000 (16:07 +0100)]
lib/nolibc: Implement isblank function

This function determines whether the given character is a space or tab.

Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agolib/nolibc: Add atol function
Marco Schlumpp [Thu, 24 Mar 2022 16:06:03 +0000 (17:06 +0100)]
lib/nolibc: Add atol function

This function is basically atoi with a large output range.

Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agolib/nolibc: strcasecmp function
Marco Schlumpp [Thu, 24 Mar 2022 16:02:24 +0000 (17:02 +0100)]
lib/nolibc: strcasecmp function

This function compares two strings case insensitively. The
implementation was taken from the MUSL libc.

Checkpatch-Ignore: TRAILING_STATEMENTS
Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agolib/nolibc: Introduce strcat/bcopy/bzero functions
Marco Schlumpp [Tue, 22 Mar 2022 11:01:57 +0000 (12:01 +0100)]
lib/nolibc: Introduce strcat/bcopy/bzero functions

The bcopy/bzero originate from BSD, but are often provided by libc on
other systems for compatibility. The strcat function is also added for
improved compatibility.

Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #627

2 years agobuild: Implement a more robust compiler detection
Marco Schlumpp [Mon, 27 Feb 2023 14:33:10 +0000 (15:33 +0100)]
build: Implement a more robust compiler detection

Instead of checking the compiler executable name, inspect the compiler's
version output. This also works when there are symlinks involved or the
executable name has additional text such as version numbers.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #774

2 years agolib/uksglist: Add `__nonnull` to relevant `uk_sglist_*` methods
vineethkm [Sat, 25 Mar 2023 19:43:30 +0000 (01:13 +0530)]
lib/uksglist: Add `__nonnull` to relevant `uk_sglist_*` methods

GitHub-Fixes: #730
Signed-off-by: Vineeth Krishna M <vineethkm.01@gmail.com>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Alexander Jung <alex@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #813

2 years agoplat/kvm/arm: Use 48-bit virtual addressing for PARange >= 52
Eduard Vintilă [Sat, 28 Jan 2023 20:01:53 +0000 (22:01 +0200)]
plat/kvm/arm: Use 48-bit virtual addressing for PARange >= 52

Latest versions of QEMU (>= 7) might provide a 52-bit physical address
space when passing `max` as the `cpu` option. This information is found
in the `PARange` field of the `ID_AA64MMFR0_EL1` register.

When the Virtual Memory API is not enabled (i.e. the `CONFIG_PAGING`
macro is not set), the `T0SZ` field from the `TCR_EL1` register is set
up such that the VA space size matches the PA one.  However, we
currently do not provide a 5-level paging scheme at all in order to
implement 52-bit virtual addresing, so we need to enforce 48-bit VA space
for PARange >= 52.

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #729

2 years agolib/ukalloc: Remove unreachable NULL checks
Hugo Lefeuvre [Sun, 16 Apr 2023 08:53:17 +0000 (10:53 +0200)]
lib/ukalloc: Remove unreachable NULL checks

These
    if (ptr && ...)
will always turn out true due to the preceding
    if (!ptr)

This was found by Coccinelle [0].

[0] https://coccinelle.gitlabpages.inria.fr/website/rules/notnull.cocci

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Reviewed-by: Luca Seritan <luca.seritan@gmail.com>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #840

2 years agobuild: apply `LIBxxx_COMPFLAGS{,-y}` to C++ too
Tu Dinh Ngoc [Tue, 11 Apr 2023 16:03:02 +0000 (16:03 +0000)]
build: apply `LIBxxx_COMPFLAGS{,-y}` to C++ too

These flags were not being applied to C++ source files. Add them to
`buildrule_cxx`. Also reorder compiler flags to be in line with C flags.

Signed-off-by: Tu Dinh Ngoc <dinhngoc.tu@irit.fr>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #845

2 years agosupport/scripts: Change the SECINFO_EXP regex to be more permissive
Florin Postolache [Sat, 11 Mar 2023 08:14:39 +0000 (10:14 +0200)]
support/scripts: Change the SECINFO_EXP regex to be more permissive

Currently, the regex for matching the .uk_bootinfo section does
not consider the case of the section having a number bigger than
99 as a result for objdump -h. This PR changes the regex to consider that case.

Signed-off-by: Florin Postolache <florin.postolache80@gmail.com>
Reviewed-by: Dragos Petre <dragos.petre27@gmail.com>
Approved-by: Marco Schlumpp <marco@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #792

2 years agolib/posix-process: remove clone3 syscall
Ioan-Teodor Teugea [Wed, 19 Apr 2023 11:29:10 +0000 (14:29 +0300)]
lib/posix-process: remove clone3 syscall

As clone3 currently does not work, and glibc falls
back to clone if clone3 is not available (tested on 2.35),
the syscall can be removed until a working implementation is
available.

Signed-off-by: Ioan-Teodor Teugea <teodor.teugea@gmail.com>
Reviewed-by: Florin Postolache <florin.postolache.of@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #847

2 years agoarch/x86: Add compiler flags for auto host CPU
Andrei Tatar [Fri, 21 Apr 2023 14:42:48 +0000 (16:42 +0200)]
arch/x86: Add compiler flags for auto host CPU

Previously the `CONFIG_MARCH_X86_64_NATIVE` variable did not add
`-march=native` to CFLAGS, the compiler then defaulting to generic
x86_64. This implements the expected functionality.

Signed-off-by: Andrei Tatar <andrei.ttr@gmail.com>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #861

2 years agouk/arch: Make `ukarch_dec` use `ukarch_fetch_sub`
Razvan Virtan [Sat, 29 Apr 2023 19:18:32 +0000 (22:18 +0300)]
uk/arch: Make `ukarch_dec` use `ukarch_fetch_sub`

Change the `ukarch_dec` definition so that it uses `ukarch_fetch_sub`,
being consistent with the `ukarch_inc` implementation.

Signed-off-by: Razvan Virtan <virtanrazvan@gmail.com>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #864

2 years agouk/arch: Add `ukarch_fetch_sub`
Razvan Virtan [Sat, 22 Apr 2023 19:29:30 +0000 (22:29 +0300)]
uk/arch: Add `ukarch_fetch_sub`

Add wrapper for the `__atomic_fetch_sub` GNU builtin.

Signed-off-by: Razvan Virtan <razvanvirtan@gmail.com>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #864

2 years agosupport/scripts: Fix Python ascii codec can't decode byte
bokket [Wed, 8 Mar 2023 01:21:02 +0000 (09:21 +0800)]
support/scripts: Fix Python ascii codec can't decode byte

The output of objdump can't be decoded using only the ASCII
encoding on some system languages. Change it to utf-8 to be
more permissive.

Signed-off-by: bokket <3100563328@qq.com>
Signed-off-by: Florin Postolache <florin.postolache.of@gmail.com>
Reviewed-by: Alex Apostolescu <alexx.apostolescu@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #873

2 years agolib/devfs: Fix device_create() function comment
Marc Rittinghaus [Wed, 26 Apr 2023 11:09:51 +0000 (13:09 +0200)]
lib/devfs: Fix device_create() function comment

The current comment does not state the correct return values.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/devfs: Reorder includes + fix typo
Marc Rittinghaus [Thu, 20 Apr 2023 15:08:47 +0000 (17:08 +0200)]
lib/devfs: Reorder includes + fix typo

Standard headers and uk headers should not be mixed.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/devfs: Fix whitespaces in Config.uk
Marc Rittinghaus [Thu, 20 Apr 2023 15:07:26 +0000 (17:07 +0200)]
lib/devfs: Fix whitespaces in Config.uk

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/ukswrand: Adapt (u)random to new device_create
Marc Rittinghaus [Thu, 20 Apr 2023 15:06:37 +0000 (17:06 +0200)]
lib/ukswrand: Adapt (u)random to new device_create

The signature and requirements of device_create() changed.
This commit adapts the implementations of /dev/random and
/dev/urandom to use the new definition.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/devfs: Adapt null/zero to new device_create
Marc Rittinghaus [Thu, 20 Apr 2023 15:03:57 +0000 (17:03 +0200)]
lib/devfs: Adapt null/zero to new device_create

The signature and requirements of device_create() changed.
This commit adapts the implementations of /dev/null and
/dev/zero to use the new definition.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/devfs: Adapt stdout to new device_create
Marc Rittinghaus [Thu, 20 Apr 2023 15:01:52 +0000 (17:01 +0200)]
lib/devfs: Adapt stdout to new device_create

The signature and requirements of device_create() changed.
This commit adapts the implementation of /dev/stdout to use
the new definition.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/devfs: Merge device_register and create
Marc Rittinghaus [Thu, 20 Apr 2023 14:59:25 +0000 (16:59 +0200)]
lib/devfs: Merge device_register and create

This commit merges the device_register() and device_create() functions
to safe a malloc() operation. The function is also changed to return
a proper error code instead of crashing. Furthermore, users of the
function are expected to provide a handler function for all device
operations. The early check via asserts ensures that missing handlers
are easily detected in debug builds without having to explicitly call
all device operations.

Checkpatch-Ignore: USE_NEGATIVE_ERRNO
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/devfs: Fix format of include guard
Marc Rittinghaus [Thu, 20 Apr 2023 14:51:23 +0000 (16:51 +0200)]
lib/devfs: Fix format of include guard

The include guard should contain the name of the component.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/devfs: Remove unused header file
Marc Rittinghaus [Thu, 20 Apr 2023 14:50:06 +0000 (16:50 +0200)]
lib/devfs: Remove unused header file

The devfs.h header file serves no purpose as it potential define for
debug builds is not used anywhere.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/devfs: Remove unused fields and functions
Marc Rittinghaus [Thu, 20 Apr 2023 14:47:45 +0000 (16:47 +0200)]
lib/devfs: Remove unused fields and functions

The definition for device objects contain numerous fields which are not
used. In addition, there are various function definitions and
declarations which are not used or not even related to generic devices
(e.g., partition table). This commit removes all of these definitions.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/devfs: Remove unused devops
Marc Rittinghaus [Thu, 20 Apr 2023 14:39:25 +0000 (16:39 +0200)]
lib/devfs: Remove unused devops

This commit removes unused operations from the device operations
structure and updates the no-op macros and functions to be usable
for seldomly set operations (also externally).

Checkpatch-Ignore: FUNCTION_WITHOUT_ARGS
Checkpatch-Ignore: USE_NEGATIVE_ERRNO
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855

2 years agolib/vfscore: Fix leak in sys_futimens
Marc Rittinghaus [Mon, 24 Apr 2023 15:21:15 +0000 (17:21 +0200)]
lib/vfscore: Fix leak in sys_futimens

Previously, sys_futimens() retrieved a reference to the file
descriptor to get a value for the pathname argument. The reference
was not freed afterwards. Since sys_utimensat() has been changed
to accept NULL as pathname and work on dirfd instead, the code
can be removed altogether.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Rares Miculescu <miculescur@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865

2 years agolib/vfscore: sys_utimensat style fixes
Marc Rittinghaus [Mon, 24 Apr 2023 15:18:58 +0000 (17:18 +0200)]
lib/vfscore: sys_utimensat style fixes

This commit fixes a few styling issues in sys_utimensat() and its
utility functions.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Rares Miculescu <miculescur@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865

2 years agolib/vfscore: Use unlikely() for error checks
Marc Rittinghaus [Mon, 24 Apr 2023 15:17:27 +0000 (17:17 +0200)]
lib/vfscore: Use unlikely() for error checks

This commit adds the unlikely() macro to remaining error checks in
sys_utimensat().

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Rares Miculescu <miculescur@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865

2 years agolib/vfscore: Exit sys_utimensat on all UTIME_OMIT
Marc Rittinghaus [Mon, 24 Apr 2023 15:12:07 +0000 (17:12 +0200)]
lib/vfscore: Exit sys_utimensat on all UTIME_OMIT

This commit restructures the sanity checks of the input timespecs
to come before all other checks and to include an early exit of
both times are UTIME_OMIT. This is inline with the behavior on
Linux.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Rares Miculescu <miculescur@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865

2 years agolib/vfscore: Remove surplus check and fix leak
Marc Rittinghaus [Mon, 24 Apr 2023 14:57:21 +0000 (16:57 +0200)]
lib/vfscore: Remove surplus check and fix leak

The dedicated check for a readonly filesystem can be removed
in sys_utimensat(), because it is part of vn_access(). The commit
also fixes a leak of reference to the dentry in case of an error.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Rares Miculescu <miculescur@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865