Sergiu Moga [Wed, 1 Nov 2023 07:02:25 +0000 (09:02 +0200)]
lib/uksched: Update `auxsp` of current LCPU when switching stacks
If uksched/ukthread is enabled, make sure that the current LCPU's
auxiliary stack pointer is updated to always point to the currently
executing thread's auxiliary stack pointer by setting it to that
of the thread it is about to switch to during context switching.
Sergiu Moga [Wed, 1 Nov 2023 06:57:34 +0000 (08:57 +0200)]
lib/uksched: Set bootstrap lcpu's `auxsp` during `uk_sched_start`
Make sure to fill in the value of current lcpu's (bootstrap lcpu in
our case) auxiliary stack pointer with that of the current thread's
(main thread) when initializing scheduling.
If shcheduling/multithreading is not enabled, allocate an auxiliary
stack for bootstrap LCPU. Otherwise, the LCPU will have the same
auxiliary stack as the thread that runs on it and this allocation is
not needed.
Sergiu Moga [Tue, 31 Oct 2023 16:49:00 +0000 (18:49 +0200)]
lib/uksched: Introduce the per-thread auxiliary stack
Add a new field to `struct uk_thread` that can represent a secondary
stack that can be used as a backup stack.
This can become very useful in cases such as when wanting to defer
exception handling without creating another thread. For example,
we want to return from an exception into a function inside the
same thread to be able to do deferred I/O outside exception
context without contaminating the original stack that was present
before the trap. We can avoid polluting the original stack by using
this auxiliary stack instead.
Update each thread creation/deletion method's signature and
implementation accordingly.
Sergiu Moga [Wed, 1 Nov 2023 06:44:07 +0000 (08:44 +0200)]
plat/common: Add `auxsp` field to `struct lcpu`
`struct uk_thread` contains a field called `auxsp` which is meant to
represent an auxiliary stack that may be used when switching stacks
during syscall entries or when simply wanting to have a scratch space
to use during a very fragile state of the system, such as when handling
an exception.
Give access to this field through `struct lcpu` as well. This field
shall represent the auxiliary stack pointer of the thread currently
executing on this LCPU.
If uksched/ukthread is disabled, this can come in handy as simply a
pointer to a scratch space that we can contaminate with whatever we
may want during a more fragile execution context.
Sergiu Moga [Thu, 23 Nov 2023 14:00:34 +0000 (16:00 +0200)]
arch/arm64: Implement stack switching on IRQ/trap
Define a per-cpu buffer whose size is twice that of the configured
stacks and whose definition may be represented through the following
diagram:
```
STACK_SIZE STACK_SIZE
<---------------------><--------------------->
|============================================|
| | |
| trap stack | IRQ stack |
| | |
|=============================================
^
SP_EL0
```
The middle address of this buffer shall be assigned to `SP_EL0`,
a great candidate for a register free of use as a `EL1` only Unikernel.
Now, depending on whether an exception is an IRQ or a trap, the early
assembly entry will switch to either the IRQ stack or the trap stack,
by simply making use of the `SP_EL0` system register.
Sergiu Moga [Thu, 23 Nov 2023 13:11:41 +0000 (15:11 +0200)]
plat/common: Move LCPU `id`/`current`/`idx` methods to arch files
Now that we have a per-cpu system register that holds the current
pointer to the `struct lcpu` element of the global `lcpus` array,
make use of that for each architecture independently and move
the implementations of `ukplat_lcpu_[id|current|idx]` from the
architecture agnostic place to the more architecture specific ones.
Notice that a default definition resorting to the value `0` is still
kept for platforms that do not have SMP and do not have a LCPU API
integrated.
Furthermore, obsolete `CONFIG_UKPLAT_LCPU_IDISIDX` since we can now
directly fetch `idx` from `struct lcpu` pointer stored in the
corresponding system register.
NOTE: `lcpu_get_current` of `x86` still makes use of the now
optimized through `%gs` register by calling `ukplat_lcpu_idx`
which calls `ukplat_lcpu_id`. However, in the future, it
will be better if we make use of the `rdgsbase` instruction
and the like.
Co-authored-by: Michalis Pappas <michalis@unikraft.io> Co-authored-by: Marco Schlumpp <marco@unikraft.io> Signed-off-by: Michalis Pappas <michalis@unikraft.io> Signed-off-by: Marco Schlumpp <marco@unikraft.io> Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Sergiu Moga [Thu, 23 Nov 2023 12:55:19 +0000 (14:55 +0200)]
plat/common/arm: Init `TPIDR_EL1` in `lcpu_arch_init`
Every LCPU shall have their `TPIDR_EL1` system register assigned
the value of the address of their own `struct lcpu` element in the
global `lcpus` array.
Implement basic methods to be able to read/write from/to the
GS_BASE and KERNEL_GS_BASE MSR's, as well as from an offset relative
to the former's value.
Co-authored-by: Marco Schlumpp <marco@unikraft.io> Signed-off-by: Marco Schlumpp <marco@unikraft.io> Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Sergiu Moga [Wed, 1 Nov 2023 06:32:07 +0000 (08:32 +0200)]
plat/common/x86: Add macro-definition for `X86_MSR_KERNEL_GS_BASE`
Add a macro-definition for the x86 `KERNEL_GS_BASE` MSR that is usually
used in conjunction with the `swapgs` instruction for an efficient swap
between the `gs_base` register placed in `KERNEL_GS_BASE` and `GS_BASE`.
Co-authored-by: Marco Schlumpp <marco@unikraft.io> Signed-off-by: Marco Schlumpp <marco@unikraft.io> Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Alexander Jung [Wed, 22 Nov 2023 13:46:33 +0000 (14:46 +0100)]
build: Introduce `UK_IMAGE_NAME_OVERWRITE` make var
This commit introduces a new make variable,
`UK_IMAGE_NAME_OVERWRITE`, which is used to customize the
output binary name of the kernel image. This is a special,
and experimental, variable which can be helpful in certain
use cases, for example where targets with the same architecture
and platform are present. This variable should be used in
conjunction with a different build directory, `O=`, as the
resulting binary will always have the name from this option.
Signed-off-by: Alexander Jung <alex@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1169
Marco Schlumpp [Mon, 27 Feb 2023 14:15:58 +0000 (15:15 +0100)]
lib/uknetdev: Add ipv4_dns0_addr configuration
Previously, we were only able to statically configure the ip address,
netmask, and gateway, but not the DNS server. This commit adds the
configuration option for a DNS server.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu> Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1167
Simon Kuenzer [Mon, 18 Sep 2023 12:17:40 +0000 (14:17 +0200)]
build: Introduce `E=` parameter for excluding libraries
This commit introduces the build system parameter `E=` which expects a
colon separated list of paths that are matched against any library path
that the build system is including. This mechanism is intended to be used
for replacing internal libraries.
For example, to replace `uksched`, the replacing library (that has to match
configuration name(s) and APIs) needs to be included with `L=` while at the
same time, the Unikraft-internal library has to be excluded with `E=`:
```
make L=/path/to/external-uksched E=/path/to/unikraft/lib/uksched
```
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104
Simon Kuenzer [Mon, 18 Sep 2023 12:15:42 +0000 (14:15 +0200)]
build: Ability to skip imports with `import_lib`
This commits adds the ability to skip including `Makefile.uk` files by
`import_lib` if the target path matches with one of the paths that can
be found in the `$(IMPORT_EXCLUDEDIRS)` variable.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104
Simon Kuenzer [Thu, 12 Oct 2023 13:18:21 +0000 (15:18 +0200)]
build: Remove obsolete relative paths handling for external libs
This commit removes obsolete build system code that checked if external
libraries and external platforms were handed over from `$(UK_BASE)`
(Application directory or Unikraft root). Relative paths were never
supported and in the meantime, arguments are even checked to be absolute.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104
Simon Kuenzer [Thu, 14 Sep 2023 19:08:02 +0000 (21:08 +0200)]
build: config-submenu: Introduce parameter to exclude libraries
This commit introduces the `-e` parameter which accepts a colon-separated
list of library paths. Such a path is compared to any library path that
would be included. If a match occurs, the affected library path is skipped.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104
Simon Kuenzer [Thu, 14 Sep 2023 19:07:15 +0000 (21:07 +0200)]
build: config-submenu: Correctly quote file path for readlink
Whenever an output file is requested, `support/build/config-submenu`
writes the name of the target file to the console. This commit passes
this file name with quotes to `readlink` that converts it to a fully
qualified path.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104
Simon Kuenzer [Fri, 8 Sep 2023 23:43:48 +0000 (01:43 +0200)]
build: Move arm64 clang target to architecture's Makefile.uk
This commit moves setting of special ARCHFLAGS and ISR_ARCHFLAGS for arm64
with clang compilers from the main Makefile to the architecture's
`Makefile.uk` at `arch/arm/arm64/Makefile.uk`. The original feature was
introduced with:
Commit 55255f470592d ("Makfile: Add target flags for `clang` with `AArch64`")
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104
Simon Kuenzer [Fri, 8 Sep 2023 23:32:07 +0000 (01:32 +0200)]
build: Rename `_import_linker` to `import_linker`
This commit renames the Makefile function `_import_linker` to `import_linker`.
The original intent was for this function to be purely internal and only
used in the core `Makefile`. It turns out that it might be used in other
places in the future, like potentilly external architectures, so this
commit removes the inappropriate `_` prefix.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104
Simon Kuenzer [Fri, 8 Sep 2023 23:31:19 +0000 (01:31 +0200)]
build: Rename `_import_lib` to `import_lib`
This commit renames the Makefile function `_import_lib` to `import_lib`.
The original intent was for this function to be purely internal and only
used in the core `Makefile`. It turns out that it needs to be used in many
other places, like `drivers/`, so this commit removes the inappropriate
`_` prefix.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104
Simon Kuenzer [Thu, 19 Oct 2023 15:17:54 +0000 (17:17 +0200)]
build: Forcefully re-create link to main Makefile
This commit makes sure that the symbolic link within the build directory
always points to the unikraft Makefile version that is used for a
build. This avoids issues when a project is build with multiple Unikraft
versions but using the same build path. The reason is that the build system
is invoking a sub-make call within the build directory using this symbolic
link.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104
plat/kvm: Enable linux-compatible virtio-mmio cmdline on Firecracker
Firecracker injects virtio-mmio device descriptors to the command line
using the Linux format. Enable VIRTIO_MMIO_LINUX_COMPAT_CMDLINE for
Firecracker.
Michalis Pappas [Thu, 31 Aug 2023 14:04:20 +0000 (16:04 +0200)]
drivers/virtio/mmio: Support passing devices via the cmdline
This commit adds support for passing virtio-mmio devices via the
command-line.
The probing function is invoked by ukbus at a priority lower than
the the platform bus, to ensure that the virtio devices have been
probed, to safely register with the parent device.
Add a config parameter to control compatibility with Linux.
Specifically, when VIRTIO_MMIO_LINUX_COMPAT_CMDLINE is selected
the MMIO driver is configured to accept devices in the Linux format,
ie:
virtio_mmio.device = <size>@<base>:<irq>[:<id>]
If this option is not enabled, use the default libukparam
format for this library, ie:
Add `uk_bus_pf_devmap()` for mapping device regions. Because of the
current boot flow that initializes the vmmap API after the probing
the interrupt controller - which is required for bringing up secondary
cores - it is not possible to use uk_vma_map_dma() here, so we need to
resort to the low level paging API and map devices 1:1.
drivers/ukbus/pci: Make PCI ECAM conditional to fdt
The PCI ECAM implementation is tightly coupled to fdt. Given that
the platform bus can now be used on x86_64, make PCI ECAM conditional
to the fdt libraries.
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