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

11 months agoplat/kvm/x86: Ensure free memory regions' lengths are page aligned
Sergiu Moga [Wed, 5 Jun 2024 08:36:20 +0000 (11:36 +0300)]
plat/kvm/x86: Ensure free memory regions' lengths are page aligned

All free memory regions must meet the following criteria:
mrd->len == mrd->pg_count * PAGE_SIZE. The `pg_count` field is
equal to the value of `PAGE_COUNT` (i.e. `DIV_ROUND_UP` of `PAGE_SIZE`)
of `len + pg_off`, however in theory this (times `PAGE_SIZE`) should be
equal to the `PAGE_ALIGN_UP` of the latter as well.
To catch cases where this may not happen (if possible), do this
differently: `PAGE_COUNT` for `pg_count` and `PAGE_ALIGN_UP` for `len`.

The lxboot boot code did not correctly compute `len` because of this,
so fix it.

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: Ensure overlapping free regions length is page aligned
Sergiu Moga [Wed, 5 Jun 2024 08:32:51 +0000 (11:32 +0300)]
plat/common: Ensure overlapping free regions length is page aligned

When a memory region descriptor of type free memory overlaps with
another, the former gets adjusted in favor of the former. However,
a condition all free memory regions must meet is that:
mrd->len == mrd->pg_count * PAGE_SIZE.

Ensure this is maintained after an overlapping fixup following a
coalescing operation.

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/xen: Enable HAVE_RANDOM
Michalis Pappas [Wed, 5 Jun 2024 09:31:24 +0000 (11:31 +0200)]
plat/xen: Enable HAVE_RANDOM

Enable HAVE_RANDOM on Xen. This flag implies that the platform
provides a hardware RNG that libukrandom can rely on to securely
seed the CSPRNG.

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

11 months agoplat/kvm: Enable HAVE_RANDOM
Michalis Pappas [Tue, 4 Jun 2024 10:40:09 +0000 (12:40 +0200)]
plat/kvm: Enable HAVE_RANDOM

Enable HAVE_RANDOM on QEMU and Firecracker. This flag implies that
the platform provides a hardware RNG that libukrandom can rely on
to securely seed the CSPRNG.

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

11 months agoarch: Enable the ukarch_random() if HAVE_RANDOM is set
Michalis Pappas [Tue, 4 Jun 2024 10:39:24 +0000 (12:39 +0200)]
arch: Enable the ukarch_random() if HAVE_RANDOM is set

Update config dependencies of ukarch_random() to enable the
feature conditionally to the platform's capabilties.

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

11 months agolib/ukrandom: Clean the public API
Alex Apostolescu [Sun, 2 Jun 2024 08:20:48 +0000 (11:20 +0300)]
lib/ukrandom: Clean the public API

This commit addresses the public API by renaming the main randomness
function uk_swrand_fill_buffer() to uk_random_fill_buffer(), to abide
Unikraft's naming convention.

As a result, the private hwrng function fill_buffer() is renamed to
uk_random_hwrng_fill_buffer().

uk_random_fill_buffer() is the result of a PRNG and it never fails.
Make it void to reflect this.

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

11 months agolib/ukrandom: Add interrupt context check for ChaCha
Alex Apostolescu [Fri, 31 May 2024 04:43:02 +0000 (07:43 +0300)]
lib/ukrandom: Add interrupt context check for ChaCha

Solve a previous TODO by checking that interruots are not disabled.

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

11 months agolib/ukrandom: Clean ChaCha20 implementation
Alex Apostolescu [Fri, 31 May 2024 04:37:02 +0000 (07:37 +0300)]
lib/ukrandom: Clean ChaCha20 implementation

This commit covers the esthetical issues of the chacha implementation.
It replaces size_t and ssize_t with __sz and __ssz, and it removes the
leading underscore from functions name as it does not abide to
Unikraft's current convention.

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

11 months agolib/ukrandom: Register /dev/hwrng
Alex Apostolescu [Thu, 30 May 2024 20:44:17 +0000 (23:44 +0300)]
lib/ukrandom: Register /dev/hwrng

This commit introduces a new device node, /dev/hwrng, that provides
pass-through access to hardware randomness.

Hardware randomness will be available for the kernel API once
ukarch_random is implemneted as a driver. For the time being, restrict
the use of hardware randomness to /dev/hwrng.

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

11 months agolib/nolibc: Add sys/random.h
Alex Apostolescu [Thu, 30 May 2024 19:01:15 +0000 (22:01 +0300)]
lib/nolibc: Add sys/random.h

Add musl's sys/random.h implementation to nolibc and use it to replace
lib/ukrandom's sys/random.h.

Use nolibc-internal/shareddefs.h instead of types.h.
Add names for function arguments as checkpatch requires.

Source of import:
Repository: https://git.musl-libc.org/cgit/musl
Tag: v1.2.4 (f5f55d65)
Path: musl/include/sys/random.h

CheckPatch-Ignore: COMMIT_LOG_USE_LINK
CheckPatch-Ignore: SPDX_LICENSE_TAG

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

11 months agolib/ukrandom: Seed PRNG from hardware
Alex Apostolescu [Thu, 30 May 2024 17:33:34 +0000 (20:33 +0300)]
lib/ukrandom: Seed PRNG from hardware

Remove insecure seeding options and only use hardware randomness to seed
the PRNG.

uk_swrand_init() requires ukarch_random_init() to be called beforehand,
hence they are wrapped inside ukarch_random_init().

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

11 months agolib/ukrandom: Deprecate MWC
Alex Apostolescu [Thu, 30 May 2024 15:41:28 +0000 (18:41 +0300)]
lib/ukrandom: Deprecate MWC

Deprecate multiply-with-carry (MWC) PRNG because it is not
cryptographycally secure.
Remove the choice for an algorithm in Config.uk as ChaCha20 is the only
supported algorithm.

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

11 months agolib/ukrandom: Rename ukswrand to ukrandom
Alex Apostolescu [Thu, 30 May 2024 14:48:16 +0000 (17:48 +0300)]
lib/ukrandom: Rename ukswrand to ukrandom

This commit renames ukswrand library to ukrandom to better describe its
use case. This library will provide cryptographically secure random
numbers, either directly from the hardware, or from a PRNG seeded with
the true random seed.

swrand.h is the main header of the library and should match its name,
therefore it is renamed to random.h. swrand.c is also renamed to match
the header.

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

11 months agoarch/x86_64/random.h: Fix return values
Alex Apostolescu [Thu, 8 Feb 2024 10:31:41 +0000 (12:31 +0200)]
arch/x86_64/random.h: Fix return values

ukarch_random_u* should return either 0 for success or a negative value
for failure as per arch/random.h comments.

RDRAND and RDSEED will set the carry flag to 1 if the operation
succedded. Return 0 or -1 explicitly based on this.

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

11 months agoarch/arm64/random.h: Fix return values
Alex Apostolescu [Thu, 8 Feb 2024 10:40:05 +0000 (12:40 +0200)]
arch/arm64/random.h: Fix return values

ukarch_random_u* should return either 0 for success or a negative value
for failure as per arch/random.h comments.

RNDR and RNDRRS will set NZCV system register to 0 if the operation
succedded. Return 0 or -1 explicitly based on this.

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

11 months agoarm64/random.h: Include arch/lcpu.h
Alex Apostolescu [Thu, 30 May 2024 14:50:30 +0000 (17:50 +0300)]
arm64/random.h: Include arch/lcpu.h

arm64/include/uk/asm/random.h requires ID_AA64ISAR0_EL1_RNDR_SHIFT and
ID_AA64ISAR0_EL1_RNDR_MASK which are defined in uk/arch/lcpu.h.

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

11 months agoplat/common/arm: Check for QARMA3 support in pauth_init()
Michalis Pappas [Sat, 1 Jun 2024 15:08:31 +0000 (17:08 +0200)]
plat/common/arm: Check for QARMA3 support in pauth_init()

Add definitions ID_AA64ISAR2_EL1.APA3 and update pauth_init() to
additionally query APA3 (QARMA3) when checking if PAuth is enabled.

Checkpatch-Ignore: LONG_LINE
Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1441

11 months agolib/ukalloc: Fix build with clang when MEMTAG is enabled
Michalis Pappas [Sat, 1 Jun 2024 14:56:13 +0000 (16:56 +0200)]
lib/ukalloc: Fix build with clang when MEMTAG is enabled

Replace cast to uint64_t with __u64 to fix building with clang when
memory tagging is enabled.

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

