support/scripts: Allow overlapping bootinfo region
Preliminary fix: Unikraft expects memory regions in the boot info
to not overlap and be page aligned. This is, however, not
compatible with having the .tdata section being assigned its
dedicated segment. This commit removes the sanity checks for
now as Unikraft can handle this specific case.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Michalis Pappas <michalis.pappas@opensynergy.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #746
When building Unikraft a warning might pop up stating that
the allocated section .tdata is not assigned to a loadable
segment. This commit puts the section into a segment which
is added to the PT_LOAD program headers.
Checkpatch-Ignore: SPACING Signed-off-by: Marco Schlumpp <marco@unikraft.io> Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Michalis Pappas <michalis.pappas@opensynergy.com> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #746
This commit introduces initial print format and decoding definitions for
the following system calls: `SYS_socket`, `SYS_bind`, `SYS_sendto`,
`SYS_recvmsg`
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #737
Simon Kuenzer [Wed, 1 Feb 2023 17:07:16 +0000 (18:07 +0100)]
lib/posix-futex: Remove circular config dependency to syscall_shim
This commit removes the unit test dependency of `lib/posix-futex` to
syscall_shim which caused a circular dependency over `lib/uktest`:
`lib/uktest` started to be dependent on `lib/syscall_shim` and because the
`lib/syscall_shim` depends on `lib/ukstreambuf`, the unit tests of
`lib/ukstreambuf` depend on `lib/uktest` too.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #737
Simon Kuenzer [Wed, 1 Feb 2023 15:22:22 +0000 (16:22 +0100)]
lib/syscall_shim: strace-like output for binary system calls
This commit introduces the option to enable a strace-like output for binary
system calls. The option can be found under the debugging options of
`lib/syscall_shim`. The implementation utilizes the pretty-print function
`uk_snprsyscall()` for system call requests.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #737
Simon Kuenzer [Wed, 1 Feb 2023 21:36:24 +0000 (22:36 +0100)]
lib/syscall_shim: Functions to pretty-print system call requests
This commit introduces an initial implementation of `uk_snprsyscall()` and
`uk_vsnprsyscall()`, two functions that pretty print a system call request
to a given C-string buffer. The system call name, the given arguments
(including flags and definitions) and the response are decoded.
As a start, this commit implements the formatting of the following system
calls: brk, open, openat, write, read, stat, fstat, close, dup, dup2,
gettid, getpid
Yet unsupported system calls are printed with the raw values of arguments.
Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Checkpatch-Ignore: MULTISTATEMENT_MACRO_USE_DO_WHILE
Checkpatch-Ignore: TRAILING_SEMICOLON
Checkpatch-Ignore: MISSING_BREAK
Checkpatch-Ignore: COMPLEX_MACRO
Checkpatch-Ignore: SPACING Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #737
Simon Kuenzer [Mon, 30 Jan 2023 14:09:24 +0000 (15:09 +0100)]
lib/syscall_shim: Use `UK_NARGS()` from `<uk/essentials.h>`
This commit removes the macros `__UK_SYSCALL_NARGS()` and
`__UK_SYSCALL_DEF_NARGS()` and replaces their usage with `UK_NARGS()`
provided by `<uk/essentials.h>`.
Checkpatch-Ignore: LONG_LINE
Checkpatch-Ignore: COMPLEX_MACRO
Checkpatch-Ignore: SPACING Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #737
Simon Kuenzer [Mon, 30 Jan 2023 02:34:07 +0000 (03:34 +0100)]
lib/ukstreambuf: Append operations for binary data
This commit introduces append operations for binary data:
- `uk_streambuf_memcpy()`: Append a copy of binary data
- `uk_streambuf_reserve()`: In-place appending of binary data (zero copy)
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #737
Simon Kuenzer [Mon, 30 Jan 2023 02:30:49 +0000 (03:30 +0100)]
lib/ukstreambuf: Append operations for C-strings
This commit introduces append operations for C-strings:
- `uk_streambuf_printf()`, `uk_streambuf_vprintf()`:
Append a printf-formatted string
- `uk_streambuf_strcpy`: Append a copy of a C-string
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #737
Simon Kuenzer [Mon, 30 Jan 2023 02:25:09 +0000 (03:25 +0100)]
lib/ukstreambuf: Initialization and basic operations
This commit introduces functions to allocate and/or initialize a streambuf
object for a given memory buffer. It also adds basic operations, like
resetting a streambuf buffer and querying its current state.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #737
lib/uksched: Silence warning about unused variable
The parent variable was not used outside the assert. This leads to a
warning when asserts are disabled. This commit fixes the warning
be removing the variable.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@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: #739
Simon Kuenzer [Fri, 3 Feb 2023 19:40:05 +0000 (20:40 +0100)]
lib/vfscore: Cast initrd vbase to (void *)
PR #722 (Boot code refactoring) introduced an update to
`struct ukplat_memregion_desc` where the virtual base of a memory region is
now specified as a __vaddr_t integer value. Since it is a virtual address
we can cast it to (void *) to avoid build warnings in
`lib/vfscore/rootfs.c`.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #744
Michalis Pappas [Sun, 11 Dec 2022 12:13:37 +0000 (13:13 +0100)]
plat/common: Use ukarch_random to generate PAuth key
With the addition of the ukarch_random() API it is now possible to
generate PAuth keys without delegating the implementation of key
generation to the platform. Remove ukplat_pauth_gen_key() from the
platform API and generate PAuth keys using the ukarch_random() API.
This commit fixes a typo in the ukplat_memregion_find_initrd0 macro.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@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: #742
The current implementation uses the heap to allocate memory for the
virtio queues. This is problematic when used in conjunction with
on-demand paging for the heap. It can cause pages of the virtio
queue to be non-contiguous in physical memory. Some pages may
not even mapped to physical memory, yet. Since the hypervisor
does not care about the virtual mapping but only gets the physical
start address of the virtio queue (i.e., the physical address of the
first page), it will write on any physical page in the range of the
virtio queue (i.e., start physical address + size of queue). However,
these physical pages may belong to arbitrary other mappings. And
even if they belong to the same virtqueue, they might not be mapped
in the same order as in the virtual space. This is especially hard to
debug, because the guest is not performing the corrupting memory
writes.
To fix this, we request contiguous memory from the frame allocator
and map this in the same order in the virtual address space using
uk_vma_map_dma().
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
ukvmem provides the means to perform virtual address space management
where each virtual address space is build from a set of virtual memory
areas. This allows the library to select virtual addresses for mappings.
This is in contrast to the primitive paging API which does not manage
virtual address allocation. The library implements different VMA types
via VMA operations that define the VMA's behavior and contents.
Just like on Linux contiguous VMAs are merged and split depending on
the compatibility of their flags and the behavior defined by the VMA.
The library provides functions for mapping, unmapping, and
changing of memory attributes. The initial version comes with
support for x86_64, only.
Checkpatch-Ignore: LONG_LINE_COMMENT
Checkpatch-Ignore: FUNCTION_WITHOUT_ARGS
Checkpatch-Ignore: SPLIT_STRING Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
This commit updates the function documentation in the platform paging
header to the new coding convention so it is inline with the newly added
functions.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
ukplat_page_unmap() ignores non-existent PTEs and just goes on to the
next PTE in the memory range. The same behavior can be achieved with
ukplat_page_mapx(). However, ukplat_page_set_attr() stops at the first
non-existent PTE. This is problematic when on-demand paging has
lead to some pages in a memory range being present and others not.
This commit changes the behavior of ukplat_page_set_attr() to just
ignore this like the other mapping functions.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
Currently, the pg_ffree() function already ignored any errors, but it
has an assert to check if the error could be expected. We add
-ENOMEM to this, which signals that the memory has not been
allocated. While this would indicate a true error condition in case
a physical page is mapped only once, this is not the case if
the same page is mapped multiple times in a certain range and this
range is unmap en-bloc. In this case, the first free would free the
frame in the allocator while the other mappings would cause an
expected error.
An example for such a mapping could be a memory range which
should be zero-initialized by mapping all pages to the same
zero frame and using a CoW-style mapping.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
For temporary mappings of physical memory within the unikernel,
it is useful to have a fast alternative to ukplat_page_mapx() that also
automatically selects a virtual address for the mapping. This commit
introduces ukplat_page_kmap() and ukplat_page_kunmap() for this
purpose. However, they are not guaranteed to succeed if for some
reason no kernel mapping can be established.
However, for direct-mapped physical memory implementations the
functions just return the virtual address of the direct mapping. This
makes the kmap() very fast. In addition, this implementation cannot
fail and the unmap is a noop. The commit comes with an
implementation for x86_64 and arm64.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
The current ukplat_page_map() functions allows to map a range of virtual
pages to physical ones with a defined set of protections. This function
has the following limitations that create problems in the context of
virtual memory management:
1) If a mapping the virtual range already exists, the function
aborts with an error. The caller has no knowledge about the virtual
address that caused the error.
2) If the page attributes are set to read only while physical memory
should be allocated at the same time with paddr=__PADDR_ANY, the
caller has no chance of initializing the frame contents.
This commit replaces ukplat_page_map() with ukplat_page_mapx()
with the x being execute/extended. The mapx version allows the caller
to specify a function that should be called during mapping before
writing a PTE. The function can modify the PTE, instruct the mapping to
skip the current page, or switch to a smaller page size. The original
function behavior is provided when the mapx argument is NULL.
The mapx function can be used in case 1) to either overwrite or skip
existing mappings. The mapx function can also be used together with
a temporary mapping to initialize the physical memory of the current
page before establishing the mapping. This way, we avoid
map/rw -> remap/ro windows, which can also pose a security problem
besides the runtime overhead. If the caller sets paddr=0, it is also
possible to completely leave physical memory allocation to the mapx
function, for example, to serve memory from a cache.
For compatibility, a wrapper for ukplat_page_map() is provided.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
This commit introduces PT_Lx_PTE_SET_PADDR() which allows
to set the physical address in a page table entry. This commit
comes only with the x86_64 implementation.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
This commit introduces a macro called PAGE_SHIFT_Lx() that is
the reverse operation of PAGE_Lx_SHIFT() and allows to compute
the page table level from the page size order.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
Currently, the macro uses the shift to define the mask. However, the
mask is determined by the number of bits reserved for the size, not
by the number of bits shifted in the flag word.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
The PAGE_ATTR_PROT_RW and PAGE_ATTR_PROT_RWX definitions should
be available even when the <uk/plat/paging.h> header is not available,
just like the other PAGE_ATTR_* values. We thus move them to the
arch header.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Michalis Pappas <michalis.pappas@opensynergy.com> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #603
In the boot refactoring, we replaced the statically allocated command
line buffer with a dynamically allocated one. However, the length
argument was not updated, which leads to the cmdline being not
properly parsed.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #741
Marco Schlumpp [Thu, 16 Dec 2021 09:48:56 +0000 (10:48 +0100)]
plat/common/pci: Implement subclass matching
The class is usually not precise enough to identify the correct driver
for a device. For example, an NVM driver can only talk to devices which
are in the subclass of NVM storage devices but not to other devices in
the larger storage class.
Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #624
Tu Dinh Ngoc [Mon, 28 Nov 2022 14:44:12 +0000 (15:44 +0100)]
plat/virtio_net: Notify host of RX bufs on start
Currently, we don't notify the virtio-net device of available RX buffers
on driver start, meaning it might never send us incoming packets. Make
sure that we send this notification once the driver has started.
Signed-off-by: Tu Dinh Ngoc <dinhngoc.tu@irit.fr> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #669
Tu Dinh Ngoc [Mon, 28 Nov 2022 14:43:57 +0000 (15:43 +0100)]
plat/virtio_net: Fix device MTU detection
When looking for MTU information, instead of checking for the
VIRTIO_NET_F_MTU feature flag, the virtio-net driver ends up checking
VIRTIO_NET_F_STATUS instead. This commit fixes this check, and reports
the device's MTU to the netdev architecture.
Signed-off-by: Tu Dinh Ngoc <dinhngoc.tu@irit.fr> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #669
Use fields and field types for nolibc `stat` structure to make it
compatible with Linux. It is required for binary compatibility mode. The
structure is copied from Musl (arch/x86_64/bits/stat.h).
Signed-off-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #675
Marco Schlumpp [Fri, 20 Jan 2023 12:46:39 +0000 (13:46 +0100)]
plat/*: Handle errors returned from IRQ event handlers
PR #691 adds the possibility to return error codes from the event
handler. In the context of interrupts, we interpret an error code as a
fatal error and emit a crash.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #699
The previous changes to the event hide if the last handler that
successfully handled the event allowed further event processing
(i.e., on success always UK_EVENT_HANDLED is returned). This
commit fixes this so that the caller of uk_raise_event() is informed
about if event processing can continue by other means or if it
should stop.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #738
Marco Schlumpp [Fri, 16 Dec 2022 15:03:05 +0000 (16:03 +0100)]
lib/ukdebug: Use correct variable name for sect-strip.py tool
The variable used didn't match the one defined in the platform part and
therefore the specified sections were never stripped.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #690
The sysinfo structure defines the `reserved` buffer. This is however not
present on Linux, meaning that binary-compatibile applications use a
shorter buffer. This results in a buffer overflow when transferring
information from Unikraft to the buffer in binary-compatible app.
This commit fixes this by commenting out the `reserved` buffer in the
`sysinfo` structure.
Signed-off-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro> Reviewed-by: Radu Nichita <radunichita99@gmail.com> Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #673
Marco Schlumpp [Fri, 28 Oct 2022 10:37:00 +0000 (12:37 +0200)]
plat/kvm: Ensure time monotonicity for tscclock
The TSC is not synchronized perfectly on some systems. Examples of such
systems are multi-socket system or newer AMD processors. This patch
ensure that this does not cause an unwanted underflow in the delta
calculation.
GitHub-Fixes: #334 Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #617
Marco Schlumpp [Tue, 19 Oct 2021 08:19:21 +0000 (10:19 +0200)]
lib/vfscore: Introduce no-access-time flag
The ported ext* filesystem supports tracks the access time by
default. By specifying this flag, the user can disable the feature to
reduce the amount of inode updates.
Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #623
Marc Rittinghaus [Tue, 17 Jan 2023 17:45:10 +0000 (18:45 +0100)]
lib/ukboot: Add heap initialization
Previously, the heap has been initialized in the platform code and
information about the heap areas has been communicated via
ALLOCATABLE memory regions. With the new boot information
heap initialization is fully moved to libukboot.
If paging is not enabled, we use the free physical memory areas to
initialize the heap. The platform takes care of only exposing mapped
physical memory. As before, non-contiguous areas are added to the
allocator one-by-one.
If paging is enabled, we create a contiguous mapping at a customizable
base address (default @16GiB) and initialize the allocator with this single
area. As before, using paging allows to access more memory than
mapped by the boot page table.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 17:36:04 +0000 (18:36 +0100)]
plat/kvm: Add generation of boot info
The information about the kernel segments available as part of the
boot information at runtime is generated by the mkbootinfo script.
The script generates a binary blob based on the linked unikernel
image. This blob is then stored in the .uk_bootinfo section to replace
the dummy data.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 17:32:17 +0000 (18:32 +0100)]
plat/kvm: Remove platform symbol hiding
To use protocol-specific names for boot protocol entry functions
we need to remove the platform symbol hiding step. This step
does not serve any useful purpose and can take considerable
time for large images. Removing it thus has also other benefits.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 17:28:52 +0000 (18:28 +0100)]
plat/kvm: Use multiboot entry function
With different boot protocols providing different entry functions
we can no longer statically define a single entry function or would
need to give it a generic name. This, however, would prevent us
from building images that come with support for multiple boot
protocols (i.e., entry functions). Also keeping a protocol specific
name make the function name more descriptive.
We thus remove the static ENTRY from the linker script and
provide the (default) entry symbol via the linker command line.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 17:16:26 +0000 (18:16 +0100)]
plat/kvm: Replace platform initialization code
This commit introduces a boot protocol-independent
platform initialization based on the unikraft boot information.
Major changes to the previous code are:
+ Simplified and no longer specific to multiboot
+ Early boot memory allocation from free memory regions to avoid
static memory reservation for the command line
+ Prepares paging initialization to be moved out of platform code
+ The paging-based implementation performs (un)mappings generically
based on the boot information, leading to more flexibility. For example,
a chainloader can specify its own memory mappings as regions to be
unmapped during boot by the chainloaded unikernel.
+ No heap initialization within the platform.
+ Detailed printing of boot memory map, kernel command line, and
others via the ukplat_bootinfo_print() method.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 17:03:37 +0000 (18:03 +0100)]
plat/kvm: Add multiboot entry
With the new boot information every boot protocol must come with
entry code that transforms the protocol-specific information into the
generic unikraft format. This commit inserts the corresponding
entry function for multiboot v1.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 16:57:13 +0000 (17:57 +0100)]
plat/kvm: Back memregions by boot information
Previously, the entries of the memory region list were dynamically
created at runtime based on the section symbols. This commit
replaces the entire implementation and uses the boot information
as source for the list instead. However, this is only done on
x86 for now. We keep the old method for ARM until we have switched
to boot information.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 16:50:23 +0000 (17:50 +0100)]
plat/common: Introduce boot information
Currently, every boot protocol (e.g., multiboot, Linux Boot Protocol)
must come with their own complete platform initialization as the
basic platform code directly works on the specific boot data
structures. The generalized boot information abstracts away from
the specifics of a certain boot protocol, thereby making it possible to
write generic platform initialization code. Every boot protocol is
thus expected to transform protocol-specific boot information to
the generic form before entering platform initialization code. In case
of chainloading via a custom unikraft loader, the loader may directly
supply boot information in the generalized format.
An important piece of boot information is the memory layout
at the time of boot. That includes the load address of the kernel,
the address of a command line, the load addresses of additional
data blobs (e.g., initrd, devicetree), and where free memory is
located. The boot information structure expresses this as a list
of memory region descriptors. For sanity checks and
compatibility a magic value and version information is provided
at the beginning of the structure.
The boot information is stored in a dedicated section (.uk_bootinfo)
that is initialized with information about the kernel image segments
and their desired access permissions at link-time. To this end, the
linker script needs to call the mkbootinfo.py script and replace the
dummy information in the allocated section with the generated
data.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 16:27:43 +0000 (17:27 +0100)]
plat/kvm: Complement multiboot header
Multiboot uses bits in the flags field to specify what fields are
available. The commit adds definitions for the flag bits. It also
adds any other missing definitions and fixes some style issues.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 16:18:04 +0000 (17:18 +0100)]
plat/kvm: Combine multiboot headers
Currently the multiboot definitions span across two headers. The one
that is used in C code only, and one that is safe to include from
assembly. Since we have the __ASSEMBLY__ macro, which is used
extensively in the project, we reduce the number of headers by
combining both multiboot headers into one.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 16:10:57 +0000 (17:10 +0100)]
include/uk/plat/common: Add memregion list
This commit adds a platform internal memory region list type based
on the public memory region descriptor. The list is effectively a
pre-allocated array that can be filled up to its capacity.
Non-overlapping regions in the list are sorted in ascending order
according to the physical address of the memory regions.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 15:46:37 +0000 (16:46 +0100)]
include/uk/plat: Extend memory region iteration
The previous search function only accepted exact matches. The new
search function extends this by allowing to specify multiple region
types that are accepted and also select the region flags that should
be incorporated in the search. For example, this allows to list all
readable kernel segments irrespective if they are also writeable or
executable.
For improved performance, the new functions only return a pointer
to the memory region and do not create a copy. While this permits
changing the memory region descriptor, this can be useful in early
boot phases to adapt the region list.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marc Rittinghaus [Tue, 17 Jan 2023 15:28:41 +0000 (16:28 +0100)]
include/uk/plat: Extend memory region descriptor
The commit extends the memory region descriptor in multiple ways to
make it ready to be used within the boot protocol to generically
express the memory layout of the system.
The new structure adds separate virtual and physical address fields
so that scenarios are supported where we don't have a 1:1 mapping
(e.g., when loading the kernel to a different virtual address). Types
are changed accordingly. We also embed the name so that the
descriptor becomes self-contained. The type and flags have been
separated for ease of use and because search semantics for these
are different.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #722
Marco Schlumpp [Wed, 1 Feb 2023 14:11:03 +0000 (15:11 +0100)]
plat/kvm/x86: Remove .intrstack section
We now rely on the bootloader to properly load the Unikernel ELF file.
Therefore, we don't be careful to not introduce alignment padding into
the final ELF file. This allows us to place the interrupt stacks in the
normal `.bss` section.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #698
Marco Schlumpp [Tue, 20 Dec 2022 09:20:08 +0000 (10:20 +0100)]
build: Place sections into segments with correct permissions
This hard-codes the permissions of the segments and assigns the sections
to the correct segments. Previously, many sections were just packed
together with other sections that had differing permissions. This
resulted in segments that had overly broad permission bits such as being
writable and executable.
Checkpatch-Ignore: SPACING Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #698
Marco Schlumpp [Tue, 17 Jan 2023 17:35:47 +0000 (18:35 +0100)]
plat/kvm: Remove omagic flag and remove MULTIBOOT_AOUT_KLUDGE
The omagic flag has caused various issues such as having multiple
segments with different permissions on the same page or producing broken
ELF files. It was necessary because the multiboot header specified the
binary layout in a.out terms. This did not allow any padding between
segments.
With this patch we produce a 32-bit ELF file that is loadable by
QEMU/GRUB without having to resort to MULTIBOOT_AOUT_KLUDGE. This is
necessary because the multiboot protocol expects to a binary that will
start in protected mode. After Unikraft switched to long mode the ELF
file type is not relevant anymore. The `*.dbg` is still a 64-bit ELF
file that can be loaded into GDB to debug a running Unikraft instance in
QEMU. Because multiboot only allows 32-bit ELF files, this also means
that the `*.dbg` cannot be loaded anymore.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #698
Marco Schlumpp [Tue, 20 Dec 2022 09:12:19 +0000 (10:12 +0100)]
build: Remove sect-strip.py tool
The script was only used for silencing a warning. Doing the same with
grep is shorter and simpler. In case there are sections to
strip it also saves an objcopy call.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #698