]> xenbits.xensource.com Git - unikraft/unikraft.git/log
unikraft/unikraft.git
17 months agoMerge remote-tracking branch 'andreittr/ttr/newvfs-timerfd' into testing testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:49 +0000 (17:39 +0200)]
Merge remote-tracking branch 'andreittr/ttr/newvfs-timerfd' into testing

17 months agoMerge remote-tracking branch 'unikraft-upb/StefanJum/posiz-sysinfo' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:47 +0000 (17:39 +0200)]
Merge remote-tracking branch 'unikraft-upb/StefanJum/posiz-sysinfo' into testing

17 months agoMerge remote-tracking branch 'DeliaPavel/readme_posix_user' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:44 +0000 (17:39 +0200)]
Merge remote-tracking branch 'DeliaPavel/readme_posix_user' into testing

17 months agoMerge remote-tracking branch 'RaduNichita/radun/add-posixtime-README' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:42 +0000 (17:39 +0200)]
Merge remote-tracking branch 'RaduNichita/radun/add-posixtime-README' into testing

17 months agoMerge remote-tracking branch 'mogasergiu/smoga/stack_switch' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:38 +0000 (17:39 +0200)]
Merge remote-tracking branch 'mogasergiu/smoga/stack_switch' into testing

17 months agoMerge remote-tracking branch 'mogasergiu/smoga/fix_wrong_TLS_on_arch_prctl' into...
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:36 +0000 (17:39 +0200)]
Merge remote-tracking branch 'mogasergiu/smoga/fix_wrong_TLS_on_arch_prctl' into testing

17 months agoMerge remote-tracking branch 'andreistan26/misaligned-section-xen' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:34 +0000 (17:39 +0200)]
Merge remote-tracking branch 'andreistan26/misaligned-section-xen' into testing

17 months agoMerge remote-tracking branch 'DeliaPavel/comments_lib_posix-user' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:33 +0000 (17:39 +0200)]
Merge remote-tracking branch 'DeliaPavel/comments_lib_posix-user' into testing

17 months agoMerge remote-tracking branch 'cocodery/issue1147' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:30 +0000 (17:39 +0200)]
Merge remote-tracking branch 'cocodery/issue1147' into testing

17 months agoMerge remote-tracking branch 'eduardvintila/go-fixes' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:28 +0000 (17:39 +0200)]
Merge remote-tracking branch 'eduardvintila/go-fixes' into testing

17 months agoMerge remote-tracking branch 'kubanrob/ukboot-dep' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:26 +0000 (17:39 +0200)]
Merge remote-tracking branch 'kubanrob/ukboot-dep' into testing

17 months agoMerge remote-tracking branch 'kubanrob/someconfig_targets' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:24 +0000 (17:39 +0200)]
Merge remote-tracking branch 'kubanrob/someconfig_targets' into testing

17 months agoMerge remote-tracking branch 'kubanrob/the-chosen-node' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:22 +0000 (17:39 +0200)]
Merge remote-tracking branch 'kubanrob/the-chosen-node' into testing

17 months agoMerge remote-tracking branch 'kubanrob/fix-tlb-aarch64' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:20 +0000 (17:39 +0200)]
Merge remote-tracking branch 'kubanrob/fix-tlb-aarch64' into testing

17 months agoMerge remote-tracking branch 'mogasergiu/smoga/fstab_initrd_fix' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:18 +0000 (17:39 +0200)]
Merge remote-tracking branch 'mogasergiu/smoga/fstab_initrd_fix' into testing

17 months agoMerge remote-tracking branch 'craciunoiuc/craciunoiuc/pr-label-action' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:16 +0000 (17:39 +0200)]
Merge remote-tracking branch 'craciunoiuc/craciunoiuc/pr-label-action' into testing

17 months agoMerge remote-tracking branch 'craciunoiuc/craciunoiuc/checkpatch-action' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:14 +0000 (17:39 +0200)]
Merge remote-tracking branch 'craciunoiuc/craciunoiuc/checkpatch-action' into testing

17 months agoMerge remote-tracking branch 'craciunoiuc/craciunoiuc/dependabot-actions' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:12 +0000 (17:39 +0200)]
Merge remote-tracking branch 'craciunoiuc/craciunoiuc/dependabot-actions' into testing

17 months agoMerge remote-tracking branch 'craciunoiuc/craciunoiuc/pr-formatting-checks' into...
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:10 +0000 (17:39 +0200)]
Merge remote-tracking branch 'craciunoiuc/craciunoiuc/pr-formatting-checks' into testing

17 months agoMerge remote-tracking branch 'craciunoiuc/craciunoiuc/add-workflow-linting' into...
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:07 +0000 (17:39 +0200)]
Merge remote-tracking branch 'craciunoiuc/craciunoiuc/add-workflow-linting' into testing

17 months agoMerge remote-tracking branch 'craciunoiuc/craciunoiuc/add-python-linting-for-scripts...
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:05 +0000 (17:39 +0200)]
Merge remote-tracking branch 'craciunoiuc/craciunoiuc/add-python-linting-for-scripts' into testing

17 months agoMerge remote-tracking branch 'craciunoiuc/craciunoiuc/add-shellcheck-for-scripts...
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:03 +0000 (17:39 +0200)]
Merge remote-tracking branch 'craciunoiuc/craciunoiuc/add-shellcheck-for-scripts' into testing

17 months agoMerge remote-tracking branch 'andreittr/ttr/static-inits' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:39:01 +0000 (17:39 +0200)]
Merge remote-tracking branch 'andreittr/ttr/static-inits' into testing

17 months agoMerge remote-tracking branch 'andreittr/ttr/atomic-and' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:38:59 +0000 (17:38 +0200)]
Merge remote-tracking branch 'andreittr/ttr/atomic-and' into testing

17 months agoMerge remote-tracking branch 'mschlumpp/mschlumpp/feature/crashscreen' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:38:57 +0000 (17:38 +0200)]
Merge remote-tracking branch 'mschlumpp/mschlumpp/feature/crashscreen' into testing

17 months agoMerge remote-tracking branch 'kha-dinh/retry-exitbootservice' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:38:55 +0000 (17:38 +0200)]
Merge remote-tracking branch 'kha-dinh/retry-exitbootservice' into testing

17 months agoMerge remote-tracking branch 'CajuM/PR-headers_install' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:38:53 +0000 (17:38 +0200)]
Merge remote-tracking branch 'CajuM/PR-headers_install' into testing

17 months agoMerge remote-tracking branch 'ungps/pci-fixes' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:38:52 +0000 (17:38 +0200)]
Merge remote-tracking branch 'ungps/pci-fixes' into testing

17 months agoMerge remote-tracking branch 'Starnox/file_operations' into testing
Razvan Deaconescu [Wed, 29 Nov 2023 15:38:50 +0000 (17:38 +0200)]
Merge remote-tracking branch 'Starnox/file_operations' into testing

17 months agovfscore: Move fd handling into posix-fdtab
Andrei Tatar [Tue, 21 Nov 2023 20:11:46 +0000 (21:11 +0100)]
vfscore: Move fd handling into posix-fdtab

This change moves the file descriptor table out of vfscore, along with
the fd-specific syscalls close and dup*.
Implementations of vfscore files are also patched to use posix-fdtab.

Checkpatch-Ignore: USE_NEGATIVE_ERRNO
Checkpatch-Ignore: LINE_SPACING
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1168

17 months agolib/posix-fdtab: Add legacy interface for vfscore
Andrei Tatar [Tue, 21 Nov 2023 19:34:43 +0000 (20:34 +0100)]
lib/posix-fdtab: Add legacy interface for vfscore

This change adds support for legacy vfscore files to posix-fdtab,
allowing both new uk_ofiles and vfscore files to be used simultaneously.
This includes legacy as well as type-agnostic ("shim") API additions.

Checkpatch-Ignore: UNNECESSARY_ELSE
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1168

17 months agolib/posix-fdtab: Introduce fdtab library
Andrei Tatar [Tue, 21 Nov 2023 19:22:23 +0000 (20:22 +0100)]
lib/posix-fdtab: Introduce fdtab library

This change introduces the posix-fdtab library, tasked with managing the
file descriptor table, mapping integers to open file descriptions.
posix-fdtab exposes functionality through Unikraft-internal APIs and is
independent from the file descriptor table implementation in vfscore,
which it aims to replace.

Checkpatch-Ignore: VOLATILE
Checkpatch-Ignore: LINE_SPACING
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1168

17 months agolib/ukfile: Introduce the ukfile library
Andrei Tatar [Mon, 20 Nov 2023 15:20:25 +0000 (16:20 +0100)]
lib/ukfile: Introduce the ukfile library

This change introduces the ukfile library to provide a new fundamental
abstraction for "files" in Unikraft. This forms the base for a larger
rearchitecting of vfscore.

Checkpatch-Ignore: ENOSYS
Checkpatch-Ignore: VOLATILE
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1165

17 months agolib/posix-timerfd: Add syscall interface 1179/head
Andrei Tatar [Fri, 24 Nov 2023 15:46:14 +0000 (16:46 +0100)]
lib/posix-timerfd: Add syscall interface

This change implements the syscall interface to posix-timerfd, adding
the following syscalls to Unikraft:
- timerfd_create
- timerfd_settime
- timerfd_gettime

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
17 months agolib/posix-timerfd: Introduce posix-timerfd library
Andrei Tatar [Fri, 24 Nov 2023 15:44:20 +0000 (16:44 +0100)]
lib/posix-timerfd: Introduce posix-timerfd library

