Tianyi Liu [Fri, 15 Sep 2023 18:02:41 +0000 (02:02 +0800)]
arch/*: Add an non-aligned version for stack-pushing
For AArch64, `ukarch_rctx_stackpush` may add padding to make sure
the `sp` register is aligned to 16 bytes. But there're also some
use cases where alignment is not allowed. In such cases, the newly
added `ukarch_rctx_stackpush_packed` and `ukarch_rstack_push_packed`
will be useful.
Signed-off-by: Tianyi Liu <i.pear@outlook.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Andrei Tatar <andrei@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1096
Andrei Tatar [Thu, 14 Sep 2023 08:58:45 +0000 (11:58 +0300)]
lib/vfscore: Fix pipe error codes
This change fixes incorrect return of error codes in the pipe module of
vfscore. Specifically:
- Return positive error codes from internal functions; syscall handlers
expect positive errors and will negate them as required
- Do not set errno, rather return the error code
- Correctly return EINVAL when attempting to open a pipe with O_DIRECT,
as we do not support packet mode pipes, and calling code needs to be
made aware of this
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1093
The futimes and lutimes functions are defined with a `struct timeval [2]`
argument. They are however instantiated with a pointer. This causes a build
warning.
Change the instantiation from pointer to array. This removes the build warning.
Signed-off-by: Tiago Andre Goncalves Oliveira <t.g.oliveira@ua.pt> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1099
Andrei Tatar [Mon, 28 Aug 2023 19:31:17 +0000 (21:31 +0200)]
lib/ramfs: Fix UAF bug when deleting open file
Previously ramfs would eagerly free filesystem nodes when deleting a
file regardless whether the file is open, leading to a possible
use-after-free bug if the open file is later used.
This change fixes this issue by marking nodes as deleted after they have
been removed from the filesystem, then only releasing resources lazily
once all open references have been garbage-collected.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Reviewed-by: Radu Nichita <radunichita99@gmail.com>
GitHub-Closes: #1075
Andrei Tatar [Mon, 28 Aug 2023 19:13:49 +0000 (21:13 +0200)]
lib/vfscore: Fix potential vfscore_file mem leak
Previously if `fdalloc` failed to allocate a file descriptor, the
function would exit without decrementing the reference count on the
vfscore_file object, leading to a potential memory leak.
This change reorders operations to prevent this scenario.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1074
Simon Kuenzer [Fri, 8 Sep 2023 17:37:46 +0000 (19:37 +0200)]
build: Always save architecture with savedefconfig
With `savedefconfig`, KConfig creates a file that contains only options
that are different from the default selection. Because the build system
automatically detects the host architecture and sets the default
architecture to this detected architecture, the architecture is never
part of the defconfig file if the architecture in the configuration
matches the host architecture. This becomes problematic as soon as such
a file is loaded on a build environment that has a different host
architecture: The configuration can fail because of architectural
configuration differences.
This commit ensures that the configured architecture is always stored
in the defconfig file. The `savedefconfig` target appends the configured
architecture to the file if the architectures between host and config
match.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikrat.io>
GitHub-Closes: #1084
Simon Kuenzer [Fri, 8 Sep 2023 21:30:11 +0000 (23:30 +0200)]
build: Forward host architecture from build system to KConfig
Commit c11dceaa9698 ("kconfig: Determine the default arch from CC")
introduced the automatic selection of a default target architecture by
querying and parsing the default compiler's target machine. Because the
detection breaks across GCC output versions, this commit forwards the host
architecture already detected by the main Makefile to the KConfig
system. This way, KConfig will be in sync with what the Makefile system has
detected.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikrat.io>
GitHub-Closes: #1084
Simon Kuenzer [Fri, 8 Sep 2023 17:37:18 +0000 (19:37 +0200)]
build: Do not check for updates with `savedefconfig`
The `savedefconfig` target is not saving a new configuration (`.config`)
but it derives a minimal configuration from the current
configuration. Because of this, it is not necessary to check for
updates to the configuration.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikrat.io>
GitHub-Closes: #1084
Andrei Tatar [Wed, 16 Aug 2023 15:10:50 +0000 (17:10 +0200)]
lib/ukcpio: Preserve timestamp of extracted files
Previously ukcpio did not honor the `mtime` field of cpio sections,
leaving extracted files timestamped with the extraction time.
This change implements setting the timestamps for regular files.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Adina-Maria Vaman <adinamariav22@gmail.com> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikrat.io>
GitHub-Closes: #1071
Andrei Tatar [Wed, 16 Aug 2023 14:24:50 +0000 (16:24 +0200)]
lib/ukcpio: Remove use of malloc & free
This change removes the use of heap memory for computing the extraction
path, eliminating a call to malloc & free for every cpio section,
leaving ukcpio to use only stack memory.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Adina-Maria Vaman <adinamariav22@gmail.com> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikrat.io>
GitHub-Closes: #1071
Andrei Tatar [Wed, 16 Aug 2023 14:01:36 +0000 (16:01 +0200)]
lib/ukcpio: Replace file libcalls with syscalls
This change replaces calls to open, close, write, chmod, and mkdir with
their raw Unikraft syscall equivalents, preventing a call into
potentially non-unikraft code, as well as eliminating the use of errno.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Adina-Maria Vaman <adinamariav22@gmail.com> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikrat.io>
GitHub-Closes: #1071
Andrei Tatar [Mon, 28 Aug 2023 19:25:05 +0000 (21:25 +0200)]
lib/ukmmap: Fix wrong return of NULL
Previously ukmmap's `mmap()` would return NULL for unimplemented cases.
However, no calling code expects this, and will wrongly try to use the
returned buffer.
This change corrects this oversight and returns MAP_FAILED in all cases
of error.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Reviewed-by: Andra Paraschiv <andra@unikraft.org> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1073
Simon Kuenzer [Fri, 22 Sep 2023 14:52:39 +0000 (16:52 +0200)]
scripts: Use GNU version of coreutils on Darwin
This commit changes the scripts under `support/scripts` and
`support/build` so that they use the GNU versions of the following
commands on Darwin:
```
readlink, dirname, grep
```
As soon as Darwin is detected as host environment, the scripts use
the following commands instead:
```
greadlink, gdirname, ggrep
```
These tools are typically installed with HomeBrew
(`brew install coreutils`).
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Jakub Ciolek <jakub.ciolek@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1109
Simon Kuenzer [Fri, 22 Sep 2023 20:13:56 +0000 (22:13 +0200)]
build: Provide command variables for `readlink` and `dirname`
For future references this commit adds command variables for `readlink`
and `dirname`. On Darwin these variables point to the GNU versions of
the commands. They are typically installed with HomeBrew
(`brew install coreutils`) and prefixed with a `g`:
`greadlink`, `gdirename`.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Jakub Ciolek <jakub.ciolek@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1109
Simon Kuenzer [Fri, 22 Sep 2023 15:00:17 +0000 (17:00 +0200)]
build: Use ggrep on Darwin (MacOS)
The build system depends on the GNU version of `grep`. Since this is
typically installed with `ggrep` on Darwin environments with HomeBrew
(`brew install coreutils`), we call `ggrep` in such a case.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Jakub Ciolek <jakub.ciolek@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1109
Simon Kuenzer [Wed, 30 Aug 2023 21:38:19 +0000 (23:38 +0200)]
support/scripts: mkcpio: Support Darwin (MacOS) environments
The standard `cpio` tool available under Darwin is the equivalent of the
`bsdcpio` tool available under Linux. At the beginning of the script we
detect the host environment and use `bsdcpio` or `cpio` accordingly.
Andrei Tatar [Fri, 15 Sep 2023 12:52:19 +0000 (14:52 +0200)]
build: Add target to print unikernel LoC stats
This change adds the `print-loc` Makefile target which (fairly hackishly)
computes and prints statistics about the number of lines of code that
make it into a built unikernel image. It is not intended as an end-user
metric and thus does not aim for any particular level of accuracy or
edge-case handling, rather it is a fun little dev tool that allows
rough comparisons of the level of "bloat" between unikernels.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1108
Marco Schlumpp [Wed, 13 Sep 2023 09:34:17 +0000 (11:34 +0200)]
build: Forward YACC/LEX to kconfig make invocation
KConfig relies on GNU bison and does not work with the classical yacc.
While most Linux distributions prefer bison and add a symlink for yacc,
there are distributions that do not this (Fedora). They seem to actually
use the original Berkeley yacc to provide `yacc`.
Instead of using the default `yacc` for `YACC` in make explicitly forward
our preference for `bison` to the kconfig Makefile.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1092
Andrei Tatar [Tue, 22 Aug 2023 13:43:05 +0000 (15:43 +0200)]
lib/vfscore: Replace dup2 syscalls with dup3
vfscore contained internal calls to the dup2 syscall, which is not
universally provided on all architectures, notably absent on AArch64.
This change replaces calls to dup2 with dup3 which is more universal.
Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Ioan-Teodor Teugea <ioan_teodor.teugea@stud.acs.upb.ro> Reviewed-by: Andra Paraschiv <andra@unikraft.org> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1069
Using Musl and the dirent64 structure causes build warnings. This is
because certain source code files do not define _GNU_SOURCE. Fix build
warnings by defining _GNU_SOURCE in the required source code files.
Signed-off-by: Tiago Andre Goncalves Oliveira <t.g.oliveira@ua.pt> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1097
Robert Kuban [Tue, 5 Sep 2023 14:39:58 +0000 (16:39 +0200)]
Makefile: Fix support for external platforms
Set `KCONFIG_EPLAT_DIRS` to the list of external platforms `$(P)` instead
of `$(E)`, which is not defined in this context.
With the change, the `config-submenu.sh` script will pickup the `Config.uk`
of an external platform as expected.
Signed-off-by: Robert Kuban <robert.kuban@opensynergy.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1082
plat/kvm: Update `kvm/Config.uk` and `kvm/Makefile.uk`
Remove VIRTIO from `kvm/Makefile.uk` and
update VIRTIO drivers on KVM:
* Enable the VIRTIO PCI driver on KVM QEMU VMMs.
* Enable the VIRTIO MMIO driver on all KVM VMMs for arm64.
* Enable the VIRTIO BLK and NET drivers for both
KVM QEMU and Firecracker.
* Enable the VIRTIO 9P driver for when `LIBUK9P`
is selected.
* Correct indentation
lib/9pfs: Add check for `NULL` `data` in `uk_9pfs_parse_options`
The `mount` system call may actually allow ignoring the `data`
argument depending on the usecase. Therefore allow `data` to be
`NULL` by adding a check in `uk_9pfs_parse_options`.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1086
Michalis Pappas [Mon, 28 Aug 2023 21:13:51 +0000 (23:13 +0200)]
drivers: Update includes to the new platform bus headers path
With the platform bus driver being migrated to the ukbus drivers subsystem
its headers path and names have been updated according the the drivers
conventions. Update drivers to use the new include path.
Michalis Pappas [Tue, 29 Aug 2023 16:17:44 +0000 (18:17 +0200)]
plat/kvm: Enable the PCI driver by default
Enable LIBUKBUS_PCI on all KVM VMMs. That will be eventually replaced
by VIRTIO_PCI, yet we add it now to maintain backwards compatibility
with existing applications.
Michalis Pappas [Tue, 29 Aug 2023 19:14:44 +0000 (21:14 +0200)]
drivers/ukbus/pci: Memset dummy_imask using size not element count
The call of memset in the initialization of dummy_imask in the fdt
irq parser of pci_ecam would pass the number of array elements instead
of the array size in bytes.
This bug was pinpointed by a long ignored GCC warning:
warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
237 | memset((void *)dummy_imask, cpu_to_fdt32(~0), ARRAY_SIZE(dummy_imask));
| ^~~~~~
Michalis Pappas [Wed, 30 Aug 2023 15:37:13 +0000 (17:37 +0200)]
plat/kvm: Update Kconfig options to use LIBUKBUS_PCI
The migration of PCI to the drivers subsystem has caused the update
of its Kconfig options according to the driver's conventions. Update
plat/kvm/Config.uk accordingly.
Michalis Pappas [Tue, 29 Aug 2023 16:02:47 +0000 (18:02 +0200)]
drivers: Update includes to the new PCI bus driver headers path
With the PCI driver being migrated to the ukbus drivers subsystem
its headers path and names have been updated according the the drivers
conventions. Update drivers to use the new include path.
This commit adds dynamic entry support to uk_store. Libraries can
dynamically register uk_store objects at runtime, each one of which
is associated with one or more entries. Similarly to static entries,
each dynamic entry is associated with a getter and / or a setter.
Consumers are notified for the lifetime of objects via events.
Checkpatch-Ignore: SPACING LONG_LINE
GitHub-Closes: #539 Co-authored-by: Michalis Pappas <michalis@unikraft.io> Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com> Signed-off-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #939
Michalis Pappas [Tue, 6 Jun 2023 08:34:05 +0000 (10:34 +0200)]
lib/ukalloc: Add entry IDs and update static entry definitions
Introduce header for definitions related to uk_store. Add
entry IDs for stats tracked by uk_alloc, and update static
entry definitions to pass entry IDs.
Signed-off-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #939
Xingjian Zhang [Thu, 17 Aug 2023 13:42:54 +0000 (21:42 +0800)]
plat/drivers/virtio: Fix virtio_9p tag read
Swap the last two arguments of virtio_9p_feature_negotiate's first
call to virtio_config_get. As per the function definition, the last
argument needs to actually be the length of the type.
Signed-off-by: Xingjian Zhang <zhxj9823@qq.com> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1059
Sergiu Moga [Wed, 16 Aug 2023 15:20:39 +0000 (18:20 +0300)]
plat/kvm/x86: Ensure that lxboot initrd/cmdl regions are aligned
All memory region descriptors must be aligned. Therefore, ensure
that the initrd and command-line related memory regions inserted
when booting through the Linux Boot Protocol are also aligned.
Note: If these two are aligned, all the other memory regions reported
through the boot protocol should be already aligned. Thus, we do not
do this explicit alignment on the free memory regions, as they must
have been already aligned by the previous boot phase. If this is not
the case, then the issue lies in the entity that booted us.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1057
Stefan Jumarea [Thu, 29 Jun 2023 08:59:30 +0000 (11:59 +0300)]
lib/vfscore: Add non-largefile variant for dirent
Unikraft defines the `dirent` structure as identical to `dirent64`.
This works fine if not using Unikraft in binary compatibility mode,
since we have total control over the internal functions/structures that
are used.
However, if we use Unikraft in binary compatibility mode, we want to use
Linux `dirent` and `dirent64` structures in order to maintain compatibility
with older libc versions that do not use the `*64` calls by default.
Since the filesystems `READDIR` vop uses `dirent64`, we will convert to a
`dirent` structure within the `readdir_r` call.
Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
GitHub-Closes: #919 Reviewed-by: Radu Nichita <radunichita99@gmail.com> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #963
Sergiu Moga [Wed, 16 Aug 2023 08:56:15 +0000 (11:56 +0300)]
plat/kvm/arm: Use length when clean/invalidating cache in `KVM` entry
Fix second argument of [clean_and_]invalidate_dcache_range in `KVM`
entry to use the length of the range instead of the address of the
end of the range.
Xingjian Zhang [Mon, 14 Aug 2023 15:29:18 +0000 (23:29 +0800)]
plat/drivers: Add two configurations to ns16550
The register shift of ns16550 is hard-coded in the driver, but it does
not match the hardware on some platforms. The device-tree specification
has a property "reg-shift" to describe the register shift of a device.
To match the specification, the register shift of ns16550 is retrieved
from the device tree instead. If no such property is found, the default
value 0 is used.
The register width of ns16550 varies on different platforms. u-boot uses
a reg-io-width property in the device tree to determine it. If no such
property is found, the default value 1 is used. The read and write
macros are replaced by functions with the same name.
This patch also adds the corresponding configurations to override the
values when dts does not specify them.
These two configurations break the compatibility of the driver. To keep
the compatibility, the device tree should contain these properties or
set them in configurations.
plat/common/arm: Do not use a barrier on every invalidation
The current implementation of clean and invalidate by region uses
a barrier after every cache line. This is unnecessary and expensive.
Use a barrier once, at the end of the operation.
plat/kvm/arm: Do not clean & invalidate the cache after enabling the MMU
To maximize boot performance we only invalidate the cache for regions
accessed before enabling the MMU. This makes the clean & invalidate
step of the entire image region after enabling the MMU redundant.
plat/kvm: Do not unconditionally clean and invalidate the cache
The arm64 linux boot protocol provides the requirements for
the system's state before jumping into the kernel [1]. Among
these it is required that upon entry:
- The MMU is off
- The D-cache for the region corresponging to the loaded image
must be cleaned to the point of coherence.
Skip expensive cache clean & invalidate operations if the MMU is
found to be disabled at boot. Although this heuristic is not
strictly required it provides with some additional confidence
that the bootloader behaves as expected.
With a clean cache, additionally optmize cache invalidations by
limiting them to the regions accessed before the MMU is enabled.
Sergiu Moga [Tue, 15 Aug 2023 07:32:34 +0000 (10:32 +0300)]
lib/posix-environ: Ensure that compiled-in strings are writable
Previously, the elements of `__init_env` would be compile-in strings
that would correspond to `CONFIG_LIBPOSIX_ENVIRON_ENVPx` configurable
strings. This lead to these strings being placed by in the `.rodata`
section and making them unmodifiable.
Unfortunately, Redis represents an application whose code may want to
modify such data (see
commit 6356cf6808be ("Set process name in ps output to make operations safer.")).
Therefore, to appease such actions, make sure that this data is placed
in a modifiable section such as `.data` by using statically declared
global variables containing these very strings as an indirection.
To make it look somewhat nicer, do so with the help of two basic helper
macros: DECLARE_LIBPOSIX_ENVIRON_ENV_VAR to transparently declare such
variables and LIBPOSIX_ENVIRON_ENV_VAR to transparently access them.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1054
Sergiu Moga [Mon, 14 Aug 2023 15:33:25 +0000 (18:33 +0300)]
plat/common: Align TLS sections to PAGE_SIZE
`mkbootinfo.py` takes each ELF segment and aligns it to PAGE_SIZE to
convert it to a `struct ukplat_memregion_desc`. However, this ends up
generating overlapping memregion descriptors in the case of the ELF
segment corresponding to the TLS sections.
To solve this, simply ensure that the TLS sections are already aligned
by PAGE_SIZE.
Sergiu Moga [Mon, 14 Aug 2023 15:50:04 +0000 (18:50 +0300)]
plat/kvm: Check return code of all memory region inserting methods
Make sure that we do check the return codes of all of the memory region
inserting methods so that we can crash in case of failure, instead
of letting the system run with a corrupted state.
Sergiu Moga [Mon, 14 Aug 2023 15:42:31 +0000 (18:42 +0300)]
plat/common: Increase granularity of hardcoded legacy high memory
To ensure compatibility with boot protocols that do report the
BIOS System Memory region as a reserved region, split the memory
region inserted by `ukplat_memregion_list_insert_legacy_hi_mem`
into two memory region descriptors: one to contain known memory
holes (e.g. VGA Text Mode framebuffer) and one to contain the
previously mentioned BIOS System Memory region. The former will
have read/write permissions to ensure that zones like the VGA
framebuffer or certain PCI BARs mapped by the BIOS are writable,
while the latter will only have read permissions to ensure
compatibility with other boot protocols.
Michalis Pappas [Mon, 14 Aug 2023 14:07:15 +0000 (16:07 +0200)]
plat/kvm/arm: Fix default choice in arm64 VMM menu
Fix the default selection of the VMM in Config.uk. Kconfig requires
that the default is defined as an attribute of the `choice` option
rather than the contained item.
Signed-off-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1053
Michalis Pappas [Mon, 14 Aug 2023 08:21:36 +0000 (10:21 +0200)]
plat/kvm/arm: Fix bootstack base alignment on arm64
280c69559 introduces a regression to the alignment of the
bootstack. Update __libkvmplat_entry to enforce the correct
alignment before assigning to the sp.
Sergiu Moga [Mon, 14 Aug 2023 08:08:17 +0000 (11:08 +0300)]
plat/common: Add BIOS system memory in legacy high memory region
Previously, `ukplat_memregion_list_insert_legacy_hi_mem` did not
include the `0xf0000 -> 0x100000` memory regions that would usually
contain the legacy BIOS system memory below the first 1MiB. This
would lead to x86 platforms that do not yet have any form of
ACPI (RSDP from BDA or UEFI System Tables) such as Firecracker
to crash when looking for the `RSDP` in that specific region.
Therefore, make sure that this region is also included so that it
can be mapped accordingly by the paging initialization phase.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1046
Sergiu Moga [Sun, 13 Aug 2023 12:06:12 +0000 (15:06 +0300)]
plat/kvm/x86: Enable relocation for `Firecracker` `PIE` builds
Previously, `PIE` builds for `Firecracker VMM` would fail at runtime
due to the fact that the static boot page tables would not be
relocated.
Therefore, enable `Firecracker` builds to run as `PIE` by employing
the early self relocator from `libukreloc`. Since an early bootstack
is also required to backup `rsi` holding the Linux Boot Protocol
structure as well as to provide room to `do_uk_reloc`'s local variables,
use the already existing `lcpu_bootstack` since it does not matter
whether it ends up being tainted or not.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1045
Sergiu Moga [Fri, 11 Aug 2023 17:51:08 +0000 (20:51 +0300)]
plat/kvm: Fix guest hang on `UKPLAT_HALT` during shutdown request
As soon as
commit 170a8a4fb242 ("plat/kvm/shutdown.c: If on a `UEFI` system, rely on Runtime Services")
got merged guests would not finish on successful runs by exiting, but
instead by halting.
Although confusing, the intention was to use `UKPLAT_HALT` for a
graceful shutdown instead of a `cpu_halt` as it acts now.
Therefore, fix this by deleting the `UKPLAT_HALT` `case` from the
`switch` statement.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Alexander Jung <alex@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1039