11 months agoplat/common/x86: Sanitize the ECTX slot on syscall entry
Sergiu Moga [Mon, 3 Jun 2024 10:57:23 +0000 (13:57 +0300)]
plat/common/x86: Sanitize the ECTX slot on syscall entry

Commit c716bcca4822 ("{lib,arch,plat}: Redo syscall ctx's and swapgs logic"),
following a rework of architecture specific contexts and syscall entries,
by mistake removed the ECTX sanitization at the beginning of system calls.
This can result in #GP on x86 if the XSAVE header happens to be dirty.
Thus, bring this sanitization back.

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

11 months agoplat/xen: Remove UKPLAT_MEMRF_MAP from arm/setup64
Michalis Pappas [Tue, 4 Jun 2024 06:46:36 +0000 (08:46 +0200)]
plat/xen: Remove UKPLAT_MEMRF_MAP from arm/setup64

Remove UKPLAT_MEMRF_MAP to fix a regression when allocating memregs
on arm/setup64.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Andrei Stan <andreistan2003@gmail.com>
GitHub-Closes: #1445

11 months agoarch/arm64: Add checks for min clang version
Michalis Pappas [Sat, 1 Jun 2024 14:50:53 +0000 (16:50 +0200)]
arch/arm64: Add checks for min clang version

Add conditionals for clang to fix the build when arch features are
enabled. Set min clang version to 14 on all features as that is the
first clang version that supports branch-protection on arm64, and
for the rest of the features the only version tested.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Radu Nichita <radunichita99@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1439

11 months agodrivers/ukrtc/pl031: Map pl031 regions at runtime
Michalis Pappas [Wed, 15 May 2024 09:49:54 +0000 (11:49 +0200)]
drivers/ukrtc/pl031: Map pl031 regions at runtime

Map pl031 regions dynamically if paging is enabled. This is now
required as paged memory init unmaps any memory not backed by an
mrd.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agodrivers/ukintctlr/gic: Map GIC regions at runtime
Michalis Pappas [Wed, 15 May 2024 09:48:35 +0000 (11:48 +0200)]
drivers/ukintctlr/gic: Map GIC regions at runtime

Map GIC regions dynamically if paging is enabled. This is now required
as paged memory init unmaps any memory not backed by an mrd.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agoplat/kvm/arm64: Register UART devices to early init
Michalis Pappas [Sat, 30 Mar 2024 13:35:12 +0000 (14:35 +0100)]
plat/kvm/arm64: Register UART devices to early init

Register ns16550 and pl011 into ukplat_early_init.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agoplat/kvm/arm64: Remove console registration from platform setup
Michalis Pappas [Fri, 29 Mar 2024 16:07:22 +0000 (17:07 +0100)]
plat/kvm/arm64: Remove console registration from platform setup

With both UART drivers initialized by uk_inittab, remove console
registration from platform setup.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agodrivers/uktty/ns16550: Add early_init
Michalis Pappas [Tue, 26 Dec 2023 16:01:14 +0000 (17:01 +0100)]
drivers/uktty/ns16550: Add early_init

Add early device init. When paging is enabled, this adds an mrd for
the ns16550 MMIO region to bootinfo so that the region is not unmapped
during paged memory init.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agodrivers/uktty/ns16550: Move driver initialization to uk_inittab
Michalis Pappas [Sun, 31 Mar 2024 15:42:14 +0000 (17:42 +0200)]
drivers/uktty/ns16550: Move driver initialization to uk_inittab

Move console initialization with the rest of devices at
UK_INIT_CLASS_SYS. Since the pf bus does not support priority
levels, and the console should start before the pf bus to
allow drivers to print their status, register directly with
init instead of the pf bus.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agodrivers/uktty/ns16550: Fix config option of early console
Michalis Pappas [Tue, 26 Dec 2023 15:45:20 +0000 (16:45 +0100)]
drivers/uktty/ns16550: Fix config option of early console

Update the early console Kconfig option of ns16550 to aligned with the
current convention as well as the equivalent option of pl011.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agodrivers/uktty/ns16550: Map device region at runtime
Michalis Pappas [Sun, 31 Mar 2024 15:31:01 +0000 (17:31 +0200)]
drivers/uktty/ns16550: Map device region at runtime

Map the ns16550 region at runtime. This is now required as paged memory
init unmaps any memory not registered by early devices, thus if early
UART is not enabled the device regions is not mapped.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agodrivers/uktty/ns16550: Clean up driver init
Michalis Pappas [Sun, 24 Dec 2023 09:39:26 +0000 (10:39 +0100)]
drivers/uktty/ns16550: Clean up driver init

Clean ns16550 driver init. Functional changes:
- Return an error when init fails
- Downgrade diagnostic message severity to uk_pr_debug

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agodrivers/uktty/pl011: Add early init
Michalis Pappas [Sat, 30 Mar 2024 13:34:43 +0000 (14:34 +0100)]
drivers/uktty/pl011: Add early init

Add early device init. When paging is enabled, this adds an mrd for
the pl011 MMIO region to bootinfo so that the region is not unmapped
during paged memory init.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agodrivers/uktty/pl011: Move driver initialization to initttab
Michalis Pappas [Sat, 30 Mar 2024 13:06:09 +0000 (14:06 +0100)]
drivers/uktty/pl011: Move driver initialization to initttab

Move console initialization with the rest of devices at
UK_INIT_CLASS_SYS. Since the pf bus does not support priority
levels, and the console should start before the pf bus to
allow drivers to print their status, register directly with
init instead of the pf bus.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agodrivers/uktty/pl011: Map region on runtime
Michalis Pappas [Sun, 31 Mar 2024 12:54:36 +0000 (14:54 +0200)]
drivers/uktty/pl011: Map region on runtime

Map the pl011 region at runtime. This is now required as paged memory
init unmaps any memory not registered by early devices, thus if early
UART is not enabled the device regions is not mapped.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agodrivers/uktty/pl011: Clean up driver init
Michalis Pappas [Sun, 24 Dec 2023 09:34:17 +0000 (10:34 +0100)]
drivers/uktty/pl011: Clean up driver init

Clean up pl011 init. Functional changes:
 - Return an error when init fails
 - Downgrade diagnostic message severity to uk_pr_debug

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agoplat/kvm/arm: Add early init boot stage
Michalis Pappas [Fri, 8 Mar 2024 05:22:12 +0000 (06:22 +0100)]
plat/kvm/arm: Add early init boot stage

Add boot stage for early initialization. This is invoked at the end
of early boot code, before passing control to the platform.

Early devices can use the APIs provided by the boot protocol to obtain
any information required, such as device regions and the kernel
command line.

Drivers that register with early_init() should append mrds of their
MMIO regions to bootinfo so that these regions are not unmapped
during paged memory init. These mrds must use the newly introduced
UKPLAT_MEMRT_DEVICE type.

Notice that early drivers should not call ukplat_bootinfo_coalesce(),
as mrd coalescing is performed once at the end of early_init().

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agoplat/kvm/x86: Coalesce bootinfo at EFI post
Michalis Pappas [Wed, 15 May 2024 13:30:15 +0000 (15:30 +0200)]
plat/kvm/x86: Coalesce bootinfo at EFI post

With bootinfo coalesce having moved out of EFI common code,
and with kvm/x86 lacking an early init bootstage, do the coalescing
as the last part at EFI post before jumping to kernel.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agoplat/kvm: Move coalesce outside EFI bootinfo setup
Michalis Pappas [Tue, 14 May 2024 16:03:20 +0000 (18:03 +0200)]
plat/kvm: Move coalesce outside EFI bootinfo setup

Remove coalescing from EFI bootinfo setup to allow coalescing to
happen at a boot protocol agnostic way at early_init(), after the
initialization of early devices.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agoplat/kvm: Clean up function declarations in EFI post
Michalis Pappas [Wed, 15 May 2024 13:38:00 +0000 (15:38 +0200)]
plat/kvm: Clean up function declarations in EFI post

Remove redundant extern keyword from function declarations in EFI
post on arm64 and x86_64.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373

11 months agoplat/common: Move coalesce out of bootinfo fdt setup
Michalis Pappas [Tue, 14 May 2024 16:01:45 +0000 (18:01 +0200)]
plat/common: Move coalesce out of bootinfo fdt setup

Remove coalescing out of bootinfo fdt setup to allow coalescing happen
at a boot protocol agnostic way at early_init(), after the initialization
of early devices.

Break down bootinfo_fdt_setup() into a pre and post coalesce functions
as the latter call ukplat_memory_alloc() which operates on ordered
regions.

Signed-off-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu@unikraft.io>
Reviewed-by: Serban Sorohan <serban.sorohan@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1373