]> xenbits.xensource.com Git - unikraft/unikraft.git/log
unikraft/unikraft.git
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

2 years agolib/vfscore: Linux compatibility for sys_utimensat
Marc Rittinghaus [Mon, 24 Apr 2023 14:54:37 +0000 (16:54 +0200)]
lib/vfscore: Linux compatibility for sys_utimensat

Previously, if pathname is either NULL or a relative path, and
dirfd is not AT_FDCWD, dirfd needed to refer to a directory.
However, in Linux there is a non-conformant behavior that
if pathname is NULL, the timestamps are applied to whatever
file dirfd refers to. For improved Linux compatibility, we
adopt this behavior.

This commit also fixes various leaks of the file descriptor
reference that is received via the call to vfscore_get_file().

Github-Fixes: #858
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: Fix error checks in sys_utimensat
Marc Rittinghaus [Mon, 24 Apr 2023 14:19:25 +0000 (16:19 +0200)]
lib/vfscore: Fix error checks in sys_utimensat

If successful, asprintf() returns the number of characters written. Due
to the format strings this will always be >0. On error, asprintf()
returns -1, which means the return value will in any case be non-zero,
always leading to a (false) ENOMEM.

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 VAPPEND mode
Marc Rittinghaus [Mon, 24 Apr 2023 14:13:06 +0000 (16:13 +0200)]
lib/vfscore: Remove VAPPEND mode

vfscore defines a VAPPEND mode bit which is only used in
sys_utimensat() and which erroneously overlaps with VEXEC permission
for the group. While VAPPEND is a useful feature, it needs a proper
definition and support in all vfscore APIs. We thus remove the
broken definition for now.

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: Check for EBADF in dup2
Marc Rittinghaus [Mon, 24 Apr 2023 06:59:28 +0000 (08:59 +0200)]
lib/vfscore: Check for EBADF in dup2

In contrast to dup3(), dup2() returns the oldfd if oldfd and newfd
are equal. However, the fd still needs to be valid. Otherwise, EBADF
has to be returned.

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: Fix multiple issues with dup3
Marc Rittinghaus [Mon, 24 Apr 2023 06:54:18 +0000 (08:54 +0200)]
lib/vfscore: Fix multiple issues with dup3

dup3() is broken in multiple ways:
1) the fget() for newfd leaks the the file reference before the close
2) the error code from close() is -1 instead of the errno value
3) the old file descriptor is duplicated to a new fd slot. However, its
reference is not incremented due to the fdrop().
4) there is a race condition between the close() of newfd and its
reservation for the to-be-duplicated file description

This commit fixes all these issues except the race condition, which
needs new functionality to atomically replace a file description in
the fd tab.

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: Fix zero refcount for stdio
Marc Rittinghaus [Mon, 24 Apr 2023 06:42:33 +0000 (08:42 +0200)]
lib/vfscore: Fix zero refcount for stdio