This change introduces posix-timerfd, a library providing timerfd files.
Initial implementation consists of Unikraft-internal API.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
17 months agoinclude/arch: Add atomic fetch & AND operation
Andrei Tatar [Mon, 2 Oct 2023 18:58:34 +0000 (20:58 +0200)]
include/arch: Add atomic fetch & AND operation

This change adds a Unikraft macro for an architecture's atomic fetch &
AND operation, similar to the fetch & OR we already have.
It also fixes the order of the fetch & OR operations to be truthful to
the docstring.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1125

17 months agolib/uklock: Add static initializer for uk_rwlock
Andrei Tatar [Mon, 2 Oct 2023 19:07:40 +0000 (21:07 +0200)]
lib/uklock: Add static initializer for uk_rwlock

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1126

17 months agolib/uksched: Export static wait queue initializer
Andrei Tatar [Mon, 2 Oct 2023 19:04:47 +0000 (21:04 +0200)]
lib/uksched: Export static wait queue initializer

This change adds the convenience macro `UK_WAIT_QUEUE_INITIALIZER` to
the public API of uksched, enabling external code to use initializers
for embedded wait queues.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1126

17 months agoinclude/: Add static initializer for refcounts
Andrei Tatar [Mon, 2 Oct 2023 19:02:41 +0000 (21:02 +0200)]
include/: Add static initializer for refcounts

Checkpatch-Ignore: SPACING
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1126

17 months agoinclude: Add strong/weak reference counting
Andrei Tatar [Thu, 16 Nov 2023 18:04:30 +0000 (19:04 +0100)]
include: Add strong/weak reference counting

This change adds a utility header implementing a reference counting
scheme that supports regular (strong) as well as weak references.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1160

17 months agolib/ukcpio: Optimize path handling
Andrei Tatar [Wed, 16 Aug 2023 22:45:39 +0000 (00:45 +0200)]
lib/ukcpio: Optimize path handling

This change removes redundant string copies of the destination
extraction path, dropping about half of the total string copy ops.
In addition, some minor code style changes included.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1181

17 months agolib/ukcpio: Refactor CPIO extraction
Andrei Tatar [Wed, 16 Aug 2023 22:00:31 +0000 (00:00 +0200)]
lib/ukcpio: Refactor CPIO extraction

This change reorganizes the CPIO extraction code, making the parsing of
header fields more explicit, as well as splitting functionality into
dedicated handling functions.

Checkpatch-Ignore: CODE_INDENT
Checkpatch-Ignore: LEADING_SPACE
Checkpatch-Ignore: LINE_SPACING
Checkpatch-Ignore: UNNECESSARY_ELSE
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1181

17 months agolib/ukcpio: Clean up & organize code
Andrei Tatar [Wed, 16 Aug 2023 17:58:24 +0000 (19:58 +0200)]
lib/ukcpio: Clean up & organize code

This change is a minor code cleanup with no significant logic changes,
in preparation for a larger refactoring; it includes:
- improved macros with more logical ordering
- code deduplication
- cleaner structured `read_section` function

Checkpatch-Ignore: COMPLEX_MACRO
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1181

17 months agolib/uktimeconv: Add conversion functions
Andrei Tatar [Thu, 16 Nov 2023 18:22:22 +0000 (19:22 +0100)]
lib/uktimeconv: Add conversion functions

This change adds a header with utility functions related to various time
formats defined by standard C or POSIX.
This header depends on time headers provided by (no)libc.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1162

17 months agolib/nolibc: Import sys/timerfd.h header from musl
Andrei Tatar [Fri, 24 Nov 2023 15:42:43 +0000 (16:42 +0100)]
lib/nolibc: Import sys/timerfd.h header from musl

This change imports the sys/timerfd.h header from musl 1.2.4, needed for
type definitions required to implement timerfd files.

Checkpatch-Ignore: FUNCTION_ARGUMENTS
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
17 months agolib/uklock: Add static initializer for uk_rwlock 1126/head
Andrei Tatar [Mon, 2 Oct 2023 19:07:40 +0000 (21:07 +0200)]
lib/uklock: Add static initializer for uk_rwlock

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
17 months agolib/uksched: Export static wait queue initializer
Andrei Tatar [Mon, 2 Oct 2023 19:04:47 +0000 (21:04 +0200)]
lib/uksched: Export static wait queue initializer

This change adds the convenience macro `UK_WAIT_QUEUE_INITIALIZER` to
the public API of uksched, enabling external code to use initializers
for embedded wait queues.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
17 months agoinclude/: Add static initializer for refcounts
Andrei Tatar [Mon, 2 Oct 2023 19:02:41 +0000 (21:02 +0200)]
include/: Add static initializer for refcounts

Checkpatch-Ignore: SPACING
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
17 months agolib/nolibc,lib/isrlib: Fix strncpy
Christiano Haesbaert [Wed, 5 Jul 2023 13:00:11 +0000 (15:00 +0200)]
lib/nolibc,lib/isrlib: Fix strncpy

strncpy will produce different results for an empty string depending on the
preceding value of dst:

char buf[4];

bzero(buf, sizeof(buf));
buf[0] = 0;
buf[1] = 9;
strncpy(&buf[1], "", 3);

"clen" will be 0 since strnlen("") is 0, which will then look into dst[-1]
(buf[0]) to decide if it terminates dst or not.

Instead of working around, replace strncpy for a conformant version, taken
from OpenBSD libkern, as a bonus we zero out the remaining buffer.

https://github.com/openbsd/src/blob/master/sys/lib/libkern/strncpy.c

Signed-off-by: Christiano Haesbaert <haesbaert@haesbaert.org>
Reviewed-by: Eduard-Florin Mihailescu <mihailescu.eduard@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #973

17 months agoinclude/arch: Make time constants signed
Andrei Tatar [Tue, 7 Nov 2023 13:59:41 +0000 (14:59 +0100)]
include/arch: Make time constants signed

This change removes the unsigned marker on integer literals that define
time-related constants, as there is no logical reason for time to always
be positive. This also alleviates mixed-signedness warnings when doing
arithmetic on time values, as well as assigning to __snsec.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1157

17 months agoinclude/arch: Add raw compare-exchange operation
Andrei Tatar [Tue, 7 Nov 2023 13:53:45 +0000 (14:53 +0100)]
include/arch: Add raw compare-exchange operation

This change adds a Unikraft macro for the raw compare-exchange
operation, which in contrast to the existing macro may modify its
arguments.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1156

17 months agolib/vfscore: Fix crash in fstatat on NULL args
Andrei Tatar [Tue, 7 Nov 2023 14:12:30 +0000 (15:12 +0100)]
lib/vfscore: Fix crash in fstatat on NULL args

This change makes fstatat gracefully handle NULL arguments by returning
-EFAULT, preventing a hard crash.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1155

17 months agolib/posix-time: Allow NULL arg in clock_getres
Andrei Tatar [Tue, 7 Nov 2023 14:06:48 +0000 (15:06 +0100)]
lib/posix-time: Allow NULL arg in clock_getres

This change fixes the behavior of clock_getres to not return an error
when receiving a NULL as its output argument, in accordance with docs.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1154

17 months agolib/posix-sysinfo: Add code comments
Stefan Jumarea [Mon, 27 Nov 2023 13:46:11 +0000 (15:46 +0200)]
lib/posix-sysinfo: Add code comments

Add doxygen-style code comments to the `posix-sysinfo` internal library
files.

Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
17 months agolib/posix-sysinfo: Add README.md file
Stefan Jumarea [Mon, 27 Nov 2023 13:45:13 +0000 (15:45 +0200)]
lib/posix-sysinfo: Add README.md file

Add a minimal README that includes basic information abot the library,
as well as a simple application example.

Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
17 months agoplat/kvm/arm: Switch to auxiliary stack on syscall entry
Sergiu Moga [Wed, 1 Nov 2023 11:02:47 +0000 (13:02 +0200)]
plat/kvm/arm: Switch to auxiliary stack on syscall entry

We would usually use the trap stack to execute the issued
system call. However this may be troublesome if the syscall will
generate page faults for example, which would end up reusing the
same stack.

To fix this, switch to the per-thread auxiliary stack on system call
entry and use that instead. The switch shall be done with the help of
the `tpidr_el1` register to help us, as it will be guaranteed to contain
`struct lcpu` that has an up to date pointer to the current thread's
auxiliary stack.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common/x86: Save `ss`/`rsp`/`eflags`/`cs`/`rip` on syscall frame
Sergiu Moga [Sat, 4 Nov 2023 14:54:34 +0000 (16:54 +0200)]
plat/common/x86: Save `ss`/`rsp`/`eflags`/`cs`/`rip` on syscall frame

Previously, we would save zeroes on the syscall entry frame instead
of using the actual values for the registers that would normally be
popped off the stack since they would not be used anyway by a syscall.

For completeness's sake, do still save them, to offer those that may
view the structure a clear view of what the syscall will return to.

Furthermore, we no longer need to clear the stack before syscall exit
(the previous `addq $(6 * 8), %rsp`) because the auxiliary stack is
used instead, so do not do this operation anymore.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common/x86: Switch to auxiliary stack on syscall entry
Sergiu Moga [Wed, 1 Nov 2023 11:02:47 +0000 (13:02 +0200)]
plat/common/x86: Switch to auxiliary stack on syscall entry

We would usually use the application's stack to execute the issued
system call. However this present a couple of problems such as
if the application's stacks are too small (like it is the case
for Go's goroutines) this will end up generating an unhandled
pagefault or, even worse, corrupting other memory areas beyond
the respective stack. Another problem would be that we will
end up overwriting stuff on the Red Zone for those applications
that employ it.

To fix this, switch to the per-thread auxiliary stack on system call
entry and use that instead. The switch shall be done with the help of
the `swapgs` instruction to help us swap the `gs_base` registers, as
our own `KERNEL_GS_BASE` contains a pointer to the current LCPU's
`struct lcpu` that has an up to date pointer to the current thread's
auxiliary stack.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agolib/posix-user: Add comments for posix-user
Delia Pavel [Mon, 20 Nov 2023 20:27:40 +0000 (22:27 +0200)]
lib/posix-user: Add comments for posix-user

Signed-off-by: Delia-Maria Pavel <delia_maria.pavel@stud.acs.upb.ro>
17 months agolib/posix-user: Add README.md file for posix-user
Delia Pavel [Sun, 26 Nov 2023 11:20:33 +0000 (13:20 +0200)]
lib/posix-user: Add README.md file for posix-user

Signed-off-by: Delia-Maria Pavel <delia_maria.pavel@stud.acs.upb.ro>
17 months agoAdd README for posix-time library
Radu Nichita [Sat, 25 Nov 2023 13:12:15 +0000 (15:12 +0200)]
Add README for posix-time library

17 months agoplat/common/x86: Use `uk/asm.h` defined `ENTRY` for syscall entry
Sergiu Moga [Sat, 4 Nov 2023 14:04:42 +0000 (16:04 +0200)]
plat/common/x86: Use `uk/asm.h` defined `ENTRY` for syscall entry

Deprecate locally defined `ENTRY` macro in favor of the more generally
available, equivalent macro defined in `uk/asm.h`.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agolib/uksched: Update `auxsp` of current LCPU when switching stacks
Sergiu Moga [Wed, 1 Nov 2023 07:02:25 +0000 (09:02 +0200)]
lib/uksched: Update `auxsp` of current LCPU when switching stacks

If uksched/ukthread is enabled, make sure that the current LCPU's
auxiliary stack pointer is updated to always point to the currently
executing thread's auxiliary stack pointer by setting it to that
of the thread it is about to switch to during context switching.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agolib/uksched: Set bootstrap lcpu's `auxsp` during `uk_sched_start`
Sergiu Moga [Wed, 1 Nov 2023 06:57:34 +0000 (08:57 +0200)]
lib/uksched: Set bootstrap lcpu's `auxsp` during `uk_sched_start`

Make sure to fill in the value of current lcpu's (bootstrap lcpu in
our case) auxiliary stack pointer with that of the current thread's
(main thread) when initializing scheduling.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common/x86: Add `auxsp` getter/setter for `struct lcpu`
Sergiu Moga [Wed, 1 Nov 2023 06:53:56 +0000 (08:53 +0200)]
plat/common/x86: Add `auxsp` getter/setter for `struct lcpu`

Implement basic getter/setter methods for the `auxsp` field that
exists in `struct lcpu`.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common/arm: Add `auxsp` getter/setter for `struct lcpu`
Sergiu Moga [Wed, 1 Nov 2023 06:53:56 +0000 (08:53 +0200)]
plat/common/arm: Add `auxsp` getter/setter for `struct lcpu`

Implement basic getter/setter methods for the `auxsp` field that
exists in `struct lcpu`.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agolib/ukboot: Allocate bootstrap LCPU auxiliary stack
Sergiu Moga [Thu, 9 Nov 2023 19:16:03 +0000 (21:16 +0200)]
lib/ukboot: Allocate bootstrap LCPU auxiliary stack

If shcheduling/multithreading is not enabled, allocate an auxiliary
stack for bootstrap LCPU. Otherwise, the LCPU will have the same
auxiliary stack as the thread that runs on it and this allocation is
not needed.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agolib/uksched: Introduce the per-thread auxiliary stack
Sergiu Moga [Tue, 31 Oct 2023 16:49:00 +0000 (18:49 +0200)]
lib/uksched: Introduce the per-thread auxiliary stack

Add a new field to `struct uk_thread` that can represent a secondary
stack that can be used as a backup stack.

This can become very useful in cases such as when wanting to defer
exception handling without creating another thread. For example,
we want to return from an exception into a function inside the
same thread to be able to do deferred I/O outside exception
context without contaminating the original stack that was present
before the trap. We can avoid polluting the original stack by using
this auxiliary stack instead.

Update each thread creation/deletion method's signature and
implementation accordingly.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common: Add `auxsp` field to `struct lcpu`
Sergiu Moga [Wed, 1 Nov 2023 06:44:07 +0000 (08:44 +0200)]
plat/common: Add `auxsp` field to `struct lcpu`

`struct uk_thread` contains a field called `auxsp` which is meant to
represent an auxiliary stack that may be used when switching stacks
during syscall entries or when simply wanting to have a scratch space
to use during a very fragile state of the system, such as when handling
an exception.

Give access to this field through `struct lcpu` as well. This field
shall represent the auxiliary stack pointer of the thread currently
executing on this LCPU.

If uksched/ukthread is disabled, this can come in handy as simply a
pointer to a scratch space that we can contaminate with whatever we
may want during a more fragile execution context.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat: Implement a method for allocating the auxiliary stack
Sergiu Moga [Thu, 9 Nov 2023 19:14:19 +0000 (21:14 +0200)]
plat: Implement a method for allocating the auxiliary stack

Add a method that transparently allocates and returns an auxiliary
stack according to CONFIG_UKPLAT_AUXSP_SIZE.

Note that if `libukvmem` is enabled, this stack shall be premapped
as we do not want accesses to this to generate page faults.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoarch/arm64: Implement stack switching on IRQ/trap
Sergiu Moga [Thu, 23 Nov 2023 14:00:34 +0000 (16:00 +0200)]
arch/arm64: Implement stack switching on IRQ/trap

Define a per-cpu buffer whose size is twice that of the configured
stacks and whose definition may be represented through the following
diagram:
```
      STACK_SIZE               STACK_SIZE
 <---------------------><--------------------->
 |============================================|
 |                     |                      |
 |       trap stack    |        IRQ stack     |
 |                     |                      |
 |=============================================
                       ^
                     SP_EL0
```

The middle address of this buffer shall be assigned to `SP_EL0`,
a great candidate for a register free of use as a `EL1` only Unikernel.

Now, depending on whether an exception is an IRQ or a trap, the early
assembly entry will switch to either the IRQ stack or the trap stack,
by simply making use of the `SP_EL0` system register.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/kvm/arm: Obsolete `EL0` logic from trap/IRQ handling
Sergiu Moga [Thu, 23 Nov 2023 13:26:54 +0000 (15:26 +0200)]
plat/kvm/arm: Obsolete `EL0` logic from trap/IRQ handling

Although the Vector table has `EL0` exceptions related entries,
we never execute from `EL0` and they will never happen.

Furthermore, `SP_EL0` is a perfect candidate for an emergency
scratch register in an `EL1` only OS like us.

Thus, remove all of the `EL0` logic, while maintaining the same
alignments and semantics.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common: Move LCPU `id`/`current`/`idx` methods to arch files
Sergiu Moga [Thu, 23 Nov 2023 13:11:41 +0000 (15:11 +0200)]
plat/common: Move LCPU `id`/`current`/`idx` methods to arch files

Now that we have a per-cpu system register that holds the current
pointer to the `struct lcpu` element of the global `lcpus` array,
make use of that for each architecture independently and move
the implementations of `ukplat_lcpu_[id|current|idx]` from the
architecture agnostic place to the more architecture specific ones.
Notice that a default definition resorting to the value `0` is still
kept for platforms that do not have SMP and do not have a LCPU API
integrated.

Furthermore, obsolete `CONFIG_UKPLAT_LCPU_IDISIDX` since we can now
directly fetch `idx` from `struct lcpu` pointer stored in the
corresponding system register.

NOTE: `lcpu_get_current` of `x86` still makes use of the now
optimized through `%gs` register by calling `ukplat_lcpu_idx`
which calls `ukplat_lcpu_id`. However, in the future, it
will be better if we make use of the `rdgsbase` instruction
and the like.

Co-authored-by: Michalis Pappas <michalis@unikraft.io>
Co-authored-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agolib/devfs: Remove dependency on `LIBVFSCORE_AUTOMOUNT_ROOTFS`
Sergiu Moga [Mon, 23 Oct 2023 16:19:05 +0000 (19:19 +0300)]
lib/devfs: Remove dependency on `LIBVFSCORE_AUTOMOUNT_ROOTFS`

Now that we have `fstab`, we no longer depend on something mounting
a rootfs being preconfigured within the kernel. A user may simply
choose to specify rootfs through the `vfs.fstab` command-line
argument.

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

17 months agoplat/common/arm: Init `TPIDR_EL1` in `lcpu_arch_init`
Sergiu Moga [Thu, 23 Nov 2023 12:55:19 +0000 (14:55 +0200)]
plat/common/arm: Init `TPIDR_EL1` in `lcpu_arch_init`

Every LCPU shall have their `TPIDR_EL1` system register assigned
the value of the address of their own `struct lcpu` element in the
global `lcpus` array.

Co-authored-by: Michalis Pappas <michalis@unikraft.io>
Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common/x86: Init `GS_BASE`/`KERNEL_GS_BASE` in `lcpu_arch_init`
Sergiu Moga [Thu, 23 Nov 2023 12:52:10 +0000 (14:52 +0200)]
plat/common/x86: Init `GS_BASE`/`KERNEL_GS_BASE` in `lcpu_arch_init`

Every LCPU shall have their `GS_BASE` and `KERNEL_GS_BASE` registers
assigned to their own `struct lcpu` element of the `lcpus` array.

Co-authored-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common: Declare `lcpus` array through `UKPLAT_PER_LCPU_DEFINE`
Sergiu Moga [Thu, 23 Nov 2023 12:50:16 +0000 (14:50 +0200)]
plat/common: Declare `lcpus` array through `UKPLAT_PER_LCPU_DEFINE`

Align the `lcpus` array with other per-cpu variables by defining
it through the `UKPLAT_PER_LCPU_DEFINE` macro.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common/x86: Add `gs_base`/`k_gs_base` MSR's read/write methods
Sergiu Moga [Thu, 23 Nov 2023 12:41:28 +0000 (14:41 +0200)]
plat/common/x86: Add `gs_base`/`k_gs_base` MSR's read/write methods

Implement basic methods to be able to read/write from/to the
GS_BASE and KERNEL_GS_BASE MSR's, as well as from an offset relative
to the former's value.

Co-authored-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common/x86: Add macro-definition for `X86_MSR_KERNEL_GS_BASE`
Sergiu Moga [Wed, 1 Nov 2023 06:32:07 +0000 (08:32 +0200)]
plat/common/x86: Add macro-definition for `X86_MSR_KERNEL_GS_BASE`

Add a macro-definition for the x86 `KERNEL_GS_BASE` MSR that is usually
used in conjunction with the `swapgs` instruction for an efficient swap
between the `gs_base` register placed in `KERNEL_GS_BASE` and `GS_BASE`.

Co-authored-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoplat/common/x86: Add macro-definition for `X86_MSR_GS_BASE`
Sergiu Moga [Wed, 1 Nov 2023 06:30:24 +0000 (08:30 +0200)]
plat/common/x86: Add macro-definition for `X86_MSR_GS_BASE`

Add a macro-definition for the `MSR_GS_BASE` MSR to access the
`gs_base` register in 64-bit mode.

Co-authored-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoPR #1173
Sergiu Moga [Sat, 4 Nov 2023 08:54:06 +0000 (10:54 +0200)]
PR #1173

17 months agolib/syscall_shim: Fix `arch_prctl`'s `ARCH_SET_FS` handling
Sergiu Moga [Sat, 4 Nov 2023 08:54:06 +0000 (10:54 +0200)]
lib/syscall_shim: Fix `arch_prctl`'s `ARCH_SET_FS` handling

NOTE: This is interdependent on the `app-elfloader` commit that
changes `arch_prctl`'s `ARCH_SET_FS` behavior, entitled:
```
Do not change real `fs_base` register in `arch_prctl`
```

The code may store and restore userland TLS pointer properly in the
system call handler and it does check if it was changes by syscalls
such as `arch_prctl`'s `ARCH_SET_FS` command. However, one aspect
was missed: `__UK_SYSCALL_RETADDR_CLEAR`. The macro
`__UK_SYSCALL_RETADDR_CLEAR` accesses what is meant to be Unikraft's
TLS and is invoked in the time window between TLS store and restore.
In the `ARCH_SET_FS` case, `arch_prctl` sets the the `fs` register
regardless and thus we end up having the userland desired TLS pointer
during a time window where keeping our own TLS pointer is mandatory.

Thus, to avoid this, do not set any `fs` register value during
`arch_prctl` (see top NOTE) and, instead, simply modify the
`_uk_syscall_ultlsp` value which will be used instead to restore
the userland TLS as the last operation.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
17 months agoMerge branch 'unikraft:staging' into misaligned-section-xen
andreistan26 [Thu, 23 Nov 2023 08:38:16 +0000 (10:38 +0200)]
Merge branch 'unikraft:staging' into misaligned-section-xen

17 months agobuild: Introduce `UK_IMAGE_NAME_OVERWRITE` make var
Alexander Jung [Wed, 22 Nov 2023 13:46:33 +0000 (14:46 +0100)]
build: Introduce `UK_IMAGE_NAME_OVERWRITE` make var

This commit introduces a new make variable,
`UK_IMAGE_NAME_OVERWRITE`, which is used to customize the
output binary name of the kernel image.  This is a special,
and experimental, variable which can be helpful in certain
use cases, for example where targets with the same architecture
and platform are present.  This variable should be used in
conjunction with a different build directory, `O=`, as the
resulting binary will always have the name from this option.

Signed-off-by: Alexander Jung <alex@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1169

17 months agolib/uknetdev: Add ipv4_dns0_addr configuration
Marco Schlumpp [Mon, 27 Feb 2023 14:15:58 +0000 (15:15 +0100)]
lib/uknetdev: Add ipv4_dns0_addr configuration

Previously, we were only able to statically configure the ip address,
netmask, and gateway, but not the DNS server. This commit adds the
configuration option for a DNS server.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1167

17 months agoplat/xen/x86_64: Add missing segment alignement for `xen`
Andrei Stan [Mon, 20 Nov 2023 21:32:57 +0000 (23:32 +0200)]
plat/xen/x86_64: Add missing segment alignement for `xen`

Make the second segment in a `xen/x86-64` ELF aligned to the page size.
This fixes a memory overlap issue that triggers an assert during
memory coalescing.

Signed-off-by: Andrei Stan <andreistan2003@gmail.com>
17 months agolib/ukrust: Fix compilation fialure when enable libukrust
cocodery [Mon, 20 Nov 2023 04:33:41 +0000 (12:33 +0800)]
lib/ukrust: Fix compilation fialure when enable libukrust

This commit aims to fix issue#1147 which compile apps with enabled
libukrust

1. ukrust/Makefile.uk: fix command line argument with high-version
   bindgen, from 'size_t-is-usize' to 'no-size_t-is-usize'.
2. ukrust/src/allocator.rs: fix previous defined symbol by comment
   them, becasue rustc will help to resolve, and add new symbol
'__rust_no_alloc_shim_is_unstable' for locate.

Signed-off-by: Chris Wu <cocodery@outlook.com>
17 months agobuild: guarantee files generated by awk-file before others rely on them
cocodery [Fri, 17 Nov 2023 16:17:03 +0000 (00:17 +0800)]
build: guarantee files generated by awk-file before others rely on them

Fix sub-problem of issue#1147 when enable libukrust, which will throw an error that
`fatal error: 'uk/bits/libid.h' file not found` because of wrong commands order.
this header file is needed by `bindings_helper.h` but command generates
'uk/bits/libid/h' is ahead from the bindgen command.

Signed-off-by: Chris Wu <cocodery@outlook.com>
17 months agolib/posix-process: Use builtin `exit` flags only for C and CXX sources
Eduard Vintilă [Sun, 12 Nov 2023 13:59:20 +0000 (15:59 +0200)]
lib/posix-process: Use builtin `exit` flags only for C and CXX sources

The `-fno-builtin-exit` and `-fno-builtin-exit-group` flags are not
available for Golang sources, so keep them only for C and C++.

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
17 months agoplat/common/arm: Zero out `x29` and `x30` before stack switch
Eduard Vintilă [Sun, 12 Nov 2023 13:54:34 +0000 (15:54 +0200)]
plat/common/arm: Zero out `x29` and `x30` before stack switch

In order to properly mark the end of a stacktrace and avoid
undefined behaviour during unwinding, both the frame pointer
(`x29`) and the link register (`x30`) should be
zeroed out before switching to a new stack.

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
18 months agoinclude/arch: Add atomic fetch & AND operation 1125/head
Andrei Tatar [Mon, 2 Oct 2023 18:58:34 +0000 (20:58 +0200)]
include/arch: Add atomic fetch & AND operation

This change adds a Unikraft macro for an architecture's atomic fetch &
AND operation, similar to the fetch & OR we already have.
It also fixes the order of the fetch & OR operations to be truthful to
the docstring.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
18 months ago.github/workflows: Add shellcheck for scripts 1133/head
Cezar Craciunoiu [Sat, 14 Oct 2023 08:09:35 +0000 (11:09 +0300)]
.github/workflows: Add shellcheck for scripts

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
18 months ago.github/workflows: Add python checks for support scripts 1134/head
Cezar Craciunoiu [Sat, 14 Oct 2023 09:02:59 +0000 (12:02 +0300)]
.github/workflows: Add python checks for support scripts

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
18 months ago.github/workflows: Add github workflows checks 1137/head
Cezar Craciunoiu [Sat, 14 Oct 2023 09:22:13 +0000 (12:22 +0300)]
.github/workflows: Add github workflows checks

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
18 months ago.github/workflows: Add commit and PR format checks 1139/head
Cezar Craciunoiu [Mon, 16 Oct 2023 12:50:53 +0000 (15:50 +0300)]
.github/workflows: Add commit and PR format checks

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
18 months ago.github: Enable dependabot for action bumping 1140/head
Cezar Craciunoiu [Mon, 16 Oct 2023 13:20:26 +0000 (16:20 +0300)]
.github: Enable dependabot for action bumping

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
18 months agoplat/common: Add commit to destroy checkpatch
Cezar Craciunoiu [Mon, 16 Oct 2023 14:32:54 +0000 (17:32 +0300)]
plat/common: Add commit to destroy checkpatch

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
18 months ago.github/workflows: Add checkpatch checks for commits
Cezar Craciunoiu [Mon, 16 Oct 2023 14:06:17 +0000 (17:06 +0300)]
.github/workflows: Add checkpatch checks for commits

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
18 months ago.github/workflows: Add PR auto-labelling
Cezar Craciunoiu [Mon, 16 Oct 2023 14:23:30 +0000 (17:23 +0300)]
.github/workflows: Add PR auto-labelling

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
18 months ago.github/labels: Add labels list for syncing
Cezar Craciunoiu [Mon, 16 Oct 2023 14:24:51 +0000 (17:24 +0300)]
.github/labels: Add labels list for syncing

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>