Simon Kuenzer [Thu, 23 Feb 2023 23:42:29 +0000 (00:42 +0100)]
lib/uklibparam: Rewrite of parser
This commit introduces a rewrite of `lib/uklibparam`. The rewrite ensures
that it is errno-free, malloc-free, and TLS-free. This makes it ideal for
processing library parameters early during boot. It includes an own and
modified version of `strtoull` function that is used for parsing integer
values from the command line.
Additionally, the parser can handle arrays more intuitively (and for any
data type of the elements) while fully utilizing pre-processed argument
vectors. It relies on the fact that whitespacing and quoting is already
handled (e.g., by `lib/ukargparse`). There are new types that are more
inline with the ones defined by ukstore.
This rewrite introduces the ability to provide a parameter description
with updated parameter registration macros:
UK_LIBPARAM_PARAM(variable, type, description)
UK_LIBPARAM_PARAM_ARR(variable, type, count, description)
The description is printed on the help output.
The previous interfaces are kept for backwards compatibility. However,
it is planned to remove them as soon as the code base is completely
adopted.
Checkpatch-Ignore: SPACING
Checkpatch-Ignore: OPEN_BRACE
Checkpatch-Ignore: MACRO_WITH_FLOW_CONTROL Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868
Simon Kuenzer [Thu, 23 Feb 2023 21:21:04 +0000 (22:21 +0100)]
build: Declare __LIBNAME__, __BASENAME__ and __VARIANT__ for .lds.S
.lds.S files are linker script files that use the C preprocessor in order
to generate the final .lds file. This commit provides Unikraft's common
declarations of `__LIBNAME__`, `__BASENAME__`, `__VARIANT__` to this
pre-processing step so that they can be used for generating linker scripts.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868
Simon Kuenzer [Thu, 23 Feb 2023 20:47:59 +0000 (21:47 +0100)]
plat/*: Add linker scripts to link dependencies
This commit adds needed linker scripts as dependency to the linking rule
of the final image. This dependency was mostly indirectly covered via
libraries. However, updates to platform linker scripts did not trigger
relinking the final image.
Additionally, pure API libraries (like `lib/ukfalloc`) would not even cause
building a linker script that is shipped with the library or injected with
an `EACHOLIB_SRCS` declaration. The library buildrule is generated but
because no library object is generated, the linker script was never be part
of a dependency list.
Signed-off-by: Simon Kuenzer <simon@unikraft.io> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #868
Marc Rittinghaus [Tue, 25 Apr 2023 10:24:08 +0000 (12:24 +0200)]
lib/vfscore: Cleanup sys_symlink
This commit cleans up sys_symlink() according to the current coding
conventions and uses separate jump labels for exits depending on
if the vnode lock needs to be released or not.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@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: #866
Marc Rittinghaus [Tue, 25 Apr 2023 10:19:05 +0000 (12:19 +0200)]
lib/vfscore: Do not copy oldpath in symlink
With the changes to the vnode ops definitions the symlink operation
takes a constant string. We can thus just pass the input string on
without having to copy it.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@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: #866
Marc Rittinghaus [Tue, 25 Apr 2023 10:12:09 +0000 (12:12 +0200)]
lib/vfscore: Make vnops strings constant
The current vnode operations define strings as mutable, which
makes it more difficult to do optimizations. Since no buffer size
is supplied the strings can only be modified on a char-for-char
basis anyways, which also limits the use-cases. In addition, no
implementation of the vnode operations makes use of the
mutability of the strings.
This commit thus introduces the `const` keyword for all strings
passed to vnode operations.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@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: #866
Marco Schlumpp [Mon, 17 Apr 2023 08:04:04 +0000 (10:04 +0200)]
lib/posix-futex: Check for proper FUTEX_CLOCK_REALTIME usage
The documentation specifies a list of operations which support this
flag. This adds a check that explicitly rejects all invalid combinations
and returns `ENOSYS` according to the documentation.
Checkpatch-Ignore: ENOSYS Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Adina Smeu <adina.smeu@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #758
Marco Schlumpp [Thu, 9 Feb 2023 15:44:35 +0000 (16:44 +0100)]
lib/posix-futex: Implement subset of FUTEX_WAIT_BITSET
Many modern applications use FUTEX_WAIT_BITSET to be able to set an
absolute timeout. To accomplish that they set all bits in the val3/mask
parameter, which makes the operation equivalent to a normal FUTEX_WAIT
(except the absolute timeout value).
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Adina Smeu <adina.smeu@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #758
Marco Schlumpp [Thu, 9 Feb 2023 14:57:30 +0000 (15:57 +0100)]
lib/uksched: Expose uk_thread_block_until
This allows external API clients to specify an absolute deadline for
waking up. This is potentially more precise because the `timeout` is
relative to whenever uk_thread_block_timeout is actually taking the
"current" time.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Adina Smeu <adina.smeu@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #758
Marco Schlumpp [Mon, 2 Jan 2023 10:22:18 +0000 (11:22 +0100)]
plat/kvm/x86: Stop unwinding at _libkvmplat_entry2
The _libkvmplat_entry2 function is called using assembler code that
switches stacks. Therefore, a debugger can't unwind its frame. This
inserts a CFI that marks the previous instruction pointer as undefined.
Signed-off-by: Marco Schlumpp <marco@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: #700
Marco Schlumpp [Mon, 2 Jan 2023 14:15:52 +0000 (15:15 +0100)]
plat/kvm/x86: Add unwinding information to interrupt/exception handlers
This allows debuggers and profilers to unwind past interrupt/exception
handlers.
Signed-off-by: Marco Schlumpp <marco@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: #700
Marco Schlumpp [Wed, 21 Dec 2022 10:01:34 +0000 (11:01 +0100)]
plat/x86: Add unwind information to system call handler
Without this information debugging tools do not know how to properly
unwind the _ukplat_syscall frame. For example, this causes them to
output garbage output for back traces.
Signed-off-by: Marco Schlumpp <marco@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: #700
Marco Schlumpp [Mon, 2 Jan 2023 10:40:13 +0000 (11:40 +0100)]
arch/x86: Add helpers for CFI in assembler code
This introduces helpers for maintaining frame information when using
push and pop in assembler code.
Checkpatch-Ignore: SPACING Signed-off-by: Marco Schlumpp <marco@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: #700
Marco Schlumpp [Tue, 24 May 2022 18:17:14 +0000 (20:17 +0200)]
lib/nolibc: Define u_(long|int|short_char) for _DEFAULT_SOURCE files
These typedefs are commonly used in BSD code. Most libc libraries define
them by default or for _DEFAULT_SOURCE files. Because unikraft is
usually closer to Linux, this adopts the later approach.
Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@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: #627
The bcopy/bzero originate from BSD, but are often provided by libc on
other systems for compatibility. The strcat function is also added for
improved compatibility.
Signed-off-by: Marco Schlumpp <marco.schlumpp@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@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: #627
Marco Schlumpp [Mon, 27 Feb 2023 14:33:10 +0000 (15:33 +0100)]
build: Implement a more robust compiler detection
Instead of checking the compiler executable name, inspect the compiler's
version output. This also works when there are symlinks involved or the
executable name has additional text such as version numbers.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #774
Eduard Vintilă [Sat, 28 Jan 2023 20:01:53 +0000 (22:01 +0200)]
plat/kvm/arm: Use 48-bit virtual addressing for PARange >= 52
Latest versions of QEMU (>= 7) might provide a 52-bit physical address
space when passing `max` as the `cpu` option. This information is found
in the `PARange` field of the `ID_AA64MMFR0_EL1` register.
When the Virtual Memory API is not enabled (i.e. the `CONFIG_PAGING`
macro is not set), the `T0SZ` field from the `TCR_EL1` register is set
up such that the VA space size matches the PA one. However, we
currently do not provide a 5-level paging scheme at all in order to
implement 52-bit virtual addresing, so we need to enforce 48-bit VA space
for PARange >= 52.
Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Michalis Pappas <michalis@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #729
These flags were not being applied to C++ source files. Add them to
`buildrule_cxx`. Also reorder compiler flags to be in line with C flags.
Signed-off-by: Tu Dinh Ngoc <dinhngoc.tu@irit.fr> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #845
support/scripts: Change the SECINFO_EXP regex to be more permissive
Currently, the regex for matching the .uk_bootinfo section does
not consider the case of the section having a number bigger than
99 as a result for objdump -h. This PR changes the regex to consider that case.
Signed-off-by: Florin Postolache <florin.postolache80@gmail.com> Reviewed-by: Dragos Petre <dragos.petre27@gmail.com> Approved-by: Marco Schlumpp <marco@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #792
As clone3 currently does not work, and glibc falls
back to clone if clone3 is not available (tested on 2.35),
the syscall can be removed until a working implementation is
available.
Signed-off-by: Ioan-Teodor Teugea <teodor.teugea@gmail.com> Reviewed-by: Florin Postolache <florin.postolache.of@gmail.com> Reviewed-by: Simon Kuenzer <simon@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #847
Andrei Tatar [Fri, 21 Apr 2023 14:42:48 +0000 (16:42 +0200)]
arch/x86: Add compiler flags for auto host CPU
Previously the `CONFIG_MARCH_X86_64_NATIVE` variable did not add
`-march=native` to CFLAGS, the compiler then defaulting to generic
x86_64. This implements the expected functionality.
Signed-off-by: Andrei Tatar <andrei.ttr@gmail.com> Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #861
Marc Rittinghaus [Thu, 20 Apr 2023 15:06:37 +0000 (17:06 +0200)]
lib/ukswrand: Adapt (u)random to new device_create
The signature and requirements of device_create() changed.
This commit adapts the implementations of /dev/random and
/dev/urandom to use the new definition.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855
Marc Rittinghaus [Thu, 20 Apr 2023 15:03:57 +0000 (17:03 +0200)]
lib/devfs: Adapt null/zero to new device_create
The signature and requirements of device_create() changed.
This commit adapts the implementations of /dev/null and
/dev/zero to use the new definition.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855
Marc Rittinghaus [Thu, 20 Apr 2023 14:59:25 +0000 (16:59 +0200)]
lib/devfs: Merge device_register and create
This commit merges the device_register() and device_create() functions
to safe a malloc() operation. The function is also changed to return
a proper error code instead of crashing. Furthermore, users of the
function are expected to provide a handler function for all device
operations. The early check via asserts ensures that missing handlers
are easily detected in debug builds without having to explicitly call
all device operations.
Checkpatch-Ignore: USE_NEGATIVE_ERRNO Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855
Marc Rittinghaus [Thu, 20 Apr 2023 14:47:45 +0000 (16:47 +0200)]
lib/devfs: Remove unused fields and functions
The definition for device objects contain numerous fields which are not
used. In addition, there are various function definitions and
declarations which are not used or not even related to generic devices
(e.g., partition table). This commit removes all of these definitions.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #855
Marc Rittinghaus [Thu, 20 Apr 2023 14:39:25 +0000 (16:39 +0200)]
lib/devfs: Remove unused devops
This commit removes unused operations from the device operations
structure and updates the no-op macros and functions to be usable
for seldomly set operations (also externally).
Marc Rittinghaus [Mon, 24 Apr 2023 15:21:15 +0000 (17:21 +0200)]
lib/vfscore: Fix leak in sys_futimens
Previously, sys_futimens() retrieved a reference to the file
descriptor to get a value for the pathname argument. The reference
was not freed afterwards. Since sys_utimensat() has been changed
to accept NULL as pathname and work on dirfd instead, the code
can be removed altogether.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Rares Miculescu <miculescur@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865
Marc Rittinghaus [Mon, 24 Apr 2023 15:12:07 +0000 (17:12 +0200)]
lib/vfscore: Exit sys_utimensat on all UTIME_OMIT
This commit restructures the sanity checks of the input timespecs
to come before all other checks and to include an early exit of
both times are UTIME_OMIT. This is inline with the behavior on
Linux.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Rares Miculescu <miculescur@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865
Marc Rittinghaus [Mon, 24 Apr 2023 14:57:21 +0000 (16:57 +0200)]
lib/vfscore: Remove surplus check and fix leak
The dedicated check for a readonly filesystem can be removed
in sys_utimensat(), because it is part of vn_access(). The commit
also fixes a leak of reference to the dentry in case of an error.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Rares Miculescu <miculescur@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865
Marc Rittinghaus [Mon, 24 Apr 2023 14:54:37 +0000 (16:54 +0200)]
lib/vfscore: Linux compatibility for sys_utimensat
Previously, if pathname is either NULL or a relative path, and
dirfd is not AT_FDCWD, dirfd needed to refer to a directory.
However, in Linux there is a non-conformant behavior that
if pathname is NULL, the timestamps are applied to whatever
file dirfd refers to. For improved Linux compatibility, we
adopt this behavior.
This commit also fixes various leaks of the file descriptor
reference that is received via the call to vfscore_get_file().
Github-Fixes: #858 Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Rares Miculescu <miculescur@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865
Marc Rittinghaus [Mon, 24 Apr 2023 14:19:25 +0000 (16:19 +0200)]
lib/vfscore: Fix error checks in sys_utimensat
If successful, asprintf() returns the number of characters written. Due
to the format strings this will always be >0. On error, asprintf()
returns -1, which means the return value will in any case be non-zero,
always leading to a (false) ENOMEM.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Rares Miculescu <miculescur@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865
Marc Rittinghaus [Mon, 24 Apr 2023 14:13:06 +0000 (16:13 +0200)]
lib/vfscore: Remove VAPPEND mode
vfscore defines a VAPPEND mode bit which is only used in
sys_utimensat() and which erroneously overlaps with VEXEC permission
for the group. While VAPPEND is a useful feature, it needs a proper
definition and support in all vfscore APIs. We thus remove the
broken definition for now.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Rares Miculescu <miculescur@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865
Marc Rittinghaus [Mon, 24 Apr 2023 06:59:28 +0000 (08:59 +0200)]
lib/vfscore: Check for EBADF in dup2
In contrast to dup3(), dup2() returns the oldfd if oldfd and newfd
are equal. However, the fd still needs to be valid. Otherwise, EBADF
has to be returned.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Rares Miculescu <miculescur@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865
Marc Rittinghaus [Mon, 24 Apr 2023 06:54:18 +0000 (08:54 +0200)]
lib/vfscore: Fix multiple issues with dup3
dup3() is broken in multiple ways:
1) the fget() for newfd leaks the the file reference before the close
2) the error code from close() is -1 instead of the errno value
3) the old file descriptor is duplicated to a new fd slot. However, its
reference is not incremented due to the fdrop().
4) there is a race condition between the close() of newfd and its
reservation for the to-be-duplicated file description
This commit fixes all these issues except the race condition, which
needs new functionality to atomically replace a file description in
the fd tab.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Rares Miculescu <miculescur@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #865
This attribute is useful for memory-mapped devices and can reduce the
amount of transactions necessary when communicating with the device.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Approved-by: Alexander Jung <alex@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #788
Marc Rittinghaus [Thu, 27 Apr 2023 10:38:16 +0000 (12:38 +0200)]
plat/common/x86: Add PAT MSR
This commit adds the definition of the page attribute table (PAT)
configuration MSR.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Approved-by: Alexander Jung <alex@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #788
Marc Rittinghaus [Thu, 27 Apr 2023 10:36:54 +0000 (12:36 +0200)]
include/arch/x86_64: Add PAT bits
This commit adds definitions for configuration of the page attribute
table on x86.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Approved-by: Alexander Jung <alex@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #788
Radu Nichita [Mon, 6 Mar 2023 14:06:14 +0000 (16:06 +0200)]
lib/vfscore: Add README.md file
Provides information about how to interact with the vfscore library,
including details about hierarchy, core components and registration
of a new filesystem in Unikraft.
Signed-off-by: Radu Nichita <radunichita99@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #780
Marco Schlumpp [Tue, 14 Feb 2023 14:02:17 +0000 (15:02 +0100)]
drivers/virtio: Fix interrupt flag check
The check used a bit-OR instead of a bit-AND to check whether the flag
is set.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #761
i.Pear [Wed, 29 Mar 2023 18:12:51 +0000 (02:12 +0800)]
build/Makefile: Force update UK_CONFIG
The builder uses $(UK_CONFIG) to generate files such as
$(KCONFIG_AUTOHEADER) in the build directory. When $(UK_CONFIG) changes,
these newly generated files will also be regenerated.
However, $(UK_CONFIG) may not remain consistent across multiple builds.
For example, in the following command sequence:
> make C=.config_kvm-x86_64
> make C=.config_linuxu-x86_64
> make C=.config_kvm-x86_64
During the first two builds, the configuration files in the build
directory will be regenerated. But when using the same configuration file
as the first time in the third build, because .config_kvm-x86_64 is not a
new version, the configuration files in the build directory will remain
the version of linuxu, which will cause the build to fail.
When using kraftkit, similar issues can also be reproduced. Executing
"kraft build --arch x86_64" twice, each time is in the order of linuxu,
kvm, and xen. When building linuxu for the second time, the configuration
files in the build directory are still the configuration of xen, which
also causes the build to fail.
This patch forces $(UK_CONFIG) to be recognized as updated, so that the
configuration files in the build directory are always updated. It has been
tested and can fix this issue.
Signed-off-by: Tianyi Liu <i.pear@outlook.com> Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #817
Marc Rittinghaus [Fri, 14 Apr 2023 14:14:00 +0000 (16:14 +0200)]
lib/syscall_shim: Add struct printing
This commit adds macros for printing selected members of
struct types in the prsyscall output just like strace. The PT_STRUCT
macro takes the struct's name to form a new parameter type name.
The PR_STRUCT macro prints the fields specified in the var args. Nested
printing of struct fields members is supported for structs pointers as
well as for embedded structs. Whenever fields that are usually pointers
(e.g., PT_CHARP or PT_STRUCT) are embedded, the `PT_SVAL` flag must
be specified.
Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836
Marc Rittinghaus [Fri, 14 Apr 2023 16:22:32 +0000 (18:22 +0200)]
lib/syscall_shim: Add 0x prefix to PT_HEX
Currently, it is hard to know if a value is a hexadecimal or decimal
number if there are no letters in the output. This commit adds the
hex prefix 0x to avoid the confusion.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836
Marc Rittinghaus [Fri, 14 Apr 2023 15:47:19 +0000 (17:47 +0200)]
lib/syscall_shim: Print PT_OUT only on success
Previously, we are printing buffers and output strings also when the
call fails. However, in that case it will usually contain no meaningful
value so we reduce trace output by just printing the buffer's target
address.
Checkpatch-Ignore: COMPLEX_MACRO
Checkpatch-Ignore: TRAILING_SEMICOLON
Checkpatch-Ignore: DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON
Checkpatch-Ignore: MULTISTATEMENT_MACRO_USE_DO_WHILE Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Approved-by: Simon Kuenzer <simon@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #836
Marco Schlumpp [Wed, 1 Feb 2023 13:42:17 +0000 (14:42 +0100)]
lib/posix-event: Add an empty implementation of ioctl to eventfd
The fcntl function will forward fcntl(O_NONBLOCK), to the
underlying vnode `ioctl` op function, when a definition of FIONBIO and
FIOASYNC is present. This effectively makes `ioctl` a required function
for the vnops structure.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #756
Eduard Vintilă [Sat, 11 Mar 2023 18:29:59 +0000 (20:29 +0200)]
lib/posix-event: Update `uio_offset` and `uio_resid` on successful reads
This commit updates (on a sucessful read) the `uio_offset` and
`uio_resid` members of the `uio` structure passed to the
`eventfd_vfscore_read` function. Without updating those members, the
`read` function from the vfscore layer will always report that no bytes
have been read at all.
Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com> Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io> Reviewed-by: Delia Pavel <delia_maria.pavel@stud.acs.upb.ro> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #798
Marc Rittinghaus [Wed, 12 Apr 2023 13:22:54 +0000 (15:22 +0200)]
lib/9pfs: Add truncate to 9P_PROTO_2000U
When providing a length in the stat structure the 9pfs server on the
host will truncate the file to the specified size. We use this to also
enable truncation for the 2000U protocol version. Since uk_9pfs_setattr
checks for the protocol to use, the check can be completely dropped in
uk_9pfs_truncate.
Marc Rittinghaus [Wed, 12 Apr 2023 13:14:56 +0000 (15:14 +0200)]
lib/9pfs: Fix I/O error with chmod on directories
When we perform a chmod on a directory with the 9P_PROTO_2000U
protocol, the TWSTAT command is used with a previously received and
modified stat structure as parameter. There are two bugs in this.
First, updating the mode will remove the type information stored in the
high bits of the mode field. The call to the 9pfs device thus fails because
the 9pfs server thinks we want to change the directory to a regular
file.
Fixing this, will reveal another issue. The update should use a
specifically initialized "dont-touch" stat structure instead of
receiving the current structure. The 9pfs server will only update
the properties that divert from this "dont-touch" structure. This
is important because otherwise the length field of the stat
structure is set and the server tries to truncate the directory
object on the host, which fails and eventually will be reported
as failed chmod to the guest application.
Marc Rittinghaus [Wed, 12 Apr 2023 12:55:03 +0000 (14:55 +0200)]
lib/uksglist: Make sure buffers are mapped
With ukvmem and demand-paging enabled it can happen that buffers
supplied to the sglist are not fully backed by physical memory. In that
case the call to ukplat_virt_to_phys() fails, which expects a valid
mapping.
This commit adds a call to uk_vma_advise() to make sure the entire
buffer is backed by physical memory.
A future optimization should integrate the address translation and
backing with physical memory in a visitor pattern that traverses the
page tables only once instead of doing it one time for the advise and
then an extra time for each page of the buffer.
Marco Schlumpp [Thu, 9 Feb 2023 11:28:50 +0000 (12:28 +0100)]
plat/x86: Enable NX bit when initializing paging
There are a few reasons to enable the NX bit in the paging init routine:
* Setting the bit before checking for actual support is risky.
Currently, the check happens in the paging initialization routine.
* The bit is not used, when the Unikraft paging support is not enabled.
* Every boot entry point (32-bit/64-bit) would have a duplicated enable.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Florin Postolache <florin.postolache80@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #752
The issue #821 was caused by defining the feature macro `_BSD_SOURCE` in
a header file `include/vfscore/mount.h`. This commit moves the macro
from the header to its source files, resolving the issue.
Marco Schlumpp [Thu, 9 Feb 2023 14:46:02 +0000 (15:46 +0100)]
lib/ukalloc: Ensure the ifpages metadata does not break any alignments
By using the rounded version of the metadata size, we can ensure that
the resulting alignments are suitable for any C scalar type. This is a
requirement for any malloc implementation.
Signed-off-by: Marco Schlumpp <marco@unikraft.io> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #757
Marc Rittinghaus [Thu, 20 Apr 2023 07:49:02 +0000 (09:49 +0200)]
lib/vfscore: Enable FIONBIO in fcntl(F_SETFL)
Currently, we are synching FIONBIO to the underlying file
implementation via an ioctl only if FIONBIO is defined in
vfscore. Since this is not the case, setting O_NONBLOCK on
a file descriptor does not have any effect. This commit
includes the necessary header and also fixes the
fcntl(F_SETFL) and ioctl() to make sure that the state of
the file stays in sync with its flags.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #850
Marc Rittinghaus [Thu, 20 Apr 2023 07:12:35 +0000 (09:12 +0200)]
lib/nolibc: Fix ioctl signature
The signature of ioctl imported from musl uses a signed int as second
argument. This, however, differs from the definition in Linux, glibc,
and our own implementation, which use an unsigned long. Since using
int has lead to all sorts of problems also for musl (e.g., overflow into
sign bit), this commit adopts unsigned long also for the musl imported
header.
Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io> Reviewed-by: Andra Paraschiv <andra@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Razvan Deaconescu <razvand@unikraft.io> Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #850