]> xenbits.xensource.com Git - unikraft/unikraft.git/log
unikraft/unikraft.git
5 months ago.github/workflows: Wait once before checking 1547/head
Cezar Craciunoiu [Wed, 13 Nov 2024 15:12:17 +0000 (17:12 +0200)]
.github/workflows: Wait once before checking

Because there is no pause between steps, the start-stop
interval is usually 1s or less. This does not allow for
the jobs to even enter pending state.

This introduces another sleep before doing anything to
ensure that the interval is big enough.

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

6 months agolib/vfscore: Change faccessat with AT_SYMLINK_NOFOLLOW
Robert Zamfir [Mon, 14 Oct 2024 18:51:25 +0000 (21:51 +0300)]
lib/vfscore: Change faccessat with AT_SYMLINK_NOFOLLOW

* Change faccessat with AT_SYMLINK_NOFOLLOW
* Move the path creation and logic before the AT_SYMLINK_NOFOLLOW
* Apply AT_SYMLINK_NOFOLLOW only if the file is an actual symlink
* I didn't implement the `don't follow link logic`

Checkpatch-Ignore: LONG_LINE_STRING
Checkpatch-Ignore: STRLCPY
Signed-off-by: Robert Zamfir <georobi.016@gmail.com>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Andrei Tatar <andrei@unikraft.io>
GitHub-Closes: #1462

6 months agoinclude/uk/arch: Define bool types for C++ compilers
Stefan Jumarea [Mon, 23 Sep 2024 12:14:27 +0000 (15:14 +0300)]
include/uk/arch: Define bool types for C++ compilers

If compiling using a C++ compiler, `_Bool` is undefined, as it is a C
built-in type and C++ compilers do not recognize it. Define `__bool`,
`__true` and `__false` for C++ compiler as `bool`, `true` and `false`.

Checkpatch-Ignore: REPEATED_WORD
Github-Fixes: #1513
Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1500

6 months agobuild: use different progress flags based on the wget version
Thassilo Schulze [Mon, 3 Jun 2024 09:16:29 +0000 (11:16 +0200)]
build: use different progress flags based on the wget version

The Unikraft build system uses the `--show-progress` flag for
Wget1. This flag has been renamed to `--force-progress` in Wget2.
That's why we need to check the version of Wget before using either
one of the flags. There's a list of CLI changes from Wget1 to Wget2
here:

https://gitlab.com/gnuwget/wget2/-/wikis/Home

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1442

6 months agoplat/xen: Include fp_arm64.c in FPSIMD Xen ARM64 builds
Razvan Deaconescu [Wed, 9 Oct 2024 22:15:18 +0000 (01:15 +0300)]
plat/xen: Include fp_arm64.c in FPSIMD Xen ARM64 builds

`fp_arm64.c` implements `fpsimd_save_state()` and
`fpsimd_restore_state()` that are required by FPSIMD ARM64 builds. The
file was not included in the build rules (in `Makefile.uk`) resulting in
a build error.

Fix the build error by including `fp_arm64.c` in the Xen build rules.
This is similar to its inclusion in the KVM build rules.

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

6 months agoplat/common/x86: Use `X86_VIDEO_MEM_START` for SIPI vector allocation
Sergiu Moga [Fri, 7 Jun 2024 15:28:58 +0000 (18:28 +0300)]
plat/common/x86: Use `X86_VIDEO_MEM_START` for SIPI vector allocation

Commit a001e41f607c ("plat/common/x86: Increase legacy high regions granularity")
changed the definitions of some x86 memregion related macro-definitions.
By mistake it forgot to adapt the `ukplat_memregion_alloc_sipi_vect`
function which was using one them. This was not caught at the time as it
required one to have SMP enabled in order to get the build error.

Checkpatch-Ignore: COMMIT_LOG_LONG_LINE
Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Mihnea Firoiu <mihneafiroiu0@gmail.com>
Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1457

6 months agolib/nolibc: Compile string.c with -O3
Andrei Tatar [Wed, 5 Jun 2024 15:30:09 +0000 (17:30 +0200)]
lib/nolibc: Compile string.c with -O3

This change makes nolibc's string.c compile with -O3 optimizations when
optimizing for performance. This gives compilers more freedom to better
optimize the often-used mem* and str* functions.

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

6 months agoplat/kvm: Enable VGA by default on QEMU x86_64
Michalis Pappas [Mon, 16 Sep 2024 11:53:44 +0000 (13:53 +0200)]
plat/kvm: Enable VGA by default on QEMU x86_64

Enable VGA by default on QEMU x86_64. This was removed during the
migration of VGA to drivers.

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

6 months agolib/posix-process: Use posix-fdtab for prlimit
Andrei Tatar [Wed, 5 Jun 2024 18:45:55 +0000 (20:45 +0200)]
lib/posix-process: Use posix-fdtab for prlimit

This change makes the prlimit syscall report the maximum file descriptor
using Kconfig options of posix-fdtab, instead of the vfscore hardcoded
default, thus correctly reporting the fdtab size.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1455

6 months agolib/posix-sysinfo: Use posix-fdtab for SC_OPEN_MAX
Andrei Tatar [Wed, 5 Jun 2024 18:37:00 +0000 (20:37 +0200)]
lib/posix-sysinfo: Use posix-fdtab for SC_OPEN_MAX

This change makes `sysinfo` take the size of the fdtab from Kconfig
options of posix-fdtab instead of a macro defined by vfscore.
This correctly reports the size of the file descriptor table, instead of
the vfscore hardcoded default.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1455

6 months agoplat/xen: Fix Arm setup to work with new Xen console
Thassilo Schulze [Mon, 16 Sep 2024 15:10:34 +0000 (17:10 +0200)]
plat/xen: Fix Arm setup to work with new Xen console

This fixes a regression introduced in the `ukconsole`
changes. The recent updates to the Xen console drivers
removed the `prepare_console()` and `init_console()`
functions in favor of calling the same code through
the early init tab.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1490

6 months agolib/ukdebug: Add `README.md` to `ukdebug`
Thassilo Schulze [Sun, 15 Sep 2024 15:35:01 +0000 (17:35 +0200)]
lib/ukdebug: Add `README.md` to `ukdebug`

The primary function of this README is to document how the
GDB stub is used. In future commits, this README could
potentially be extended with extra documentation describing
the other features of `ukdebug`.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
GitHub-Closes: #1492

7 months agoplat/kvm: Remove |isr flag to prevent build error
Razvan Deaconescu [Fri, 20 Sep 2024 20:37:42 +0000 (23:37 +0300)]
plat/kvm: Remove |isr flag to prevent build error

The `plat/common/arm/fp_arm64.c` file uses the `|isr` flag as suffix.
This enables the `-mgeneral-regs-only` flag, as shown in
`arch/arm/arm64/Makefile.uk` file. The `-mgeneral-regs-only` flag
disables the use of specialized registers (such as floating-point
registers), with the aim of not saving them during ISR processing.

However, the `plat/common/arm/fp_arm64.c` file uses floating point. So,
when `-mgeneral-regs-only` is enabled, it causes a build error, as
floating point registers are undefined. For some reason, neither GCC,
not Clang <= 17 don't fail the build. It does happen, however with Clang
>= 18.

Fix the build error by removing the `|isr` flag.

Also make the `fp_arm64.c` build only if both `CONFIG_FPSIMD` and
`CONFIG_ARCH_ARM_64` configuration options are enabled.

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
GitHub-Closes: #1497

7 months agodrivers/ukconsole/ns16550: Fix Kconfig warnings on invalid `choice`
Michalis Pappas [Tue, 24 Sep 2024 15:35:19 +0000 (17:35 +0200)]
drivers/ukconsole/ns16550: Fix Kconfig warnings on invalid `choice`

Fix Kconfig warnings on ns16550 for x86_64 caused by choice groups
defined without an associated symbol:

> warning: choice value used outside its choice group

According to [1]:

"
choices:
"choice" [symbol]
<choice options>
<choice block>
"endchoice"
...

If no [symbol] is associated with a choice, then you can not have multiple
definitions of that choice. If a [symbol] is associated to the choice,
then you may define the same choice (ie. with the same entries) in another
place."

[1] https://android.googlesource.com/kernel/common/+/bcmdhd-3.10/Documentation/kbuild/kconfig-language.txt

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Thassilo Schulze <thassilo@thasso.xyz>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1503

7 months ago.github/workflows: Remove `jq` installation
Alexander Jung [Wed, 7 Aug 2024 07:55:39 +0000 (09:55 +0200)]
.github/workflows: Remove `jq` installation

This is already installed in this context and so this sequence
of updating and installing is not necessary.

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

7 months agoplat/kvm: Fix Kconfig dependency warning on Firecracker
Michalis Pappas [Tue, 24 Sep 2024 15:55:14 +0000 (17:55 +0200)]
plat/kvm: Fix Kconfig dependency warning on Firecracker

Fix dependency warnings about VIRTIO_MMIO on Firecracker when no devices
are selected.

> WARNING: unmet direct dependencies detected for VIRTIO_MMIO_LINUX_COMPAT_CMDLINE
>   Depends on [n]: LIBVIRTIO_MMIO [=n]
>   Selected by [y]:
>   - KVM_VMM_FIRECRACKER [=y] && <choice> && (ARCH_X86_64 [=y] || ARCH_ARM_64 [=n])
>
> WARNING: unmet direct dependencies detected for VIRTIO_MMIO_LINUX_COMPAT_CMDLINE
>   Depends on [n]: LIBVIRTIO_MMIO [=n]
>   Selected by [y]:
>   - KVM_VMM_FIRECRACKER [=y] && <choice> && (ARCH_X86_64 [=y] || ARCH_ARM_64 [=n])

Checkpatch-Ignore: COMMIT_LOG_LONG_LINE
Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Thassilo Schulze <thassilo@thasso.xyz>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1504

7 months agolibuklibparam: Fix symbols not present after linkage
Michalis Pappas [Mon, 23 Sep 2024 10:32:16 +0000 (12:32 +0200)]
libuklibparam: Fix symbols not present after linkage

In certain build (nginx/bincompat) linkage results into libukparam
symbols from individual libraries not making it into the executable
object.

Although the internal behavior of ld is not clear, it looks like the
issue is resolved by updating libuparam.ld.S to collect each library's
section rather than its individual symbols.

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

7 months agolibs/vfscore: Fix dirent64 warning
Razvan Rus [Sat, 30 Mar 2024 15:41:37 +0000 (17:41 +0200)]
libs/vfscore: Fix dirent64 warning

Current Musl-based builds generate warnings related to dirent64 definition.
Define _GNU_SOURCE in all souce files so it prevents the warning from happening.

Signed-off-by: Razvan Rus <razvanrus2003@gmail.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1372

7 months agoplat/kvm/arm64: Do not unmask PSTATE.D on IRQ entry
Michalis Pappas [Fri, 6 Sep 2024 14:29:40 +0000 (16:29 +0200)]
plat/kvm/arm64: Do not unmask PSTATE.D on IRQ entry

Enabling PSTATE.D at IRQ entry results into nested debug exceptions.
This is incorrect as the context restored on IRQ exit invalidates
any changes to the context made by the debug exception's handler.

Also remove the unmasking of PSTATE.F as at the present we don't
deal with FIQs.

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

7 months agoinclude/uk/errptr: Fix NULL being an error pointer
Andrei Tatar [Wed, 5 Jun 2024 14:53:57 +0000 (16:53 +0200)]
include/uk/errptr: Fix NULL being an error pointer

Previously, `PTRISERR` would be true for NULL, breaking the convention
of error pointers that `PTR2ERR` returns a negative error code for
any pointer for which `PTRISERR` is true. This would add a subtle corner
case where errors could be silently ignored.
This change fixes this oversight. Code using `PTRISERR` ambiguously or
to erroneously check for NULL is also fixed.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Maria Pana <maria.pana4@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1453

7 months agodrivers/xen/console: Update nolibc dependency
Razvan Deaconescu [Sun, 15 Sep 2024 06:00:29 +0000 (09:00 +0300)]
drivers/xen/console: Update nolibc dependency

Xen console dependency on nolibc in `Config.uk` (`select LIBNOLIBC`)
causes conflict with the `plat/xen/Config.uk` configuration (`select
LIBNOLIBC if !HAVE_LIBC`) when a libc (such as Musl) is used.

The dependency must consider both using nolibc and using a libc (such as
Musl). Update dependency to select nolibc only when a libc is absent.

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1487

7 months agolib/ukdebug, plat/common: Invalidate i-cache if GDB writes memory
Thassilo Schulze [Fri, 9 Aug 2024 04:10:15 +0000 (06:10 +0200)]
lib/ukdebug, plat/common: Invalidate i-cache if GDB writes memory

On ARM we need to always invalidate the i-cache if the GDB stub
writes somewhere into memory because the stub might change the
executable code.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Disable gdb's ack mode if the stub is connected
Thassilo Schulze [Wed, 5 Jun 2024 15:42:07 +0000 (17:42 +0200)]
lib/ukdebug: Disable gdb's ack mode if the stub is connected

Using acknowledgment packets only makes sense on unreliable connections.
But if the connection is reliable, disabling acknowledgment packets
makes the communication between gdb and the stub much faster.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/*: Turn `\n` into `\r\n`
Thassilo Schulze [Fri, 28 Jun 2024 14:11:06 +0000 (16:11 +0200)]
lib/*: Turn `\n` into `\r\n`

See the TODOs in the diff

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agodrivers/uktty: Remove newline conversion from drivers
Thassilo Schulze [Thu, 27 Jun 2024 11:35:09 +0000 (13:35 +0200)]
drivers/uktty: Remove newline conversion from drivers

Turning a `\n` character into a `\r\n` character sequence
breaks the communication between the gdb stub and the gdb
host. The stub will calculate a checksum on the message
without the extra carriage returns but the host will receive
a message with the extra carriage returns that the drivers
add and thus the host will calculate a different checksum
than the stub.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Add breakpoints to set up and connect to stub
Thassilo Schulze [Tue, 4 Jun 2024 09:25:48 +0000 (11:25 +0200)]
lib/ukdebug: Add breakpoints to set up and connect to stub

If the gdb stub is enabled, it registers a function in the inittab
that tries to connect to the gdb host. This function first checks
if the console with the ID from `debug.gdbcon` is available. If so,
this function executes a breakpoint instruction to enter the gdb
stub. If the console is not available, the breakpoint is skipped.

Checkpatch-Ignore: LONG_LINE_STRING
Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Add virtual kernel console to gdb stub
Thassilo Schulze [Mon, 2 Sep 2024 07:39:20 +0000 (09:39 +0200)]
lib/ukdebug: Add virtual kernel console to gdb stub

The `debug.gdb_kern` parameter is a tristate. It determines
if the gdb stub should send kernel output to the gdb host
over the gdb remote protocol. A negative value means "auto".
In this case, the gdb stub sends kernel output to the gdb
host if the backing console had the `UK_CONSOLE_FLAG_STD[OUT|IN]`
flags set. "auto" is the default. A value of zero means "off";
kernel output is never sent to the gdb host. A positive value
means "on"; kernel output is always sent to the gdb host.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Communicate with gdb host through `ukconsole`
Thassilo Schulze [Wed, 26 Jun 2024 14:04:47 +0000 (16:04 +0200)]
lib/ukdebug: Communicate with gdb host through `ukconsole`

The gdb stub now uses the `ukconsole` interface to talk
to gdb. That's why the stub also depends on `LIBUKCONSOLE`.
Without `ukconsole` providing a serial connection, the
stub is entirely useless.

The gdb stub communicates with the gdb host using one of
the console devices that are registered with `ukconsole`.
The ID of the console device that the stub should use is
specified in the `debug.gdb_cons` parameter. The stub will
clear the `UK_CONSOLE_FLAG_STD[OUT|IN]` flags on that device
and keep a reference to it to communicate with the gdb host.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Add `qAttached` packet to gdb stub
Thassilo Schulze [Tue, 27 Aug 2024 09:39:39 +0000 (11:39 +0200)]
lib/ukdebug: Add `qAttached` packet to gdb stub

This packet is not mandatory but gdb will probe for
it. Now we respond properly to the probing. This
packet must be updated to support the multiprocess
features of the gdb remote protocol.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Add `vCont` packet to gdb stub
Marc Rittinghaus [Mon, 19 Aug 2024 09:44:28 +0000 (11:44 +0200)]
lib/ukdebug: Add `vCont` packet to gdb stub

This packet is used by the gdb host as a replacement for the
`c`, `s`, `C` and `S` packets. `vCont` has some more features
than these packets on their own. These features are related to
multi-threading support for the most part. We don't support
the multi-threading features of the gdb remote protocol, so
the `vCont` packet isn't a real improvement over the `c`,
`s`, `C` and `S` packets. But the gdb host still prefers to
use it.

Co-authored-by: Thassilo Schulze <thassilo@unikraft.io>
Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Add `q` commands to gdb stub for target information
Marc Rittinghaus [Mon, 19 Aug 2024 09:38:23 +0000 (11:38 +0200)]
lib/ukdebug: Add `q` commands to gdb stub for target information

The two `q` commands (`qSupported` and `qXfer:features:read:target.xml`)
allow the gdb host to retrieve information about the target system
that's being debugged.

Checkpatch-Ignore: AVOID_EXTERNS
Checkpatch-Ignore: UNNECESSARY_PARENTHESES
Checkpatch-Ignore: SPDX_LICENSE_TAG
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Add register read and write packets to gdb stub
Marc Rittinghaus [Mon, 19 Aug 2024 09:34:04 +0000 (11:34 +0200)]
lib/ukdebug: Add register read and write packets to gdb stub

These packets allow the gdb host to read and write the registers
on the target system.

Source of import (lib/ukdebug/arch/arm64/target.xml):
Repository: https://gitlab.com/qemu-project/qemu
Tag: v9.1.0  (fd1952d)
Path: gdb-xml/aarch64-core.xml

NOTE: The `target.xml` file from the QEMU source tree does not
strictly adhere to the gdb remote procol docs because it doesn't
include a `target` element. But in practice this element seems
to be optional.

Source of import (lib/ukdebug/arch/x86_64/target.xml):
Repository: https://gitlab.com/qemu-project/qemu
Tag: v9.1.0  (fd1952d)
Path: gdb-xml/i386-64bit.xml

NOTE: We aim to support the `org.gnu.gdb.i386.core` feature with
the target description for x86_64. The GDB docs specify the minimal
list of registers that must be included in the description for this
feature. See
https://sourceware.org/gdb/current/onlinedocs/gdb.html/i386-Features.html
The x86_64 target description that we have imported from QEMU includes
more register definitions than required by this feature. At present, we
do not support getting the extra registers. That's why any registers
that are included in the target description from QEMU but not required
by the `org.gnu.gdb.i386.core` feature have been removed. The removed
register definitions are: `ss_base` through `k_gs_base`, `cr0`, `cr2`,
`cr3`, `cr4`, `cr8`, `efer`, `xmm0` through `xmm15`, `mxcsr`.

Checkpatch-Ignore: LONG_LINE
Checkpatch-Ignore: COMMIT_LOG_USE_LINK
Co-authored-by: Thassilo Schulze <thassilo@unikraft.io>
Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Add memory read and write packets to gdb stub
Marc Rittinghaus [Mon, 19 Aug 2024 09:12:06 +0000 (11:12 +0200)]
lib/ukdebug: Add memory read and write packets to gdb stub

These packets allow the gdb host to read and write memory on the
target system. This capability is used to implement breakpoints for
example.

There's an edge-case that the implementation of `gdb_arch_write_memory`
must handle. Assume virtual memory is enabled with `ukvmem` and consider
the following sequence of events:

1. the system starts and the gdb stub is entered early on in the boot
   sequence
2. the gdb stub writes a breakpoint to some location in the program's
   text
3. execution is resumed. Now virtual memory is initialized. The location
   in the program's text that the stub wrote to is marked read-only
4. the breakpoint that the stub created is hit. The stub has to write
   to the read-only page to remove the breakpoint and resume exeuction

This edge-case is handled by using addresses from `ukplat_page_kmap`
instead of the addresses that are passed to `gdb_arch_write_memory`.

Checkpatch-Ignore: UNNECESSARY_PARENTHESES
Co-authored-by: Thassilo Schulze <thassilo@unikraft.io>
Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Add continue and single step packets to gdb stub
Marc Rittinghaus [Mon, 19 Aug 2024 08:58:03 +0000 (10:58 +0200)]
lib/ukdebug: Add continue and single step packets to gdb stub

These packets implement the "single step" and "continue" operations
in gdb.

Checkpatch-Ignore: UNNECESSARY_PARENTHESES
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agoarch: Add SP and PC getters and setters for struct __regs
Michalis Pappas [Wed, 24 Jul 2024 10:23:33 +0000 (12:23 +0200)]
arch: Add SP and PC getters and setters for struct __regs

Add architecture-specific getters/setters for the stack pointer
and program counter of a `struct __regs`. ELR_EL1 is used as the
PC on Arm since `struct __regs` is used in exception context.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Co-authored-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/isrlib: Remove libc dependency
Thassilo Schulze [Thu, 12 Sep 2024 09:43:55 +0000 (11:43 +0200)]
lib/isrlib: Remove libc dependency

`isrlib` had a libc dependency because `isrlib` used libc-defined
types. However, there are equivalent types defined in the kernel
so that we can remove the libc dependency by switching to the
Unikraft-internal types. By removing the libc dependency, we also
remove the potential for a recursive dependency cycle. E.g., now
a library used by `nolibc` can safely select `isrlib`.

Checkpatch-Ignore: SPACING
Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/uknofault, lib/uktest: Fix recursive dependencies
Thassilo Schulze [Mon, 19 Aug 2024 08:51:11 +0000 (10:51 +0200)]
lib/uknofault, lib/uktest: Fix recursive dependencies

The gdb stub selects `uknofault` to access memory in a safe way.
But making the stub select `uknofault` creates two circular dependencies.
There is a similar issue with `uktest`. This commit works around these
circular dependency issues by switching from `select` to `depends on`.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug, arch/arm: Add main loop to handle incoming packets
Marc Rittinghaus [Mon, 19 Aug 2024 08:34:37 +0000 (10:34 +0200)]
lib/ukdebug, arch/arm: Add main loop to handle incoming packets

The main loop of the gdb stub receives packets, calls the appropriate
handlers and responds to the gdb host. The loop is entered after a
debug trap has been caught.  The code in `lib/ukdebug/arch/*` implements
the trap handling for the ARM64 and x86_64 architectures.

Checkpatch-Ignore: COMPLEX_MACRO
Checkpatch-Ignore: UNNECESSARY_PARENTHESES
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agolib/ukdebug: Introduce gdb stub beginning with send/receive functions
Marc Rittinghaus [Mon, 19 Aug 2024 08:23:22 +0000 (10:23 +0200)]
lib/ukdebug: Introduce gdb stub beginning with send/receive functions

This commit starts introducing the gdb stub with the functions that
allow the stub to send data to and receive data from the gdb host.
The actual transmission of data isn't implemented yet. That's why
the `gdb_dbg_putc` and `gdb_dbg_getc` functions are stubs for now.

Checkpatch-Ignore: MACRO_WITH_FLOW_CONTROL
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1479

7 months agodrivers/xen/emg_console: Add Xen emergency console
Thassilo Schulze [Wed, 11 Sep 2024 14:22:10 +0000 (16:22 +0200)]
drivers/xen/emg_console: Add Xen emergency console

The emergency console is kept in a separate library from
the HV console for simplicity. The emergency console also
registers in the early init tab.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agodrivers/xen/console: Adapt HV console to work with `ukconsole`
Thassilo Schulze [Mon, 24 Jun 2024 13:03:42 +0000 (15:03 +0200)]
drivers/xen/console: Adapt HV console to work with `ukconsole`

The standard HV console now works with `ukconsole`. It registers
its initialization function in the early init table.

Checkpatch-Ignore: CAMELCASE
Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agoplat/xen: Update Xen to use console drivers in `drivers/`
Thassilo Schulze [Mon, 24 Jun 2024 12:57:32 +0000 (14:57 +0200)]
plat/xen: Update Xen to use console drivers in `drivers/`

* Imply the console drivers from the Xen platform
  if `ukconsole` is enabled.
* The original Xen console header that was called
  `common/console.h` in the platform now lives in
  the `drivers/` folder where it's accessible as
  `xen/console.h`.
* The Xen console drivers in the `drivers/` directory
  will register in the early init tab. That's why the
  setup on x86 and Arm has to change slightly (see diff)

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agoplat/xen: Move console driver code into drivers/
Thassilo Schulze [Mon, 24 Jun 2024 12:33:09 +0000 (14:33 +0200)]
plat/xen: Move console driver code into drivers/

Just like the drivers from the KVM platform, we also
want to move the Xen console drivers to `drivers/`
and later register them with `ukconsole`.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agoplat/kvm: Imply COM drivers in x86 platform configuration
Thassilo Schulze [Fri, 19 Jul 2024 09:09:27 +0000 (11:09 +0200)]
plat/kvm: Imply COM drivers in x86 platform configuration

The KVM platform configuration for x86 now implies the
COM driver in `drivers/`.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agoinclude/plat: Delete old `ukplat_[cout|cin]` function declarations
Thassilo Schulze [Mon, 17 Jun 2024 11:30:38 +0000 (13:30 +0200)]
include/plat: Delete old `ukplat_[cout|cin]` function declarations

There functions are now replaced by the `ukconsole` interface
and the drivers that implemented them are moved to `drivers/uktty`.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agoplat/kvm: Delete console driver files for x86_64
Thassilo Schulze [Mon, 17 Jun 2024 14:37:46 +0000 (16:37 +0200)]
plat/kvm: Delete console driver files for x86_64

* The implementation of the console drivers now lives
  in `drivers/`. Additional functionality that was in
  the platform before is in `ukconsole`.
* The delete console driver configuration options now
  live in the `drivers/uktty/` subdirectories
* Delete MRD-related code for x86 video memory. This
  MRD is inserted by the VGA driver on init now.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agodrivers/ukconsole: Adapt NS16550 for use with `ukconsole`
Thassilo Schulze [Thu, 11 Jul 2024 08:49:13 +0000 (10:49 +0200)]
drivers/ukconsole: Adapt NS16550 for use with `ukconsole`

These changes are functionally identical to those in the
PL011 driver.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agodrivers/ukconsole: Adapt PL011 driver to work with `ukconsole`
Thassilo Schulze [Thu, 11 Jul 2024 08:12:08 +0000 (10:12 +0200)]
drivers/ukconsole: Adapt PL011 driver to work with `ukconsole`

The PL011 driver can register devices in the early init table
and in the inittab. There can only be a single device that's
registers in the early init table and the base address for
that device can be configured using kconfig or using a kernel
parameter.

Any number of devices can be registered in the init table. The
DTB is searched for PL011 UARTs. If a device is found, a new
device structure is dynamically allocated and registered with
`ukconsole`.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agodrivers/ukconsole: Adapt VGA driver for use with `ukconsole`
Thassilo Schulze [Mon, 22 Jul 2024 09:56:23 +0000 (11:56 +0200)]
drivers/ukconsole: Adapt VGA driver for use with `ukconsole`

The VGA driver registers a device with `ukconsole` in
the early init table. The device that the driver registers
only has the `UK_CONSOLE_FLAG_STDOUT` flag set because the
VGA driver doesn't implement keyboard input.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agoplat/kvm: Move VGA driver from plat/ to drivers/
Thassilo Schulze [Mon, 17 Jun 2024 13:33:01 +0000 (15:33 +0200)]
plat/kvm: Move VGA driver from plat/ to drivers/

This commit moves the VGA driver to `drivers/ukconsole`. In future
commits, the VGA driver will be adapted to work with `ukconsole`.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agodrivers/ukconsole: Adapt COM driver to work with `ukconsole`
Thassilo Schulze [Fri, 19 Jul 2024 09:08:43 +0000 (11:08 +0200)]
drivers/ukconsole: Adapt COM driver to work with `ukconsole`

The COM driver now exposes COM ports COM1 to COM4. The
driver registers a `struct uk_console` for a port to
make that port available to `ukconsole`. One of the
ports can be configured as the "early console". This
port is initialized and registered in the early init
table. All other ports besides the configured "early
console" are initialized and registered when the init
table runs.

Checkpatch-Ignore: EMBEDDED_FUNCTION_NAME
Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agoplat/kvm: Move `serial_console.c` into `drivers/ukconsole/ns16550/`
Thassilo Schulze [Tue, 25 Jun 2024 13:51:33 +0000 (15:51 +0200)]
plat/kvm: Move `serial_console.c` into `drivers/ukconsole/ns16550/`

`serial_console.c` implements a driver for the COM ports
on x86. The driver is now moved out of the platform and
will be registered with `ukconsole` in the future. The device
underlying the COM port interface is a 16550 / 8250 so the
`ns16550` subdirectory is the right place to put this driver.
Because the device is the same on Arm and on x86, the `com.c`
and `ns16550.c` driver should be merged into one driver in
the future.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agodrivers/ukconsole: Rename all occurrences of `uktty` to `ukconsole`
Thassilo Schulze [Thu, 12 Sep 2024 14:09:29 +0000 (16:09 +0200)]
drivers/ukconsole: Rename all occurrences of `uktty` to `ukconsole`

This is part of the rename of the `drivers/uktty` subdirectory
to `drivers/ukconsole`.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agodrivers: Rename `drivers/uktty` to `drivers/ukconsole`
Thassilo Schulze [Wed, 11 Sep 2024 12:29:49 +0000 (14:29 +0200)]
drivers: Rename `drivers/uktty` to `drivers/ukconsole`

The `drivers/ukconsole` subdirectory is where drivers implementing
the interface from the `ukconsole` library will live.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agolib/ukdebug: Switch from `ukplat` to `ukconsole` for printing
Thassilo Schulze [Thu, 20 Jun 2024 11:37:12 +0000 (13:37 +0200)]
lib/ukdebug: Switch from `ukplat` to `ukconsole` for printing

For printing debug messages, `ukdebug` now uses `ukconsole`
instead of the old printing functions from the platform.

Checkpatch-Ignore: SPACING
Checkpatch-Ignore: LONG_LINE
Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agolib/posix-tty: Replace `ukplat_[coutk|cink]` with `ukconsole` calls
Thassilo Schulze [Mon, 17 Jun 2024 11:24:31 +0000 (13:24 +0200)]
lib/posix-tty: Replace `ukplat_[coutk|cink]` with `ukconsole` calls

This commit makes `posix-tty` call into `ukconsole` instead of the
platform-provided print system.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agolib/devfs: Switch from `ukplat` to `ukconsole` for printing
Thassilo Schulze [Thu, 20 Jun 2024 11:39:01 +0000 (13:39 +0200)]
lib/devfs: Switch from `ukplat` to `ukconsole` for printing

`ukconsole` replaces the use of the platform-provided print
functions so `devfs` should use `ukconsole` too.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agolib/syscall_shim: Switch from `ukplat` to `ukconsole` for printing
Thassilo Schulze [Thu, 20 Jun 2024 11:38:18 +0000 (13:38 +0200)]
lib/syscall_shim: Switch from `ukplat` to `ukconsole` for printing

This commit makes the syscall shim call into `ukconsole`
to print some message. Direct calls to `ukconsole` like
this one should normally be avoided in favor of calling
into `ukdebug`. But in this case, we don't want to print
the extra information that `ukdebug` always includes.

When there is a kernel print system in the future, the
new print calls in this commit will be updated.

This commit avoids creating a direct dependency between
the syscall shim and `ukconsole` because the call into
`ukconsole` is a workaround anyway and will be removed
in the future.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agolib/nolibc: Switch from `ukplat` to `ukconsole` for printing
Thassilo Schulze [Tue, 25 Jun 2024 13:16:11 +0000 (15:16 +0200)]
lib/nolibc: Switch from `ukplat` to `ukconsole` for printing

`ukconsole` replaces the use of the platform-provided print
functions so `nolibc` should use `ukconsole`.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agolib/ukconsole: Add abstraction layer for console drivers
Thassilo Schulze [Wed, 10 Jul 2024 13:59:41 +0000 (15:59 +0200)]
lib/ukconsole: Add abstraction layer for console drivers

`ukconsole` is a new library that implements a generic
interface for console devices. It will be used to replace
the current kernel/debug print system that's based on the
`ukplat_c[out|in][k|d]` functions. `ukconsole` is
groundwork for properly integrating the gdb stub with
Unikraft and for adding a proper kernel print system
later on.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

7 months agoinclude/uk/arch: Add kernel `__bool` type
Thassilo Schulze [Fri, 13 Sep 2024 09:51:32 +0000 (11:51 +0200)]
include/uk/arch: Add kernel `__bool` type

This commits adds a kernel-internal `__bool` type to express
booleans.

Checkpatch-Ignore: CAMELCASE
Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1484

7 months agobuild: Log calls to the `multiboot` and `mkefi` scripts
Samuel Hym [Mon, 24 Jun 2024 13:04:15 +0000 (15:04 +0200)]
build: Log calls to the `multiboot` and `mkefi` scripts

Use `build_cmd` to log calls to `multiboot.py` as `MULTIBT` and to
`mkefi.py` as `MKEFI` instead of completely hiding them
This uses fake `.multiboot` and `.efi` extensions to avoid clashing with
the first rule generating the target (ie overwriting its `.cmd` file)
Note this is already done with the `.bin` extension when generating the
binary image

Signed-off-by: Samuel Hym <samuel@tarides.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1469

7 months agoplat/xen: Fix implicit conversion on return type
Andrei Stan [Fri, 6 Sep 2024 19:07:41 +0000 (22:07 +0300)]
plat/xen: Fix implicit conversion on return type

Clang throws an error when trying to implicitly convert
from `const void*` to `const char *`.

Signed-off-by: Andrei Stan <andreistan2003@gmail.com>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1482

8 months agoplat/kvm/arm: Enable early console
Michalis Pappas [Mon, 29 Jul 2024 09:00:30 +0000 (11:00 +0200)]
plat/kvm/arm: Enable early console

Enable early console by default in QEMU virt and Firecracker
on kvm/arm64.

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

8 months agodrivers/uktty/pl011: Deprecate compiled config options
Michalis Pappas [Thu, 1 Aug 2024 06:25:38 +0000 (08:25 +0200)]
drivers/uktty/pl011: Deprecate compiled config options

When PL011_EARLY_CONSOLE is set, the base address of the MMIO
region is provided by the node pointed by the device'tree's
`/chosen/stdout-path`, or by the pl011.base cmdline parameter.

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

8 months agodrivers/uktty/pl011: Add runtime configuration
Michalis Pappas [Thu, 18 Jul 2024 04:09:09 +0000 (06:09 +0200)]
drivers/uktty/pl011: Add runtime configuration

Add cmdline option pl011.base to configure the device MMIO base
address. If that option is not set, try the dtb `chosen/stdout-path`.

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

8 months agodrivers/uktty/pl011: Configure the port at early init
Michalis Pappas [Thu, 18 Jul 2024 02:35:49 +0000 (04:35 +0200)]
drivers/uktty/pl011: Configure the port at early init

The console port is configured at init(), leaving the early
console to the cold-boot port state. Update early_init() to
explicitly configure the port.

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

8 months agodrivers/uktty/pl011: Register driver with earlytab
Michalis Pappas [Thu, 18 Jul 2024 02:15:38 +0000 (04:15 +0200)]
drivers/uktty/pl011: Register driver with earlytab

Register the driver with ukboot earlytab at priority 2
i.e. after the cmdline is parsed and before other early
devices are initialized.

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

8 months agodrivers/uktty/ns16550: Deprecate compiled config options
Michalis Pappas [Thu, 1 Aug 2024 06:33:47 +0000 (08:33 +0200)]
drivers/uktty/ns16550: Deprecate compiled config options

When NS16550_EARLY_CONSOLE is set, the base address of the MMIO
region is provided by the node pointed by the device'tree's
`/chosen/stdout-path`, or by the ns16550.base cmdline parameter.

The register-shift and register-width parameters are provided by
the device-tree via the `reg-shift` and `reg-io-width` properties.

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

8 months agodrivers/uktty/ns16550: Add runtime configuration
Michalis Pappas [Mon, 15 Jul 2024 03:11:42 +0000 (05:11 +0200)]
drivers/uktty/ns16550: Add runtime configuration

Add cmdline option ns16550.base to configure the device MMIO base
address. If that option is not set, try the dtb `chosen/stdout-path`.

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

8 months agodrivers/uktty/ns16550: Update port configuration
Michalis Pappas [Wed, 10 Jul 2024 10:41:11 +0000 (12:41 +0200)]
drivers/uktty/ns16550: Update port configuration

Update the port configuration to set up the baud and
data / parity / stop bits.

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

8 months agodrivers/uktty/ns16550: Configure the port at early_init()
Michalis Pappas [Thu, 18 Jul 2024 07:22:05 +0000 (09:22 +0200)]
drivers/uktty/ns16550: Configure the port at early_init()

The console port is configured at init(), leaving the early
console to the cold-boot port state. Update early_init() to
explicitly configure the port.

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

8 months agodrivers/uktty/ns16550: Register driver with earlytab
Michalis Pappas [Thu, 18 Jul 2024 07:14:46 +0000 (09:14 +0200)]
drivers/uktty/ns16550: Register driver with earlytab

Register the driver with ukboot earlytab at priority 2
i.e. after the cmdline is parsed and before other early
devices are initialized.

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

8 months agolib/ukofw: Add helper for /chosen/stdout-path
Michalis Pappas [Thu, 11 Jul 2024 06:36:41 +0000 (08:36 +0200)]
lib/ukofw: Add helper for /chosen/stdout-path

Add fdt_chosen_stdout_path() helper to derive the boot console.
This returns the node pointed by `/chosen/stdout-path` as well
as any console options set.

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

8 months agolib/ukofw: Add fdt_node_check_compatible_list()
Michalis Pappas [Mon, 15 Jul 2024 02:51:50 +0000 (04:51 +0200)]
lib/ukofw: Add fdt_node_check_compatible_list()

Add a helper to check if a node matches a list of `compatible`.
This is a wrapper to libfdt's fdt_node_check_compatible().

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

8 months agolib/nolibc: Fix memory bug in vfscanf
Thassilo Schulze [Wed, 31 Jul 2024 09:33:57 +0000 (11:33 +0200)]
lib/nolibc: Fix memory bug in vfscanf

It wasn't guaranteed that the `buf` buffer would be
null-terminated in all cases. The fix makes sure that
there is always as null byte at the end.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1474

8 months agoplat/xen/x86_64: Adapt to libukboot early init
Michalis Pappas [Mon, 15 Jul 2024 08:29:24 +0000 (10:29 +0200)]
plat/xen/x86_64: Adapt to libukboot early init

Remove cmdline mrd allocation and call uk_boot_early_init().
Replace call to ukplat_entry_argp() with call to uk_boot_entry().

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1472

8 months agoplat/xen/arm64: Adapt to libukboot early init
Michalis Pappas [Mon, 15 Jul 2024 08:14:27 +0000 (10:14 +0200)]
plat/xen/arm64: Adapt to libukboot early init

Remove cmdline mrd allocation and call uk_boot_early_init().

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1472

8 months agoplat/kvm: Adapt to libukboot early init
Michalis Pappas [Fri, 12 Jul 2024 02:18:29 +0000 (04:18 +0200)]
plat/kvm: Adapt to libukboot early init

Update plat/kvm for newly introduced libukboot early init.

arm64:
- Deprecate kvm/arm64/early_init.c and calls.

arm64 & x86_64:
- Remove ukplat_memregion_list_coalesce() from boot protocols.
  Coalescing is now part of libukboot early init.
- Remove cmdline_init() from kvm/arm64 and kvm/x86_64. Command line
  initialization is now performed of libukboot early init.
- Call uk_boot_early_init() from _ukplat_entry()
- Remove call to ukplat_entry_argp() and jump directly to
  uk_boot_entry()

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1472

8 months agoplat: Move SIPI vector mrd allocation to lcpu_mp_init
Michalis Pappas [Fri, 12 Jul 2024 10:29:48 +0000 (12:29 +0200)]
plat: Move SIPI vector mrd allocation to lcpu_mp_init

Move the SIPI vector mdr allocation from the boot protocol
to lcpu_arch_mp_init(). Notice that lcpu_arch_mp_init() must
be called after mrd coalescing.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1472

8 months agoplat/common: Deprecate UKPLAT_MEMRT_CMDLINE
Michalis Pappas [Mon, 15 Jul 2024 08:07:03 +0000 (10:07 +0200)]
plat/common: Deprecate UKPLAT_MEMRT_CMDLINE

Deprecate UKPLAT_MEMRT_CMDLINE. Passing an cmdline mrd has been
deprecates by libukboot early init.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1472

8 months agoplat/kvm/x86: Remove mrd allocation of cmdline
Michalis Pappas [Mon, 15 Jul 2024 08:01:01 +0000 (10:01 +0200)]
plat/kvm/x86: Remove mrd allocation of cmdline

Remove cmdline mrd allocation from the efi, lxboot, multiboot boot
protocols as this requirement has been deprected by libukboot early
init.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1472

8 months agoplat/common/bootinfo: Remove mrd allocation of cmdline
Michalis Pappas [Fri, 12 Jul 2024 02:19:39 +0000 (04:19 +0200)]
plat/common/bootinfo: Remove mrd allocation of cmdline

Remove cmdline mrd allocation from bootinfo_fdt, as this requirement
has been deprected by libukboot early init.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1472

8 months agolib/ukboot: Rename ukplat_entry() to uk_boot_entry()
Michalis Pappas [Tue, 16 Jul 2024 03:49:12 +0000 (05:49 +0200)]
lib/ukboot: Rename ukplat_entry() to uk_boot_entry()

Migrate definition of ukplat_entry() from uk/plat/bootstrap.h
to boot.h and rename to uk_boot_entry().

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1472

8 months agolib/ukboot: Introduce early init bootstage
Michalis Pappas [Wed, 17 Jul 2024 02:28:10 +0000 (04:28 +0200)]
lib/ukboot: Introduce early init bootstage

Introduce uk_boot_early_init(). This implements an early init
bootstage based on uk_boot_earlytab.

Register cmdline parsing at UK_PRIO_EARLIEST to provide cmdline args
to functions registered into the earlytab.

Deprecate ukplat_entry_argp(). Platforms must now call
uk_boot_early_init() to parse the command line arguments.

As mrd allocation must happen after coalesce, but cmdline parsing must
happen at UK_PRIO_EARLY (before coalesce), deprecate the requirement
for boot protocols to pass a cmdline mrd. Also deprecate the
requirement that platforms provide mutable copy of the cmdline mrd,
as copying is internally performed by the cmdline parsing of early
init into newly introduced buffer of configurable size
(CONFIG_LIBUKBOOT_CMDLINE_MAX_LEN).

Register mrd coalescing as the penultimate priority and reserve
UK_PRIO_LATEST for post-coalesce functions.

Register parsing of uklibparam at UK_PRIO_EARLIEST to provide the
rest of earlytab entries with early cmdline. Notice that for the
time being this has the side-effect of information printed by
libuklibparam to be lost, as earlycon is registered to a later
priority. This will be resolved once libukprint is introduced, as
that library will provide a console buffer.

Checkpatch-Ignore: AVOID_EXTERNS
Checkpatch-Ignore: MACRO_ARG_REUSE
Checkpatch-Ignore: STRNCPY
Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1472

8 months agolib/ukboot: Introduce uk_boot_earlytab
Michalis Pappas [Tue, 16 Jul 2024 04:23:09 +0000 (06:23 +0200)]
lib/ukboot: Introduce uk_boot_earlytab

uk_boot_earlytab is a simplified version of uk_inittab for libraries
that need to register functions at the early boot stage. Libraries
can register with the earlytab using the uk_boot_earlytab_register()
macro.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1472

8 months agodrivers/ukbus/pci: Map PCI regions on runtime
Michalis Pappas [Mon, 24 Jun 2024 11:48:40 +0000 (13:48 +0200)]
drivers/ukbus/pci: Map PCI regions on runtime

Update the PCI driver to map PCI regions on runtime if paging is
enabled.

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

8 months agodrivers/ukbus/platform: Rework uk_bus_pf_devmap()
Michalis Pappas [Mon, 24 Jun 2024 11:42:05 +0000 (13:42 +0200)]
drivers/ukbus/platform: Rework uk_bus_pf_devmap()

Updating the attributes of an already mapped region can potentially
fail as ukplat_page_map() will also return EEXIST for a partially
mapped region too. Addressing the problem by handling a region
page-by-page normally works, yet it is too slow for devices with
large regions like PCI. Rework the implementation to remap the entire
region if ukplat_page_map() returns EEXIST.

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

9 months agolib/uklibparam: Refactor parameter registration
Michalis Pappas [Wed, 17 Jul 2024 08:11:19 +0000 (10:11 +0200)]
lib/uklibparam: Refactor parameter registration

Remove UK_CTORS registration to allow libukparam parsing to be
executed during early init. Parameters now are registered into
a global section similarly to inittab. This additionally fixes
a limitation of the previous registration mechanism where all
parameters had to be registered from a single file.

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

9 months agolib/vfscore: Fix renameat function in vfscore
sebastian [Sun, 16 Jun 2024 11:26:18 +0000 (14:26 +0300)]
lib/vfscore: Fix renameat function in vfscore

In the renameat function, 'dest' variable is declared but not initialized,
leading to unexpected behaviour. Fix by making sure 'dest' is being set
in the else branch by replacing "src" with "dest" in the strlcpy function.

Signed-off-by: Sebastian Ion <sebastianion@outlook.com>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Andrei Tatar <andrei@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1460

9 months ago.github: Remove CODEOWNERS
Marco Schlumpp [Fri, 28 Jun 2024 12:52:28 +0000 (14:52 +0200)]
.github: Remove CODEOWNERS

The goal of the CODEOWNERS file is to automatically assign PRs to the
responsible team. However, this notifies the full team instead of individual
persons and we manually assign specific persons anyway via a bot. After the
team was added as a review once, the notifications will be still sent even
after the team removal. This causes an immensive amount of noise and many
people disable notifications/mails entirely making it necessary to rely
on out-of-band channels to notify people of actual review requests.

Signed-off-by: Marco Schlumpp <marco@unikraft.io>
Reviewed-by: Alexander Jung <alex@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1468

10 months agosupport/qemu-guest: Enable RDRAND, RDSEED for x86 TCG
Simon Kuenzer [Fri, 14 Jun 2024 22:29:06 +0000 (00:29 +0200)]
support/qemu-guest: Enable RDRAND, RDSEED for x86 TCG

QEMU's TCG for x86 can emulate `rdrand` and `rdseed` instructions as
long as specified via `-cpu` parameter and QEMU 8.1.3 or newer is used.
Due to recent requirements introduced with `lib/ukrandom` (see PR #1008,
PR #1451), we request `rdseed` and `rdrand` when using TCG.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1459

11 months agoRelease: v0.17.0 Calypso RELEASE-0.17.0
Razvan Deaconescu [Thu, 6 Jun 2024 22:05:43 +0000 (01:05 +0300)]
Release: v0.17.0 Calypso

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
11 months agoplat/common: Fix wrong `vbase` of legacy video memory area
Sergiu Moga [Thu, 6 Jun 2024 11:33:35 +0000 (14:33 +0300)]
plat/common: Fix wrong `vbase` of legacy video memory area

Commit a001e41f607c ("plat/common/x86: Increase legacy high regions granularity")
used the wrong value for the vbase, using by mistake the length of the
region instead of its start. Fix this.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1452

11 months agolib/ukrandom: Add option to seed the CSPRNG with a fixed value
Michalis Pappas [Wed, 5 Jun 2024 15:42:58 +0000 (17:42 +0200)]
lib/ukrandom: Add option to seed the CSPRNG with a fixed value

Add an option to seed the CSPRNG with a fixed value. This options is
intended for development purposes, or running Unikraft in legacy
systems that don't provide a TRNG.

Enabling this option compromises the system's security. The build
system will mark Unikraft as tainted and libukrandom will print a
banner during init.

DO NOT ENABLE THIS OPTIION IN PRODUCTION SYSTEMS.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Alex Apostolescu <alexx.apostolescu@gmail.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1451

11 months agolib/ukrandom: Use RDRAND to seed ChaCha
Michalis Pappas [Wed, 5 Jun 2024 16:04:29 +0000 (18:04 +0200)]
lib/ukrandom: Use RDRAND to seed ChaCha

It has been observed that in some x86_64 systems the loop that initializes
the ChaCha seed fails after a few iterations due to exhaustion of the
conditioned entropy. In [1] Intel suggests that performance-crtical
systems may use RDRAND instead. Switch to ukarch_random_u32() to
mitigate this risk. In the future there should be a mechanism to allow
configuring the mechanism that controls this behavior, for systems that
favor security to performance.

[1] https://www.intel.com/content/www/us/en/developer/articles/guide/intel-digital-random-number-generator-drng-software-implementation-guide.html

Checkpatch-Ignore: COMMIT_LOG_LONG_LINE
Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Alex Apostolescu <alexx.apostolescu@gmail.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1451

11 months agoconfig: Introduce taint options for Unikraft
Michalis Pappas [Wed, 5 Jun 2024 16:03:50 +0000 (18:03 +0200)]
config: Introduce taint options for Unikraft

Add placeholder for options that taint Unikraft. These options should
be set by any library that provides options to bypass security.

Selecting any of these options will trigger a message on the main
Kconfig screen. Future updates may inlucde additional hints to notify
the user.

Currently, this consists of CONFIG_UK_TAINT_INSECURE_CSPRNG, which should
be set when the security of the CSPRNG is bypassed.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Alex Apostolescu <alexx.apostolescu@gmail.com>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1451

11 months agoplat/common: On overlap, see if left free region surpasses right one
Sergiu Moga [Wed, 5 Jun 2024 14:22:14 +0000 (17:22 +0300)]
plat/common: On overlap, see if left free region surpasses right one

In the following case:
                   ml
◄────────────────────────────────────────────►

 ┌──────────────┬──────────────────────┬─────┐
 │              │                      │     │
 │              │                      │     │
 │              │                      │     │
 │              │                      │     │
 │              │                      │     │
 │              │                      │     │
 │              │                      │     │
 │              │                      │     │
 │              │                      │     │
 └──────────────┴──────────────────────┴─────┘

                ◄──────────────────────►
                       mr

The left over zone to the left of `mr` is inserted separately, as it
should. But without this patch, for the following scenario

                   ml
◄──────────────────────────────────►

 ┌──────────────┬──────────────────┬────┐
 │              │                  │    │
 │              │                  │    │
 │              │                  │    │
 │              │                  │    │
 │              │                  │    │
 │              │                  │    │
 │              │                  │    │
 │              │                  │    │
 │              │                  │    │
 └──────────────┴──────────────────┴────┘

                ◄──────────────────────►
                       mr

There is no leftover space, but a memory region of negative size is
inserted. so check for the size of the negative region before doing any
insertions.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1449

11 months agoplat/common: On memory region based allocations, skip small regions
Sergiu Moga [Wed, 5 Jun 2024 14:18:40 +0000 (17:18 +0300)]
plat/common: On memory region based allocations, skip small regions

If a free memory region is too small for the current requested
allocation, skip to the next region directly.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1449

11 months agoplat/common/x86: Increase legacy high regions granularity
Sergiu Moga [Wed, 5 Jun 2024 14:12:34 +0000 (17:12 +0300)]
plat/common/x86: Increase legacy high regions granularity

Split the previously named `HI_MEM` region into two separate
regions:
- a region for display buffers for video adapters (e.g. VGA Text Mode)
- mapped PCI expansion ROMs regions

This is the new legacy high region expected layout:
Expected memory map for the first 1MiB w.r.t. PC-AT systems compatibility
0x00000 – 0x9FFFF 640KB Main memory, DOS compatible. May contain the
          following memory subregions that we will not need after
          boot. If the EBDA is defined here, then 1KB starting
          at that address shall be treated as a reserved region
    0x00000 - 0x003FF Legacy BIOS IVT, segmented pointers to software
      interrupt routines defined in the ROM BIOS
    0x0040E - 0x0040F Optional EBDA segmented pointer (part of BDA's
      structure that occupies 40:00 -> 40:101 range)
    0x9FC00 - 0xA0000 Default 1KB of EBDA if not defined in previous
      region
0xA0000 – 0xBFFFF 128KB Display buffer for video adapters and possible
  SMM Shadow Memory
0xC0000 – 0xDFFFF 128KB ROM BIOS for add-on cards (PCI XROMBARs)
0xE0000 – 0xFFFFF 128KB System ROM BIOS

NOTE: Some systems only report 0xF0000 - 0xFFFFF for the System ROM BIOS
and that is fine.

Note that we are assigning UKPLAT_MEMRT_RESERVED to BIOS PCI ROM.
We usually have here the routines used by real-mode
bootloaders invoked through the BIOS IVT. Although this may not be
necessary anymore, we cannot assign UKPLAT_MEMRT_FREE either since
some BIOSes do set this as a RO segment in the corresponding chipset
registers, leaving this potentially unusable. Thus, just treat it
as a memory hole.

NOTE: For compatibility with newer Firecracker versions (1.7.0+), if VGA
does not exist, we mark its region as READ-ONLY.

NOTE: Assertions for in-page offsets for such regions has also been
obsoleted to deal with regions like those of EBDA, that are not
page-aligned.

Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1449