Michalis Pappas [Tue, 3 Oct 2023 15:49:35 +0000 (17:49 +0200)]
include/essentials: Provide __fallthrough macro
Add a macro for `__attribute__(fallthrough)` to hint the compiler
about fallthrough cases in switch statements. The fallthough
attributed is supported by the minimum compiler version of both GCC
and clang.
After commit f57ca0bbc402 ("plat/kvm/x86: Make zero page inaccessible"),
early accesses to uninitialized VGA framebuffer would issue an unhandled
page fault and thus crashing the application. Solve this by
preinitializing the `terminal_buffer` variable.
Sergiu Moga [Sat, 14 Oct 2023 09:15:02 +0000 (12:15 +0300)]
plat/kvm/x86: Use `ur_pte` for the first page table
After commit f57ca0bbc402 ("plat/kvm/x86: Make zero page inaccessible"),
UEFI builds would fail to run due to the first page table becoming
unrelocatable.
Therefore, fix this by using the `ur_pte` variant of the `pte` macro.
Clang's preprocessor seems to behave differently when computing an integer
based on undefined macros. For example, the following expression:
```
(!(!__LIBUKLIBID_COMPILEOPT_PIE__) * (0x01 << 0))
```
resolves to 0x0 on GCC's GAS if __LIBUKLIBID_COMPILEOPT_PIE__ is not
defined. Clang is throwing an compile error because of the missing
definition. This commit adopts `libinfo.S` to define an intermediate
value macro that is set to `0` when the requested feature is not enabled.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1131
sys/prctl.h in nolibc is using UK_LIBC_SYSCALLS as guard.
This is not required, since the guard only makes sense outside nolibc.
Remove UK_LIBC_SYSCALLS guard.
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: #1102
The "sys/prctl.h" header is specific to "nolibc". Move it from
"lib/posix-process/include/" to "lib/nolibc/musl-imported/include/".
This also fixes a warning caused by including it when Musl was used
(instead of using the Musl version).
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: #1102
Simon Kuenzer [Mon, 9 Oct 2023 16:04:23 +0000 (19:04 +0300)]
build: Clean-up and removing unused targets, like `config`
This is a small clean-up commit: it removes the unused targets `config`
and `%_defconfig`. Additionally, references to non-existing targets, like
`outputmakefile`, `silentoldconfig`, `list-defconfigs` are removed.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1119
Simon Kuenzer [Sat, 30 Sep 2023 00:13:22 +0000 (02:13 +0200)]
scripts: configupdate: Only notify on architecture change
The `configupdate` script tells the user when `make properclean` should be
called. Since compilation is retriggered on command line changes, we can
limit the cases where cleanup is suggested to architecture changes. This is
done to ensure that the architecture is also considered for fetch and
prepare targets.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1119
Simon Kuenzer [Sat, 30 Sep 2023 00:06:34 +0000 (02:06 +0200)]
build: Recompile on `.config` changes (workaround)
Our build system is still not able to re-trigger the compilation if only
the command line of a compilation unit changed due to a configuration
change. This resulted in broken builds if the user did not call `make
clean` in between.
This commit introduces a workaround that attempts to improve the user
experience by triggering a recompile when the configuration is changed.
This makes this cleaning step unecessary.
It is intended that this commit gets reverted as soon as the build system
can properly detect changes to the compiler command line.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1119
Simon Kuenzer [Fri, 29 Sep 2023 14:51:35 +0000 (16:51 +0200)]
build: Fix rule that copies `.config` to `build/config`
The rule that copies the current `.config` to the build directory was
intended, among other things, to detect configuration changes. However, the
corresponding rule always copies the file, causing to update the timestamp
on every make call. This commit fixes that rule by only copying the file
when there have been configuration updates.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1119
Simon Kuenzer [Fri, 29 Sep 2023 14:50:34 +0000 (16:50 +0200)]
build: Restructure common dependencies for preprule_*
Restructures the preprocess rules to put common dependencies in a single
place. The advantage is that these dependencies are now automatically
applied for externally defined prepare rules.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1119
Simon Kuenzer [Fri, 29 Sep 2023 14:47:31 +0000 (16:47 +0200)]
build: Link-time dependencies for libraries (`*_LDEPS`)
For each `.o` library, additional dependencies that trigger relinking
can be specified in `Makefile.uk` with `*_LDEPS`:
```
<LIBNAME>_LDEPS += <dependency>
<LIBNAME>_LDEPS-y += <dependency>
```
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1119
lib/nolibc: Provide symbols for `malloc`, `free`, `calloc`, `realloc`
`posix_memalign` and `memalign`
To ensure that symbols such as malloc, calloc, and free are accessible
during link time for internal gcc objects, such as those related to gcov,
these functions must be designated as public.
As a side-effect of this change, unikraft loses the fine-grained stats
introduced in #229 when using the before-mentioned calls,
and instead each operation via the libc interface will be accounted
to `nolibc` instead to the individual libraries that made the calls.
Signed-off-by: Eduard-Florin Mihailescu <mihailescu.eduard@gmail.com>
iReviewed-by: Andra Paraschiv <andra@unikraft.org> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1042
Sergiu Moga [Fri, 18 Aug 2023 16:44:40 +0000 (19:44 +0300)]
plat/kvm: Use `AllocatePages()` to allocate memory regions in `UEFI`
According to the `UEFI` specifications, `AllocatePool()` is the safest
allocation method, however there are two pitfalls:
- we don't know the BIOS's memory allocator or the system's memory map,
so the resulted allocation start address may be out of the range that
would be compatible with a Unikraft configuration that does not have
`CONFIG_HAVE_PAGING`
- it does not guarantee page-aligned allocations and, even though we
may be able to align the length or the end address, the allocation's
start address may therefore not be page-aligned
Thus, replace such calls to `AllocatePool()` with calls to
`AllocatePages()` to ensure page-aligned start addresses. Furthermore,
preserve backwards compatibility with Unikraft configurations that do
not have `CONFIG_HAVE_PAGING` by limiting the allocation's start address
to be below the highest address of the static boot page tables through
the help of `bpt_unmap_mrd`.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1061
Kha Dinh [Wed, 11 Oct 2023 17:09:55 +0000 (17:09 +0000)]
arch/*: Update and align paddr/vaddr validation on x86 and arm64
Changed the signature of paddr and vaddr range check to takes the
length of the range instead of the end address, which is more
clear and less error-prone.
The end address is subtracted by 1 to account for the maximum
address in the range.
Also changed the use sites of address range validation to use the
updated signature.
plat/linuxu: Adapt to changes introduced by uk_intctlr
linuxu uses it's own implementation of interrupt handling that until
now implemented the old `ukplat_irq` API. Define `linuxu/irq.h` to
preserve compatibility with the old API. Once linuxu drivers move into
`drivers` they can be updated to provide their own implementation of
the uk_intctlr API.
Notice: Picking individual commits in this PR will break the build.
Update KVM setup to use the new uk_intctlr API. Update the config
to define HAVE_INTCTLR and enable the default controller driver
depending on the VMM and architecture.
Notice: Picking individual commits in this PR will break the build.
plat/kvm: Remove IRQ acknowledgment from uk_intctlr_handle_irq
The method of interrupt acknowledgment varies between interrupt
controllers. On GIC interupts are implicitly ACKed when reading the
interrupt id from GICC_IAR before passing control to the interrupt
handler, and completion is signaled post handling via the GICC_EOIR.
On x86 controllers acknowledgment happens after interrupt handling
is complete.
Remove the explicit interrupt acknledgment from
`uk_intctlr_handle_irq()` as it causes duplicate acknowledgment on
Arm, and move it to `ops->handle_irq()` of the xPIC driver.
Notice: Picking individual commits in this PR will break the build.
drivers/ukintctlr: Add driver placeholder for Intel xPIC
Introduce a new driver placeholder for Intel interrupt controllers.
Since the different generations have often interrelated functionality,
similarly to Arm GIC, a single driver is introduced for the entire
*PIC family (PIC, APIC, x2APIC etc). More fine-grained functionality
can be controlled at the config level.
Notice: Picking individual commits in this PR will break the build.
lib/ukofw: Remove GIC interrupts parsing helper from libukofw
The interpretation of the `interrupts` property in the fdt is
controller-specific [1]. As such, the implementation should be
provided by the corresponding driver. Remove the GIC `interrupts`
helper from libofw as this is now implemented by the GIC driver.
Notice: Picking individual commits in this PR will break the build.
drivers/ukintctlr/gic: Adapt the GIC driver to the new uk_intctlr API
Deprecate `gic_init` in favor of `uk_intctlr_probe()`. Migrate the
`gic` global from the soon to be deprecated `arm64` implementation
of the old intctrl API on arm. This preserves direct access to
`gic->ops` to existing code, until all irq controller functionality
is abstracted away into `uk_intctlr_driver_ops`. Finally, update the
IRQ trigger types to use the ones defined by the uk_intctlr API, and
rename `ops->set_irq_type` to `ops->set_irq_trigger`, as the former
is too vague.
Notice: Picking individual commits in this PR will break the build.
drivers/gic: Make the GIC driver conditional to HAVE_INTCTLR
Arm ports of platforms that don't have an interrupt controller
(linuxu, xen) should not display the GIC driver in menuconfig.
Make the GIC driver conditional to `HAVE_INTCTLR` to prevent it
from being dispayed in these platforms.
Notice: Picking individual commits in this PR will break the build.
The new uk_intctlr API defines common interrupt controller driver ops,
along with a set of functions that must be implemented by the
interrupt controller drivers. It further provides unified interrupt
management and handling.
An interrupt controller descriptor that contains, among others, a
unified set of driver ops. Right now the ops implement a minimal set
of functions, which can be gradually extended to provide more
interrupt controller abstractions.
The interrupt descriptor contains properties that are populated by the
system's device discovery mechanism (fdt, ACPI) and passed to the
interrupt controller via the config operation. Right now it only
contains the interrupt trigger type (egde / level), and in the future
it can be extended to contain additional configuration such as
affinity, polarity, and priority.
The interrupt registration and handling are adaptated from the old
`ukplat_irq` API.
Finally, the previous copyright header of `ukintctlr.h` is replaced
with the one used in newly introduced files, as this is a complete
rewrite.
Notice: Picking individual commits in this PR will break the build.
plat/kvm: Migrate ukplat_irq implementation to libukintctlr
Migrate the implementation of the ukplat_irq API from `plat/kvm/irq.c`
to `lib/ukintctlr/`. The code is moved without changes, and will be
updated once the new uk_intctlr API is defined.
Deprecate the old headers. These will be replaced by new headers that
define the uk_intctlr API.
Notice: Picking individual commits in this PR will break the build.
Marco Schlumpp [Sun, 8 Oct 2023 16:14:42 +0000 (18:14 +0200)]
plat/kvm/x86: Make zero page inaccessible
Commit ad684b5175f70e78dc37ed63d8a124c2b6e53d1c made the first page
accessible. This caused NULL-pointer accesses to not cause a page-fault.
This can hide bugs and therefore this commit splits the first 2MiB page
into 4KiB pages and marks the first one as inaccessible.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1123
Tianyi Liu [Thu, 12 Oct 2023 13:19:41 +0000 (21:19 +0800)]
arch/arm64: Fix dependency for `arm64_syscall_adapter`
The `arm64_syscall_adapter` was introduced by #1009.
In order to forward binary syscalls,
it requires a dependency on `CONFIG_LIBSYSCALL_SHIM_HANDLER`,
and the current `CONFIG_LIBSYSCALL_SHIM` is not enough.
Signed-off-by: Tianyi Liu <i.pear@outlook.com> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1132
Simon Kuenzer [Tue, 10 Oct 2023 11:37:56 +0000 (13:37 +0200)]
lib/uklibid: Option to store "Compile date" to `.uklibid_info`
Adds the option to store the compile time and date for a library and
unikernel. When enabled, `libinfo.S` is recompiled on every rebuild. This
is achieved by handing over the current time and date as compile flag.
For this purpose, the build system provides `$(HOSTUTC)`, the current
time and date in UTC format.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1117
Simon Kuenzer [Fri, 6 Oct 2023 16:46:02 +0000 (19:46 +0300)]
lib/uklibid: Option to store "Compiled-by" to `.uklibid_info`
Adds the option to store information about the person/entity/robot that was
compiling a library and unikernel. When enabled, the local system user and
hostname is used as default. For this purpose, the build system provides
`$(HOSTNAME)` and `$(HOSTUSER)`. Custom strings are also supported as well.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1117
Simon Kuenzer [Fri, 6 Oct 2023 09:58:45 +0000 (12:58 +0300)]
lib/uklibid: Store compile options to `.uk_libinfo`
This commit introduces the storage of an initial set of compile options in
the metadata of each library. The following options are covered by this
commit:
- PIE: Library was compiled position-independent
- DCE: Library was compiled with support for dead code elimination
- LTO: Library was compiled with support for link time optimizations
The options are always saved, because some of the activation states cannot
be mixed, such as the PIE option (e.g., an Unikraft build must be pure PIE
enabled or pure PIE disabled) It is also intended that the encoded flags
are extended in the future.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1117
Simon Kuenzer [Fri, 15 Sep 2023 11:02:24 +0000 (13:02 +0200)]
lib/uklibid: Option to dump list of libraries during boot
This commit introduces the `CONFIG_LIBUKLIBID_INFO_BOOTDUMP` option, which
prints the name and version of each library found in the `.uk_libinfo`
section during boot.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1117
Simon Kuenzer [Tue, 26 Sep 2023 22:45:12 +0000 (00:45 +0200)]
scripts: uk-libinfo.py: Read .uk_libinfo section
This commit introduces the first version of a tool that reads and parses
the library information section (`.uk_libinfo`) of a Unikraft (debug) image
or library object file.
This first version does not yet derive the endianness and int sizes from
the ELF file.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1117
Simon Kuenzer [Fri, 15 Sep 2023 10:57:10 +0000 (12:57 +0200)]
lib/uklibid: Embedded library information
This commit introduces the `.uk_libinfo` section which is used to store
additional library information in library object files. We define the data
structure of the section and declare it as layout version 1. For each
library the build system will generate a single header and each header can
contain an individual number of records to store values.
Layout version 1 also supports storing of information related to the image
as a whole and not to a specific library. A single header is created for
global information, which differs from the library headers in that it does
not contain a record for a library name (LIBNAME).
When a final Unikraft image is linked, the individual sections of each
library are merged into one section.
By default, a minimal set of library and global information is enabled. The
motivation behind this is that library objects are instrumented with
uk_libinfo from now on. In a future commit, the build system could provide
an option to remove this section from (non-debug) images if it is not used
by Unikraft code itself.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Robert Kuban <robert.kuban@opensynergy.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1117
Simon Kuenzer [Mon, 28 Aug 2023 13:14:54 +0000 (15:14 +0200)]
lib/vfscore: Embedded initrd
This commit introduces the ability to embed a CPIO initrd in a unikernel
image. This can be useful to hard link an initrd content to an
unikernel. An additionally provided initrd can then be used freely with the
fstab function.
Checkpatch-Ignore: AVOID_EXTERNS Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Marco Schlumpp <marco@unikraft.io>
GitHub-Closes: #1070
Simon Kuenzer [Mon, 28 Aug 2023 13:12:34 +0000 (15:12 +0200)]
lib/vfscore: Support initrds with `LIBVFSCORE_ROOTFS_CUSTOM`
Commit 24be5b01a7da ("lib/vfscore: Implement individual volume automounting")
disabled the ability to manually specify mounting of an initrd with
`LIBVFSCORE_ROOTFS_CUSTOM`. Initrd support depends on `LIBUKCPIO` and
`LIBRAMFS`. This commit brings back this feature.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Marco Schlumpp <marco@unikraft.io>
GitHub-Closes: #1070
Simon Kuenzer [Mon, 28 Aug 2023 20:20:39 +0000 (22:20 +0200)]
build: Compile dependencies for source files (`*_CDEPS`)
For each source file, additional dependencies that trigger recompilation
can be specified in `Makefile.uk` with `*_CDEPS`:
```
<LIBNAME>_<SOURCENAME>[_<VARIANT>]_CDEPS += <dependency>
<LIBNAME>_<SOURCENAME>[_<VARIANT>]_CDEPS-y += <dependency>
```
Please note that because of the need to remove quotes from filenames,
`qstrip` is called and therefore the CDEPS variable cannot be expanded
with a second expansion (`$$()`).
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Marco Schlumpp <marco@unikraft.io>
GitHub-Closes: #1070
Simon Kuenzer [Mon, 28 Aug 2023 20:19:48 +0000 (22:19 +0200)]
build: Restructure common dependencies for buildrule_*
Restructures the build rules to put common dependencies in a single place.
The advantage is that these dependencies are now automatically applied for
externally defined build rules.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Marco Schlumpp <marco@unikraft.io>
GitHub-Closes: #1070
Marco Schlumpp [Mon, 20 Feb 2023 13:57:00 +0000 (14:57 +0100)]
plat/virtio: Implement support for event index notification suppression
This allows the drivers/device to specify the other side should
send a notification. This is required for firecracker which does not
support the original notification suppression flag.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Andrei Tatar <andrei@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1089
Tianyi Liu [Mon, 31 Jul 2023 05:50:16 +0000 (13:50 +0800)]
arch/arm64: Support AArch64 binary syscalls
An interrupt handler is provided to redirect the interrupts
generated by binary syscalls to the `syscall-shim` layer.
Signed-off-by: Tianyi Liu <i.pear@outlook.com> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Simon Kuenzer <simon.kuenzer@unikraft.io>
GitHub-Closes: #1009
plat/common/arm: Check for offline GICC during ACPI MP enumeration
When we probe for available, valid GICC's, we only look for those
that are already online and initialized, totally forgetting about
those that are usable but offline. Therefore, check for powered off
GICC's as well, since, during probe, we re-initialize GICC's anyway.
plat/common/acpi: Fix `VGIC IRQ MODE` flag bitfield of `GICC`
The bitfield `ACPI_MADT_GICC_FLAGS_VGIC_IRQ_MODE` of `GICC` had
the wrong value: it may be the 3rd bit from right to left, but its
corresponding value is 4 (1 << 2) not 3.
Marc Rittinghaus [Tue, 15 Feb 2022 16:37:51 +0000 (17:37 +0100)]
drivers/virtio: Fix unhandled IRQ
It may happen that depending on timing there is no new data in the
virtio queue, however, an IRQ is still pending. When this pending IRQ
is handled, the driver reports back that it did not handle the request
although in fact resetting the IRQ signal bit in the virtio device is
enough to acknowlegde that an interrupt for the device has been
received and handled (albeit without having to do any additional
work). This will lead to a false Unhandled IRQ error message on
the console. This commit is a first dirty hack to just always
acknowledge IRQs if the status bit is set, thereby avoiding the
error message.
Checkpatch-Ignore: LONG_LINE Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu> Signed-off-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Andrei Topala <topala.andrei@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1115
driver/virtio/mmio: Make config_get return value consistent with PCI
Update the return value of virtio-mmio ops->config_get to return zero
on success rather like the number of bytes read, to align with virtio-pci.
This allows consistent error handling from device driver side.
Signed-off-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Andrei Topala <topala.andrei@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1115
Due to virtio using separate data and control paths, it is normal for
the queue to be observed as empty if the interrupt arrives before the
write can be observed by the driver. Downgrade the severity of the log
message to `debug`.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu> Signed-off-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Andrei Topala <topala.andrei@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1115
Sergiu Moga [Fri, 6 Oct 2023 09:27:04 +0000 (12:27 +0300)]
plat: Increase debug messages of the memregion coalescing function
Add more debugging messages to `ukplat_memregion_list_coalesce` to help
in finding inconsistencies as well as misbehaving memory region maps.
Furthermore, replace returns of error codes with `UK_ASSERT` and, thus,
change `ukplat_memregion_list_coalesce`'s signature to return nothing
as well as its callers' site accordingly.
Sergiu Moga [Fri, 6 Oct 2023 09:25:47 +0000 (12:25 +0300)]
plat/common/memory: Add memregion descriptor print function
Implement a basic printing function for memory regions.
`ukplat_memregion_print_desc`'s implementation will be conditioned
by whether `CONFIG_LIBUKDEBUG_PRINTD` is enabled or not.
plat/common: Do not insert left region empty leftover on overlap
Consider the following case:
|-----------|----------|---------------|
| | | |
|-----------|----------|---------------|
ML start MR start MR end ML end
In the current state, we insert the (ML end - MR end) region regardless
of its length. If it is equal to 0, we end up inserting an empty memory
region. Thus, do not do this insertion if (ML end - MR end) == 0.
Sergiu Moga [Sat, 19 Aug 2023 15:56:01 +0000 (18:56 +0300)]
plat/common: Error out if free regions not aligned for paging init
If the early code did everything right when setting up the memory
regions, then no free memory region should be misaligned by this
point. Otherwise, something bad happened so throw an exception.
Sergiu Moga [Sat, 19 Aug 2023 10:35:23 +0000 (13:35 +0300)]
lib/ukboot: Ensure page-aligned mem regions are added to allocator
If paging is disabled, ensure compatibility with memory allocators
such as TLSF, by only adding page-aligned free memory regions to the
memory allocator pools. Throw an exception otherwise.
Sergiu Moga [Mon, 21 Aug 2023 07:28:49 +0000 (10:28 +0300)]
plat: Make memory region coalescing function handle misalignments
In order to preserve alignment among memory region descriptors, we
would strive to align every inserted memory region. However, this
would also rely on the boot protocol itself to report initial aligned
memory regions, which seems not be the case for some boot protocols
(e.g. cmdline may not be aligned in `Multiboot1`, `initrd` start
address may not be aligned in Linux Boot Protocol).
Therefore, write a single, centralized solution, inside the memory
region coalescing function and make it handle misalignment cases
as well to cope with misbehaving boot protocols. To guarantee
alignment, take each memory region, align it to both ends and
then resolve overlappings. Just like before, free memory regions
are trimmed in favor of other types of memory regions. We know
free memory regions will always be aligned because resolving
conflicts between aligned memory region descriptors will always
yield aligned memory regions.
To preserve original sizes of user allocated memory region descriptors,
in case a deletion is not detected, restore the start address and
length of such region and make sure that the `vbase` field stays updated
with new values of `pbase`.
Finally, now that we offload alignments to the newly improved coalescing
method, remove manual, hardcoded alignments from early boot glue code.
If everything goes as planned and is implemented in a manner where
expectations are met, these alignments should not be needed as they
are transparently ensured by the coalescing method as well as the
paging initialization.
Sergiu Moga [Sat, 19 Aug 2023 15:33:34 +0000 (18:33 +0300)]
plat/common: Preserve original size of allocated memory regions
Previously, `ukplat_memregion_alloc()` would allow one to dynamically
allocate based on available free memory regions a certain memory region
of a specific type and with specific flags and whose size will be the
page-aligned size of the desired size.
A user may want however to fetch some memory regions and know the
actual, intended size. To achieve this, make it so that the allocated
memory region has the original size on the surface, but the actual
allocation is done by splitting a page-aligned chunk to avoid
misalignments.
This leads to the same amount of memory fragmentation as before,
but with the improvement that the user of the API will have access to
the actual size of the data the memory region was allocated for.
Luckily, the paging initialization code is written in such a way that
it aligns every memory region before mapping/unmapping.
Sergiu Moga [Thu, 31 Aug 2023 18:29:48 +0000 (21:29 +0300)]
support/scripts: Use elf64_to_32.py for the multiboot header
Since `multiboot` demands that its corresponding header be placed in the
first 8192 bytes and `GRUB` for whatever reason adds another restriction
requesting that the ELF Program Headers also have to be found in this
range (see GRUB commit 9a5c1ad), offload the effort of building the
Multiboot header from the GAS directive defined header of `multiboot.S`
to `elf64_to_32.py`.
This will offer us more flexiblity and relieve us of the effort of
having anything ELF32 related inside the core codebase.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Marco Schlumpp <marco@unikraft.io>
GitHub-Closes: #1079
Sergiu Moga [Thu, 31 Aug 2023 18:29:48 +0000 (21:29 +0300)]
support/scripts: Rename `elf64_to_32.py` to `multiboot.py`
Now that we use `elf64_to_32.py` for building the `multiboot` header as
well and `elf64_to_32.py` is only used for `multiboot` builds, rename
the script accordingly, to reflect the fact the sole reason this script
exists is to cope with the demands of this ancient boot protocol.
Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Marco Schlumpp <marco@unikraft.io>
GitHub-Closes: #1079
Stefan Jumarea [Wed, 20 Sep 2023 20:32:10 +0000 (23:32 +0300)]
lib/9pfs: Return ENOTTY on terminal ioctl calls
Some applications (e.g. python) will use `ioctl()` calls to check if an
interactive interpretor should be started or if a file should be read.
`9pfs` should respond to all terminal-related calls with an `ENOTTY`
error, so applications know that they are not running in an interactive
environment.
In order to detect the ioctl request type, add a new macro,
`IOCTL_CMD_ISTYPE(cmd, type)`, which will check the corresponding bytes
from the request number (an enhanced version of the Linux `_IOC_TYPE`).
Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1098
Stefan Jumarea [Fri, 15 Sep 2023 20:02:51 +0000 (23:02 +0300)]
lib/9pfs: Return ENOTSUP on ioctl requests
Currently `9pfs` returns 0 for any `ioctl` request (except for
`TIOCGWINSZ`), which leads to multiple cases of files being interpreted
as terminals. You can see this problem when running python scripts,
since python uses `ioctl` calls to check if it should open up the
interactive interpretor or execute a script.
Same thing could happen for other applications that rely on `ioctl`
operations being properly executed, so the best way to go would be
return `ENOTSUP` (as is used to happen before commit 28d0edf).
If the `ioctl` call always return `ENOTSUP`, the Ruby binary
compatibility application will fail, since it tries to set O_ASYNC and
breaks on error, even if it does not directly depends on that, so for
now add a special case for that.
Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Sergiu Moga <sergiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1098