For stdio we use statically allocated VFS structures. However,
for the dentry the reference count was not properly initialized.

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/uksched/*: Use per-lcpu variable for current thread
Andra Paraschiv [Thu, 2 Mar 2023 14:19:06 +0000 (14:19 +0000)]
lib/uksched/*: Use per-lcpu variable for current thread

Currently there is a global variable that keeps track of the current
thread that is used by the scheduler logic.

Use a per-lcpu variable instead, to also match the case when multiple
cores are used for the unikernel setup.

Signed-off-by: Andra Paraschiv <andra@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #784

2 years agoinclude/uk/plat/lcpu: Add per-lcpu variable definition
Andra Paraschiv [Thu, 2 Mar 2023 14:11:28 +0000 (14:11 +0000)]
include/uk/plat/lcpu: Add per-lcpu variable definition

Add a definition for the per-lcpu variable and functionality to
get this variable using the lcpu index.

Checkpatch-Ignore: COMPLEX_MACRO
Signed-off-by: Andra Paraschiv <andra@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #784

2 years agoplat/x86: Add `write-combined` page entry attribute
Marco Schlumpp [Tue, 25 Oct 2022 13:45:14 +0000 (15:45 +0200)]
plat/x86: Add `write-combined` page entry attribute

This attribute is useful for memory-mapped devices and can reduce the
amount of transactions necessary when communicating with the device.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Alexander Jung <alex@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #788

2 years agoplat/common/x86: Add PAT MSR
Marc Rittinghaus [Thu, 27 Apr 2023 10:38:16 +0000 (12:38 +0200)]
plat/common/x86: Add PAT MSR

This commit adds the definition of the page attribute table (PAT)
configuration MSR.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Alexander Jung <alex@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #788

2 years agoinclude/arch/x86_64: Add PAT bits
Marc Rittinghaus [Thu, 27 Apr 2023 10:36:54 +0000 (12:36 +0200)]
include/arch/x86_64: Add PAT bits

This commit adds definitions for configuration of the page attribute
table on x86.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Alexander Jung <alex@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #788

2 years agolib/vfscore: Add README.md file
Radu Nichita [Mon, 6 Mar 2023 14:06:14 +0000 (16:06 +0200)]
lib/vfscore: Add README.md file

Provides information about how to interact with the vfscore library,
including details about hierarchy, core components and registration
of a new filesystem in Unikraft.

Signed-off-by: Radu Nichita <radunichita99@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: #780

2 years agodrivers/virtio: Fix interrupt flag check
Marco Schlumpp [Tue, 14 Feb 2023 14:02:17 +0000 (15:02 +0100)]
drivers/virtio: Fix interrupt flag check

The check used a bit-OR instead of a bit-AND to check whether the flag
is set.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #761

2 years agobuild/Makefile: Force update UK_CONFIG
i.Pear [Wed, 29 Mar 2023 18:12:51 +0000 (02:12 +0800)]
build/Makefile: Force update UK_CONFIG

The builder uses $(UK_CONFIG) to generate files such as
$(KCONFIG_AUTOHEADER) in the build directory. When $(UK_CONFIG) changes,
these newly generated files will also be regenerated.

However, $(UK_CONFIG) may not remain consistent across multiple builds.
For example, in the following command sequence:

> make C=.config_kvm-x86_64
> make C=.config_linuxu-x86_64
> make C=.config_kvm-x86_64

During the first two builds, the configuration files in the build
directory will be regenerated. But when using the same configuration file
as the first time in the third build, because .config_kvm-x86_64 is not a
new version, the configuration files in the build directory will remain
the version of linuxu, which will cause the build to fail.

When using kraftkit, similar issues can also be reproduced. Executing
"kraft build --arch x86_64" twice, each time is in the order of linuxu,
kvm, and xen. When building linuxu for the second time, the configuration
files in the build directory are still the configuration of xen, which
also causes the build to fail.

This patch forces $(UK_CONFIG) to be recognized as updated, so that the
configuration files in the build directory are always updated. It has been
tested and can fix this issue.

Signed-off-by: Tianyi Liu <i.pear@outlook.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: #817

2 years agolib/9pfs: Add README.md file for 9pfs
Delia-Maria Pavel [Sat, 15 Apr 2023 15:17:34 +0000 (18:17 +0300)]
lib/9pfs: Add README.md file for 9pfs

Signed-off-by: Delia-Maria Pavel <delia_maria.pavel@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: #837

2 years agolib/syscall_shim: Add (F|R|W|X)_OK and access
Marc Rittinghaus [Fri, 14 Apr 2023 15:01:15 +0000 (17:01 +0200)]
lib/syscall_shim: Add (F|R|W|X)_OK and access

This commit adds a definition of the (F|R|W|X)_OK flags
and the access syscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

2 years agolib/syscall_shim: Add pread64 syscall
Marc Rittinghaus [Fri, 14 Apr 2023 14:57:26 +0000 (16:57 +0200)]
lib/syscall_shim: Add pread64 syscall

This commit adds a definition of the pread64 syscall to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

2 years agolib/syscall_shim: Add utsname struct and uname
Marc Rittinghaus [Fri, 14 Apr 2023 14:55:57 +0000 (16:55 +0200)]
lib/syscall_shim: Add utsname struct and uname

This commit adds a definition of the utsname struct
and the uname syscall to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

2 years agolib/syscall_shim: Add stat struct
Marc Rittinghaus [Fri, 14 Apr 2023 14:49:53 +0000 (16:49 +0200)]
lib/syscall_shim: Add stat struct

This commit adds a definition of the stat struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

2 years agolib/syscall_shim: Add timespec struct
Marc Rittinghaus [Fri, 14 Apr 2023 14:23:20 +0000 (16:23 +0200)]
lib/syscall_shim: Add timespec struct

This commit adds a definition of the timespec struct to prsyscall

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

2 years agolib/syscall_shim: Add struct printing
Marc Rittinghaus [Fri, 14 Apr 2023 14:14:00 +0000 (16:14 +0200)]
lib/syscall_shim: Add struct printing

This commit adds macros for printing selected members of
struct types in the prsyscall output just like strace. The PT_STRUCT
macro takes the struct's name to form a new parameter type name.
The PR_STRUCT macro prints the fields specified in the var args. Nested
printing of struct fields members is supported for structs pointers as
well as for embedded structs. Whenever fields that are usually pointers
(e.g., PT_CHARP or PT_STRUCT) are embedded, the `PT_SVAL` flag must
be specified.

Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

2 years agolib/syscall_shim: Add 0x prefix to PT_HEX
Marc Rittinghaus [Fri, 14 Apr 2023 16:22:32 +0000 (18:22 +0200)]
lib/syscall_shim: Add 0x prefix to PT_HEX

Currently, it is hard to know if a value is a hexadecimal or decimal
number if there are no letters in the output. This commit adds the
hex prefix 0x to avoid the confusion.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

2 years agolib/syscall_shim: Add PT_OCTAL to print octals
Marc Rittinghaus [Fri, 14 Apr 2023 14:46:14 +0000 (16:46 +0200)]
lib/syscall_shim: Add PT_OCTAL to print octals

There are already types for decimal and hexadecimal printing.
This commit adds a type for octals.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

2 years agolib/syscall_shim: Make printing type optional
Marc Rittinghaus [Fri, 14 Apr 2023 16:10:56 +0000 (18:10 +0200)]
lib/syscall_shim: Make printing type optional

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

2 years agolib/syscall_shim: Print PT_OUT only on success
Marc Rittinghaus [Fri, 14 Apr 2023 15:47:19 +0000 (17:47 +0200)]
lib/syscall_shim: Print PT_OUT only on success

Previously, we are printing buffers and output strings also when the
call fails. However, in that case it will usually contain no meaningful
value so we reduce trace output by just printing the buffer's target
address.

Checkpatch-Ignore: COMPLEX_MACRO
Checkpatch-Ignore: TRAILING_SEMICOLON
Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Checkpatch-Ignore: MULTISTATEMENT_MACRO_USE_DO_WHILE
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836

2 years agolib/posix-event: Implement the EFD_NONBLOCK flag for eventfd
Marco Schlumpp [Wed, 1 Feb 2023 13:40:47 +0000 (14:40 +0100)]
lib/posix-event: Implement the EFD_NONBLOCK flag for eventfd

This flag allows conveniently setting O_NONBLOCK without having to use
a separate `fcntl` call.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #754

2 years agolib/syscall_shim: Add `syscall` alias to `uk_syscall`
Marco Schlumpp [Wed, 1 Feb 2023 13:39:22 +0000 (14:39 +0100)]
lib/syscall_shim: Add `syscall` alias to `uk_syscall`

The symbol is required for binaries that were compiled against a Linux
musl and use musl's system call wrapper.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #755

2 years agolib/posix-event: Add an empty implementation of ioctl to eventfd
Marco Schlumpp [Wed, 1 Feb 2023 13:42:17 +0000 (14:42 +0100)]
lib/posix-event: Add an empty implementation of ioctl to eventfd

The fcntl function will forward fcntl(O_NONBLOCK), to the
underlying vnode `ioctl` op function, when a definition of FIONBIO and
FIOASYNC is present. This effectively makes `ioctl` a required function
for the vnops structure.

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

2 years agolib/posix-event: Update `uio_offset` and `uio_resid` on successful reads
Eduard Vintilă [Sat, 11 Mar 2023 18:29:59 +0000 (20:29 +0200)]
lib/posix-event: Update `uio_offset` and `uio_resid` on successful reads

This commit updates (on a sucessful read) the `uio_offset` and
`uio_resid` members of the `uio` structure passed to the
`eventfd_vfscore_read` function. Without updating those members, the
`read` function from the vfscore layer will always report that no bytes
have been read at all.

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #798

2 years agolib/9pfs: Add truncate to 9P_PROTO_2000U
Marc Rittinghaus [Wed, 12 Apr 2023 13:22:54 +0000 (15:22 +0200)]
lib/9pfs: Add truncate to 9P_PROTO_2000U

When providing a length in the stat structure the 9pfs server on the
host will truncate the file to the specified size. We use this to also
enable truncation for the 2000U protocol version. Since uk_9pfs_setattr
checks for the protocol to use, the check can be completely dropped in
uk_9pfs_truncate.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <teodor.teugea@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: #834

2 years agolib/9pfs: Add fsync to 9P_PROTO_2000U
Marc Rittinghaus [Wed, 12 Apr 2023 13:19:43 +0000 (15:19 +0200)]
lib/9pfs: Add fsync to 9P_PROTO_2000U

Using the unmodified "dont-touch" stat structure in uk_9pfs_setattr is
equivalent to performing an fsync on the file.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <teodor.teugea@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: #834

2 years agolib/9pfs: Fix I/O error with chmod on directories
Marc Rittinghaus [Wed, 12 Apr 2023 13:14:56 +0000 (15:14 +0200)]
lib/9pfs: Fix I/O error with chmod on directories

When we perform a chmod on a directory with the 9P_PROTO_2000U
protocol, the TWSTAT command is used with a previously received and
modified stat structure as parameter. There are two bugs in this.

First, updating the mode will remove the type information stored in the
high bits of the mode field. The call to the 9pfs device thus fails because
the 9pfs server thinks we want to change the directory to a regular
file.

Fixing this, will reveal another issue. The update should use a
specifically initialized "dont-touch" stat structure instead of
receiving the current structure. The 9pfs server will only update
the properties that divert from this "dont-touch" structure. This
is important because otherwise the length field of the stat
structure is set and the server tries to truncate the directory
object on the host, which fails and eventually will be reported
as failed chmod to the guest application.

Github-Fixes: #812
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <teodor.teugea@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: #834

2 years agolib/uksglist: Make sure buffers are mapped
Marc Rittinghaus [Wed, 12 Apr 2023 12:55:03 +0000 (14:55 +0200)]
lib/uksglist: Make sure buffers are mapped

With ukvmem and demand-paging enabled it can happen that buffers
supplied to the sglist are not fully backed by physical memory. In that
case the call to ukplat_virt_to_phys() fails, which expects a valid
mapping.

This commit adds a call to uk_vma_advise() to make sure the entire
buffer is backed by physical memory.

A future optimization should integrate the address translation and
backing with physical memory in a visitor pattern that traverses the
page tables only once instead of doing it one time for the advise and
then an extra time for each page of the buffer.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <teodor.teugea@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: #834

2 years agolib/uksignal: Add sigaltstack stub
Marc Rittinghaus [Wed, 12 Apr 2023 12:46:26 +0000 (14:46 +0200)]
lib/uksignal: Add sigaltstack stub

This commit adds a stub for the sigaltstack system call, which is
necessary to run GO applications in binary compat mode.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Ioan-Teodor Teugea <teodor.teugea@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: #834

2 years agoplat/x86: Enable NX bit when initializing paging
Marco Schlumpp [Thu, 9 Feb 2023 11:28:50 +0000 (12:28 +0100)]
plat/x86: Enable NX bit when initializing paging

There are a few reasons to enable the NX bit in the paging init routine:
* Setting the bit before checking for actual support is risky.
  Currently, the check happens in the paging initialization routine.
* The bit is not used, when the Unikraft paging support is not enabled.
* Every boot entry point (32-bit/64-bit) would have a duplicated enable.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Florin Postolache <florin.postolache80@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #752

2 years agoplat/common: Merge `.gcc_except_table`s
Marco Schlumpp [Tue, 7 Feb 2023 11:12:01 +0000 (12:12 +0100)]
plat/common: Merge `.gcc_except_table`s

These tables are generated by GCC for exception handling. This merges
the individual section together instead of keeping thousands of them
separate.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@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: #753

2 years agolib/vfscore: Remove _BSD_SOURCE from mount.h
Taehyun Noh [Sun, 2 Apr 2023 11:33:51 +0000 (20:33 +0900)]
lib/vfscore: Remove _BSD_SOURCE from mount.h

The issue #821 was caused by defining the feature macro `_BSD_SOURCE` in
a header file `include/vfscore/mount.h`. This commit moves the macro
from the header to its source files, resolving the issue.

Github-Fixes: #821
Signed-off-by: Taehyun Noh <likeinstein42@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: #824

2 years agolib/ukalloc: Ensure the ifpages metadata does not break any alignments
Marco Schlumpp [Thu, 9 Feb 2023 14:46:02 +0000 (15:46 +0100)]
lib/ukalloc: Ensure the ifpages metadata does not break any alignments

By using the rounded version of the metadata size, we can ensure that
the resulting alignments are suitable for any C scalar type. This is a
requirement for any malloc implementation.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Andra Paraschiv <andra@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #757

2 years agolib/nolibc: Define max_align_t type
Marco Schlumpp [Thu, 9 Feb 2023 14:27:09 +0000 (15:27 +0100)]
lib/nolibc: Define max_align_t type

Every scalar type has an alignment requirement that is less than or
equal the alignment requirement of this type.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Andra Paraschiv <andra@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #757

2 years agolib/vfscore: Enable FIONBIO in fcntl(F_SETFL)
Marc Rittinghaus [Thu, 20 Apr 2023 07:49:02 +0000 (09:49 +0200)]
lib/vfscore: Enable FIONBIO in fcntl(F_SETFL)

Currently, we are synching FIONBIO to the underlying file
implementation via an ioctl only if FIONBIO is defined in
vfscore. Since this is not the case, setting O_NONBLOCK on
a file descriptor does not have any effect. This commit
includes the necessary header and also fixes the
fcntl(F_SETFL) and ioctl() to make sure that the state of
the file stays in sync with its flags.

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

2 years agolib/nolibc: Fix ioctl signature
Marc Rittinghaus [Thu, 20 Apr 2023 07:12:35 +0000 (09:12 +0200)]
lib/nolibc: Fix ioctl signature

The signature of ioctl imported from musl uses a signed int as second
argument. This, however, differs from the definition in Linux, glibc,
and our own implementation, which use an unsigned long. Since using
int has lead to all sorts of problems also for musl (e.g., overflow into
sign bit), this commit adopts unsigned long also for the musl imported
header.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Andra Paraschiv <andra@unikraft.io>
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: #850

2 years agolib/nolibc: Prototypes for `pread` and `pwrite`
Simon Kuenzer [Tue, 18 Apr 2023 14:20:50 +0000 (16:20 +0200)]
lib/nolibc: Prototypes for `pread` and `pwrite`

This commit introduces the prototypes for `pread` and `pwrite` with
nolibc's `<unistd.h>` header. These functions are provided by
`lib/vfscore`.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Andra Paraschiv <andra@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: #846

2 years agolib/vfscore: Fix error return on symlink syscall
Stefan Jumarea [Thu, 20 Apr 2023 10:29:49 +0000 (13:29 +0300)]
lib/vfscore: Fix error return on symlink syscall

The `sys_symlink()` function returns `ENOENT` if the lookup failed,
instead of the actual error code `lookup()` exited with.
This may not always be right, since `lookup()` can return other error
codes (for example `ELOOP`).

Fix that by not setting the error code and just jump to the end of the
function.

Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
GitHub-Closes: #849
Reviewed-by: Andra Paraschiv <andra@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #851

2 years agolib/posix-event: Fix type of `revents` pointer
Marco Schlumpp [Thu, 2 Mar 2023 14:12:10 +0000 (15:12 +0100)]
lib/posix-event: Fix type of `revents` pointer

The type of revents is a `short` and not an `int`. This caused
out-of-bounds writes and possibly in stack corruption.

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

2 years agolib/9pfs: Add comments to 9pfs.h file
Delia-Maria Pavel [Sat, 11 Mar 2023 14:09:17 +0000 (16:09 +0200)]
lib/9pfs: Add comments to 9pfs.h file

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

2 years agolib/9pfs: Enable the symlink support for UK_9P_PROTO_2000U 9pfs version
Andra Paraschiv [Mon, 10 Apr 2023 09:25:04 +0000 (09:25 +0000)]
lib/9pfs: Enable the symlink support for UK_9P_PROTO_2000U 9pfs version

Till now, symlink files could be created / opened only when using the
UK_9P_PROTO_2000L 9pfs version.

The current default 9pfs version is UK_9P_PROTO_2000U.

Enable the symlink support also for the UK_9P_PROTO_2000U 9pfs version.

Signed-off-by: Andra Paraschiv <andra@unikraft.io>
Reviewed-by: Florin Postolache <florin.postolache.of@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: #830

2 years agolib/vfscore: Initialize the fp variable to an empty string
Andra Paraschiv [Wed, 12 Apr 2023 05:12:52 +0000 (05:12 +0000)]
lib/vfscore: Initialize the fp variable to an empty string

Sometimes the fp local string variable includes data that was
used before e.g. previous file paths. Thus, fp can contain characters
that are not part of the currently processed file path and different
errors can appear e.g. ENOENT (No such file or directory), when trying
to open a file.

Initialize the fp variable to an empty string before using it.

Signed-off-by: Andra Paraschiv <andra@unikraft.io>
Reviewed-by: Florin Postolache <florin.postolache.of@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: #830

2 years agolib/vfscore: Fix the mountpoint length for the symlink support
Andra Paraschiv [Mon, 10 Apr 2023 09:11:32 +0000 (09:11 +0000)]
lib/vfscore: Fix the mountpoint length for the symlink support

Opening a symlink file doesn't successfully complete. The mountpoint
length provided to the function that resolves a symlink needs to be
adjusted.

Update the mountpoint length to be the difference in size between the
full path of the symlink file and the relative path of the symlink file
to the mountpoint.

Signed-off-by: Andra Paraschiv <andra@unikraft.io>
Reviewed-by: Florin Postolache <florin.postolache.of@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: #830

2 years agolib/ukvmem: Allow non-writable shared file mappings
Cosmin Vancea [Mon, 10 Apr 2023 15:43:11 +0000 (18:43 +0300)]
lib/ukvmem: Allow non-writable shared file mappings

Non-writable shared file mappings are treated as anonymous read-only file
mappings. Note that any writes made to the underlying file will not be
reflected in memory.

Signed-off-by: Cosmin Vancea <csvancea@gmail.com>
Reviewed-by: Andra Paraschiv <andra@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #832

2 years agolib/uk9p: Fix cast to invalid type
Hugo Lefeuvre [Sun, 16 Apr 2023 15:14:19 +0000 (17:14 +0200)]
lib/uk9p: Fix cast to invalid type

req is cast to void*, which is somewhat confusing since the function
returns a struct uk_9pfid *.

This patch was generated by the following Coccinelle semantic patch:

    @@
    expression E;
    type T;
    type R;
    function f;
    @@

    T* f(...) {
    <... when any
    - return (R*)E;
    + return (T*)E;
    ...>
    }

    @@
    type T;
    identifier X;
    function f;
    @@

    f(...) {
    ...
    T* X;
    <... when any
    - return (T*)X;
    + return X;
    ...>
    }

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Approved-by: Marco Schlumpp <marco@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #844

2 years agolib/vfscore: Fix potential free(NULL)
Hugo Lefeuvre [Sun, 16 Apr 2023 13:45:43 +0000 (15:45 +0200)]
lib/vfscore: Fix potential free(NULL)

This bug was found by Coccinelle with the following spatch:

    @@
    expression E;
    @@

    if(E) {...}
    -free(E);

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Reviewed-by: Tu Dinh Ngoc <dinhngoc.tu@irit.fr>
Reviewed-by: Eduard-Florin Mihailescu <mihailescu.eduard@gmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #843

2 years agolib/ukvmem: Compile all source files for ISR context
Marco Schlumpp [Thu, 9 Feb 2023 12:04:57 +0000 (13:04 +0100)]
lib/ukvmem: Compile all source files for ISR context

The main and individual pagefault handlers are executed in an ISR
context. Not marking the files as `isr`, will cause the usual trouble
(clobbered vector registers).

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #751

2 years agolib/ukdebug: Handle a full tracing buffer correctly
Marco Schlumpp [Mon, 13 Mar 2023 10:03:33 +0000 (11:03 +0100)]
lib/ukdebug: Handle a full tracing buffer correctly

The `__uk_trace_save_arg` function sets the `uk_trace_buffer_free` to
zero. The code previously subtracted the size from the
`uk_trace_buffer_free` variable even in this case causing an integer
underflow. Further trace-point emissions would then happily write past
the tracing buffer.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #810

2 years agoplat/common: Ensure the `.eh_frame` section stays
Marco Schlumpp [Thu, 2 Mar 2023 14:16:40 +0000 (15:16 +0100)]
plat/common: Ensure the `.eh_frame` section stays

Using the `CONFIG_OPTIMIZE_DEADELIM` KConfig option adds the
`--gc-sections` command-line flag to the linker. Because the `.eh_frame`
section is not really referenced anywhere the linker will happily throw
it away. The solution is to mark it with `KEEP` in the linker scripts.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Alexander Jung <alex@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #776

2 years agolib/ukmmap: Unit tests: check mmap/munmap results
Kha Dinh [Thu, 16 Mar 2023 10:02:06 +0000 (19:02 +0900)]
lib/ukmmap: Unit tests: check mmap/munmap results

I added the unit test (adapted from posix-mmap tests) that call mmap/munmap
and check the results to see if they executed successfully.

Signed-off-by: Kha Dinh <dalo2903@gmail.com>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #802

2 years agolib/ukmmap: replace deprecated WARN_STUBBED
Kha Dinh [Thu, 16 Mar 2023 09:32:30 +0000 (18:32 +0900)]
lib/ukmmap: replace deprecated WARN_STUBBED

WARN_STUBBED is now replaced by UK_WARN_STUBBED.

Signed-off-by: Kha Dinh <dalo2903@gmail.com>
Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #802

2 years agobuild: Detect if `gawk` can be used instead of `awk`
Simon Kuenzer [Thu, 16 Mar 2023 10:51:22 +0000 (11:51 +0100)]
build: Detect if `gawk` can be used instead of `awk`

This commit lets the build system pick preferably `gawk` as drop-in
replacement for `awk`. GNU AWK has the advantage that it emits
understandable error messages on AWK script errors. This simplifies
developing or editing awk files.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Florin Postolache <florin.postolache.of@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: #803

2 years agolib/nolibc: Fix wrong type for the `st_nlink` field inside `struct stat`
Cosmin Vancea [Sun, 9 Apr 2023 20:52:33 +0000 (23:52 +0300)]
lib/nolibc: Fix wrong type for the `st_nlink` field inside `struct stat`

For Linux x64 it is supposed to be of type `unsigned long`, yet we
had it defined as `unsigned int`. Here is a link to the relevant
kernel structure:

https://elixir.bootlin.com/linux/v6.2.10/source/arch/x86/include/uapi/asm/stat.h#L86

Signed-off-by: Cosmin Vancea <csvancea@gmail.com>
Reviewed-by: Andra Paraschiv <andra@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: #829

2 years agoplat/kvm: Change unhandled irq message to a tracepoint
Marco Schlumpp [Mon, 20 Feb 2023 14:11:32 +0000 (15:11 +0100)]
plat/kvm: Change unhandled irq message to a tracepoint

It's not possible to call a print function in an interrupt context,
because these are not ISR safe and will mess up the interrupted context.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Andra Paraschiv <andra@unikraft.io>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #768

2 years agolib/posix-process: Fix build warnings
Konstantinos Koukopoulos [Fri, 31 Mar 2023 08:01:15 +0000 (11:01 +0300)]
lib/posix-process: Fix build warnings

GitHub-Fixes: #818

Co-authored-by: Nikos Oikonomou <el20014@mail.ntua.gr>
Signed-off-by: Nikos Oikonomou <el20014@mail.ntua.gr>
Signed-off-by: Konstantinos Koukopoulos <koukopoulos@gmail.com>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #820

2 years agolib/posix-mmap: Fix wrong errno value
Ioan-Teodor Teugea [Sat, 11 Mar 2023 20:04:08 +0000 (22:04 +0200)]
lib/posix-mmap: Fix wrong errno value

The currently used syscall shim macro handles a return value of -1
by setting the return value to the value of errno, which results in
incorrect behaviour with mmap, which returns a MAP_FAILED (-1) address
as an indicator of failure. The result is that in case of mmap error,
the syscall will return the value of errno as the address, rather
than returning -1 and setting errno.

This commit fixes the issue by setting errno to the correct value
in case of mmap error.

Co-authored-by: Razvan Deaconescu <razvand@unikraft.io>
Co-authored-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Signed-off-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #799

2 years agolib/posix-mmap: Fix MAP_SHARED_VALIDATE
Marc Rittinghaus [Fri, 10 Mar 2023 10:03:32 +0000 (11:03 +0100)]
lib/posix-mmap: Fix MAP_SHARED_VALIDATE

MAP_SHARED_VALIDATE is defined as 3, while MAP_PRIVATE is defined
as 2. A MAP_PRIVATE will thus also evaluate to true for the
MAP_SHARED_VALIDATE test. This commit fixes the flag test.

Co-authored-by: Cosmin Vancea <csvancea@gmail.com>
Co-authored-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #790

2 years agolib/posix-mmap: Fix missing address update
Marc Rittinghaus [Thu, 9 Mar 2023 11:21:40 +0000 (12:21 +0100)]
lib/posix-mmap: Fix missing address update

The mmap() call does not return the allocated virtual address via the
addr argument.

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

2 years agoplat/kvm-x86: Use IST for regular traps
Marc Rittinghaus [Thu, 9 Mar 2023 11:19:45 +0000 (12:19 +0100)]
plat/kvm-x86: Use IST for regular traps

Although using IST does not allow nested exceptions we go back to
a dedicated stack for regular traps and use IST to switch to it. This
prevents an issue with ukvmem, where a stack is allocated from pageable
heap and pushing to a non-present stack page leads to a double fault.

With this change the stack is switched to the dedicated trap stack and
the page fault for the original stack can be resolved.

A solution to allow nested exceptions would be to reconfigure the trap
to not use IST before executing code that can potentially fail and
restoring IST configuration on afterwards.

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

2 years agoRelease: v0.12.0 Epimetheus RELEASE-0.12.0
Alexander Jung [Tue, 7 Feb 2023 14:00:31 +0000 (14:00 +0000)]
Release: v0.12.0 Epimetheus

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Signed-off-by: Marc Rittinghaus <marc@unikraft.io>
Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Signed-off-by: Alexander Jung <alex@unikraft.io>
2 years agolib/syscall_shim: uk_prsyscall: Fix typecast for PT_BUFP
Simon Kuenzer [Tue, 7 Feb 2023 10:03:58 +0000 (11:03 +0100)]
lib/syscall_shim: uk_prsyscall: Fix typecast for PT_BUFP

PT_BUFP prints binary buffer content human readable but had one
particular problem: Due to incomplete typecasting, printing of a
negative byte (__s8) caused printing a 4-byte hex sequence instead
of just one byte with the format: `\0xHH`.
This commit fixes this with proper typecasting.

Signed-off-by: Simon Kuenzer <simon@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: #750

2 years agoplat/common/x86: 16-byte align syscall stack
Marc Rittinghaus [Sun, 5 Feb 2023 11:02:52 +0000 (12:02 +0100)]
plat/common/x86: 16-byte align syscall stack

Currently, the user stack is used as kernel stack. This can be
a problem if the stack is not aligned on syscall entry. However, it
may be aligned for some calls. We thus cannot just push a fixed
amount of words. Instead, we store the original stack pointer and
align it using an and operation, which guarantees correct alignment
in any case.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@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: #748

2 years agolib/uksched: Align allocated stacks to arch requirement
Simon Kuenzer [Sat, 4 Feb 2023 13:17:05 +0000 (14:17 +0100)]
lib/uksched: Align allocated stacks to arch requirement

This commits introduces aligns stack allocation that are done by
`lib/uksched` to the requirement of the target architecture. Without
aligned stacks, random crashed may occur because the compiler is assuming
such an alignment. An incorrect stack alignment can cause crashes because
the compiler may placed instructions in the code that will fail when
accessing values on the stack if not properly aligned.

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

2 years agosupport/scripts: Allow overlapping bootinfo region
Marc Rittinghaus [Sat, 4 Feb 2023 04:32:20 +0000 (05:32 +0100)]
support/scripts: Allow overlapping bootinfo region

Preliminary fix: Unikraft expects memory regions in the boot info
to not overlap and be page aligned. This is, however, not
compatible with having the .tdata section being assigned its
dedicated segment. This commit removes the sanity checks for
now as Unikraft can handle this specific case.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis.pappas@opensynergy.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #746

2 years agoplat/xen/x86: Add tls_load segment
Marc Rittinghaus [Sat, 4 Feb 2023 04:14:14 +0000 (05:14 +0100)]
plat/xen/x86: Add tls_load segment

This commit adds the tls_load segment that is needed for the .tdata
section.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis.pappas@opensynergy.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #746

2 years agoplat/xen/arm: Add tls_load segment
Marc Rittinghaus [Sat, 4 Feb 2023 04:13:51 +0000 (05:13 +0100)]
plat/xen/arm: Add tls_load segment

This commit adds the tls_load segment that is needed for the .tdata
section.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis.pappas@opensynergy.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #746

2 years agoplat/kvm/arm: Add tls_load segment
Marc Rittinghaus [Sat, 4 Feb 2023 04:13:28 +0000 (05:13 +0100)]
plat/kvm/arm: Add tls_load segment

This commit adds the tls_load segment that is needed for the .tdata
section.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis.pappas@opensynergy.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #746