]> xenbits.xensource.com Git - unikraft/unikraft.git/log
unikraft/unikraft.git
3 years agoRegister test.ld usoc21
Vlad-Andrei Badoiu [Sun, 29 Aug 2021 18:15:47 +0000 (21:15 +0300)]
Register test.ld

3 years agolib/uktest: Add methods for retrieving stats about tests
Alexander Jung [Mon, 23 Aug 2021 12:58:18 +0000 (14:58 +0200)]
lib/uktest: Add methods for retrieving stats about tests

This commit introduces minimal statistic retrieval within
`uktest` such that we can count the number of failed assertions,
cases and suites.  This commit also introduces a mechanism to
print these statistics at the last possible moment from the
`inittab` and thus the last possible moment a suite can be
registered.

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
3 years agolib/uktest: Add helper assertion methods
Alexander Jung [Mon, 23 Aug 2021 12:13:36 +0000 (14:13 +0200)]
lib/uktest: Add helper assertion methods

This commit provides the following additional extended
assertion helper methods in order to standardise the output:

 * `UK_TEST_EXPECT`
 * `UK_TEST_EXPECT_NULL`
 * `UK_TEST_EXPECT_NOT_NULL`
 * `UK_TEST_EXPECT_ZERO`
 * `UK_TEST_EXPECT_NOT_ZERO`
 * `UK_TEST_EXPECT_PTR_EQ`
 * `UK_TEST_EXPECT_BYTES_EQ`
 * `UK_TEST_EXPECT_SNUM_EQ`
 * `UK_TEST_EXPECT_SNUM_NQ`
 * `UK_TEST_EXPECT_SNUM_GT`
 * `UK_TEST_EXPECT_SNUM_GE`
 * `UK_TEST_EXPECT_SNUM_LT`
 * `UK_TEST_EXPECT_SNUM_LE`

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
3 years agolib/uktest: Provide multi boot-level registration of test suites
Alexander Jung [Thu, 27 May 2021 19:59:49 +0000 (21:59 +0200)]
lib/uktest: Provide multi boot-level registration of test suites

This commit introduces a minimal implementation testing
infastructure into Unikraft.  The primary contents includes the
definition of a test (or suite of tests) and the mechanism by
which one can use to register the suite to be run.

In `uktest`, tests are organised hierarchically powered by the
the lowest common denominator: the assertion.  This organisation
is inspired by KUnit[0], the Linux Kernel's in-house testing
system.  For licensing reasons the Unikraft project cannot use
this source code.  However, by inspiration, we can organise the
`uktest` library following a similar pattern:

 1. The assertion: repersents the lowest common denominator of a
    test: some boolean operation which, when true, a single test
    passes.  Assertions are often used in-line and their usage
    should be no different to the traditional use of the `ASSERT`
    macro.  In this commit, we introduce a new definition:
    `UK_TEST_ASSERT` which has two parameters: a reference to the
    test case (see 2.) and the boolean opeation which is
    true-to-form of the traditional `ASSERT` macro: some boolean
    expresson.  This commit extends this functionality to simply
    note when this assertion has failed and to print
    contextualised information about it.

 2. The test case: often, assertions are not alone in their means
    to check the legitimacy of operation in some function.  We
    find that a "case" is best way to organise a group of
    assertions in which one particular function of some system is
    under-going testing.  A case is independent of other cases,
    but related in the same sub-system.  For this reason we
    register them together.

 3. The test suite: represents a group of test cases.  This is
    the final and upper-most heirarchical repesentation of tests
    and their groupings.  With assertions grouped into test cases
    and test cases grouped into a test suite, we end this
    organisation in a fashion which allows us to follow a common
    design pattern within Unikraft: the registration model.  The
    syntax follows similar to other registation models within
    Unikraft, e.g. `ukbus`.  However, `uktest`'s registation
    model is more powerful (see Test Execution).

To register a test suite with `uktest`, we simply invoke
`uk_testsuite_register` with an initialized `struct uk_testsuite`
variable.  This structure contains an initialized list of `struct
uk_testcase`s.  Each test case has only one input parameter: a
reference to the current case which each assertion handles during
its conditional check:

```c
UK_TESTCASE(testsuite1, some_test_case)
{
int x = 1;
UK_TEST_ASSERT(x > 0);
}

uk_testsuite_register(testsuite1, NULL);
```

The above snippet can be organised within a library in a number
of ways such as in-line or as an individual file representing the
suite.  There are a number of test suite registration handles
which are elaborated on in next section.  It should be noted that
multiple test suites can exist within a library in order to test
multiple features or components of said library.

In order to achieve consistency in the use of `uktest` across the
Unikraft code base, the following recommendation is made
regarding the registration of test suites:

 1. A single test suite should be organised into its own file,
    prefixed with `test_`, e.g. `test_feature.c`. All tests
    suites of some library within Unikraft should be stored
    within a new folder located at the root of the library named
    `tests/`.
 2. All tests suites should have a corresponding KConfig option,
    prefixed with the library name and then the word "TEST", e.g.
    `LIBNAME_TEST_`.
 3. Every library implementing one or more suite of tests must
    have a new menuconfig housing all test suite options under
    the name `LIBNAME_TEST`.  This menuconfig option must invoke
    all the suites if `LIBUKTEST_ALL` is set to true.

`uktest`'s registation model allows for the execution of tests
at different levels of the boot process.  All tests occur before
the invocation of the application's `main` method.  This is done
such that the validity of the kernel-space functions can be
legitimised before actual application code is invoked.  A fail-
fast option is provided in order to crash the kernel in case of
failures for earlier error diagnosis.

When registering a test suite, one can hook into either the
constructor "`ctor`" table or initialisation table "`inittab`".
This allows for running tests before or after certain libraries
or sub-systems are invoked during the boot process.

The following registation methods are available from this commit:

 * `uk_testsuite_early_prio`,
 * `uk_testsuite_plat_prio`,
 * `uk_testsuite_lib_prio`,
 * `uk_testsuite_rootfs_prio`,
 * `uk_testsuite_sys_prio`,
 * `uk_testsuite_late_prio` (default),
 * `uk_testsuite_prio`, and
 * `uk_testsuite_register`.

[0]: https://kunit.dev

Checkpatch-Ignore: MACRO_WITH_FLOW_CONTROL
Checkpatch-Ignore: COMPLEX_MACRO
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
3 years agolib/uktest: Introduce library skeleton
Alexander Jung [Thu, 27 May 2021 18:31:17 +0000 (20:31 +0200)]
lib/uktest: Introduce library skeleton

The `uktest` library has a dependency to `nolib`/`newlib` and to
`ukdebug` in order to function and to output test information,
respectively.  The symbols exported will be provided by the `test.c`.

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
3 years agobuild: Add embedded rust support
Vlad-Andrei Badoiu [Sun, 27 Jun 2021 22:26:47 +0000 (01:26 +0300)]
build: Add embedded rust support

This patch adds embedded rust support. Only the core crate
is available. Internal libraies may be written in rust now.
We're using rustc as a rust compiler. The compilation flags
are different from GCC and thus we introduce new flags for
rust sources such as as a -Copt_lvl="2". LTO is available
only when using the clang toolchain for C/C++ sources.
DCE is available and done at linking.
The sources should have #![no_std] and a panic handler, e.g:

```
use core::panic::PanicInfo;

fn panic(_info: &PanicInfo) -> ! {
    loop {}
}
```

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #241

3 years agobuild: Add LLVM_TARGET_ARCH
Vlad-Andrei Badoiu [Wed, 30 Jun 2021 21:09:56 +0000 (00:09 +0300)]
build: Add LLVM_TARGET_ARCH

Rustc uses the LLVM format for specifying the cross
compiler target: <arch><sub>-<vendor>-<sys>-<abi>.
This is different from GCC, in order to not have
to mantain a translation script, we provide the user
with an option to specify himself the target via
LLVM_TARGET_ARCH which is similar to CROSS_COMPILE.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #241

3 years agolib/ukdebug: Fix overrun in outf for OUTDEV_BUFFER
Marc Rittinghaus [Thu, 17 Jun 2021 17:07:13 +0000 (19:07 +0200)]
lib/ukdebug: Fix overrun in outf for OUTDEV_BUFFER

This patch fixes two bugs:
1) The return value of vsnprintf does not include the null-terminator.
Subtracting one is thus not necessary.
2) In case the buffer is too small, vsnprintf returns the number of
characters that would have been written if the buffer had
enough space. The return value must therefore be tested against
the remaining buffer space.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #232

3 years agobuild: Move GO build rules in the libgo repo
Vlad-Andrei Badoiu [Thu, 29 Jul 2021 12:28:14 +0000 (15:28 +0300)]
build: Move GO build rules in the libgo repo

Since we cannot add GO sources without the libgo external library,
we move the buildrules_go to the libgo library, in a library specific
Makefile.rules

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #258

3 years agoplat/kvm/x86: Fix lost IRQs
Marc Rittinghaus [Wed, 14 Jul 2021 15:32:11 +0000 (17:32 +0200)]
plat/kvm/x86: Fix lost IRQs

There is a race condition in `ukplat_lcpu_halt_irq()`, where an IRQ
may fire in between the short window after which interrupts are
enabled and before the halt is done. This may halt the caller
forever (or much longer until the next interrupt).

As this issue is platform and architecture specific, this commit
moves `ukplat_lcpu_halt_irq()` from the common code to the
plat/arch-specific implementation. For x86 the race condition
is avoided by ensuring that there are no instructions between
`STI` and `HLT`.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #257

3 years ago.gitignore: Do not ignore the .github directory
Alexander Jung [Wed, 14 Jul 2021 17:38:04 +0000 (19:38 +0200)]
.gitignore: Do not ignore the .github directory

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #256

3 years ago.github: Add issue template configuration
Alexander Jung [Wed, 14 Jul 2021 17:43:19 +0000 (19:43 +0200)]
.github: Add issue template configuration

This file configures the issue template page on Github, providing
additional contact information as well as disabling the ability to
open a blank template.

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #256

3 years ago.github: Introduce pull request template
Alexander Jung [Wed, 14 Jul 2021 17:12:06 +0000 (19:12 +0200)]
.github: Introduce pull request template

This commit introduces a new Github-centric configuration file which
provides a template during the Pull Request process.  When a new PR
is opened, this template will appear in the PR text body.  More
information can be found on this template at [0].

[0]: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates#pull-request-templates

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #256

3 years ago.github: Introduce 'project backlog' issue template
Alexander Jung [Wed, 14 Jul 2021 16:56:50 +0000 (18:56 +0200)]
.github: Introduce 'project backlog' issue template

This commit introduces a Github-centric configuration file which
provides a template during the creation of a new issue.  This file
is used to help with defining a feature request or "project
backlog" issue submitted to the Unikraft core repository.  More
information about issue templates can be found at [0].

[0]: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates#issue-templates

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #256

3 years ago.github: Introduce 'bug report' issue template
Alexander Jung [Wed, 14 Jul 2021 11:19:48 +0000 (13:19 +0200)]
.github: Introduce 'bug report' issue template

This commit introduces a Github-centric configuration file which
provides a template during the creation of a new issue.  This file
is used to help with defining a bug report submitted to the Unikraft
core repository.  More information about issue templates can be found
at [0].

[0]: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/about-issue-and-pull-request-templates#issue-templates

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #256

3 years ago.github: Introduce CODEOWNERS and drop MAINTAINERS.md
Alexander Jung [Wed, 14 Jul 2021 10:44:57 +0000 (12:44 +0200)]
.github: Introduce CODEOWNERS and drop MAINTAINERS.md

This commit introduces a new file, `CODEOWNERS`, which acts as a
replacement for `MAINTAINERS.md`.  This file is used by Github to
protect directories and files as well as help with automatic
assignments for incoming PRs.  More information on the
`CODEOWNERS` file can be found here[0].

[0]: https://help.github.com/articles/about-codeowners/

Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #256

3 years agobuild: Extra compile flags from command line
Hugo Lefeuvre [Wed, 14 Jul 2021 09:48:53 +0000 (11:48 +0200)]
build: Extra compile flags from command line

Additional flags can now be passed to the compiler via environment
variables, e.g., CFLAGS_EXTRA in the case of C:

    make CFLAGS_EXTRA="-DSOME_MACRO=0"

Update the documentation as well.

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #255

3 years agobuild: fetch: Support checksum checks
Simon Kuenzer [Thu, 15 Apr 2021 21:40:59 +0000 (23:40 +0200)]
build: fetch: Support checksum checks

This commit introduces the support for comparing the checksum of a
downloaded archive with `fetch`, `fetch2`, `fetchas`, and `fetchas2`.
It computes and compares the checksum with the library-local variables
within a `Makefile.uk` when given:
 LIBNAME_ORIGIN_[MD5|SHA1|...].
Please note that this variable needs to be defined
before calling `fetch`, `fetch2`, `fetchas`, or `fetchas2`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #181

3 years agobuild: fetch: Support second URL as download source
Simon Kuenzer [Fri, 9 Apr 2021 09:58:38 +0000 (11:58 +0200)]
build: fetch: Support second URL as download source

Introduces `fetch2` and `fetchas2`, two build system commands that
work like `fetch` and `fetchas` but support a secondary URL to download
archives from. The secondary URL is used when the download failed
with the primary URL.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #181

3 years agoplat/common: Fix cache policy MAIR definitions
Michalis Pappas [Thu, 12 Sep 2019 08:35:31 +0000 (10:35 +0200)]
plat/common: Fix cache policy MAIR definitions

Fix transposed cache attributes in MAIR_ATTR for ARM64

Signed-off-by: Michalis Pappas <Michalis.Pappas@opensynergy.com>
Acked-by: Renê de Souza Pinto <Rene.deSouzaPinto@opensynergy.com>
Reviewed-by: Răzvan Vîrtan <virtanrazvan@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #170

3 years agolib/ukallocpool: Remove unused `obj_init_t` type
Simon Kuenzer [Mon, 5 Jul 2021 10:44:14 +0000 (12:44 +0200)]
lib/ukallocpool: Remove unused `obj_init_t` type

Removes the unused type definition `uk_allocpool_obj_init_t`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #248

3 years agolib/ukallocpool: Use Unikraft internal types
Simon Kuenzer [Mon, 5 Jul 2021 10:43:28 +0000 (12:43 +0200)]
lib/ukallocpool: Use Unikraft internal types

Use Unikraft-internal types in order to avoid any conflict with
libc definitions. This was originally done with commit
ed1ef9aef but `lib/ukallocpool` was forgotten.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #248

3 years agolib/vfscore: Add support to mount initramfs to root
Alexander Jung [Mon, 12 Apr 2021 10:43:26 +0000 (12:43 +0200)]
lib/vfscore: Add support to mount initramfs to root

Modify vfscore boot operation to run cpio extraction algorithm on initrd
memory region and mount the resulting filesystem at root.

Signed-off-by: Robert Hrusecky <roberth@cs.utexas.edu>
Signed-off-by: Omar Jamil <omarj2898@gmail.com>
Signed-off-by: Sachin Beldona <sachinbeldona@utexas.edu>
Signed-off-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #179

3 years agoplat/linuxu: Add initrd memory region
Alexander Jung [Mon, 12 Apr 2021 10:42:27 +0000 (12:42 +0200)]
plat/linuxu: Add initrd memory region

Add a new library parameter (initrd_file). The parameter can be used to
map a file on the host filesystem to to a new memory region on boot.

Signed-off-by: Robert Hrusecky <roberth@cs.utexas.edu>
Signed-off-by: Omar Jamil <omarj2898@gmail.com>
Signed-off-by: Sachin Beldona <sachinbeldona@utexas.edu>
Signed-off-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Checkpatch-Ignore: INITIALISED_STATIC
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #179

3 years agoplat/linuxu: Add fstat, open and close host system calls
Alexander Jung [Mon, 12 Apr 2021 10:39:59 +0000 (12:39 +0200)]
plat/linuxu: Add fstat, open and close host system calls

 * Add system call number for arm_32 and x86_64 for the `fstat`
   system call;
 * Implement system call wrapper function for `open`, `close` and
   `fstat`;
 * Add `MAP_PRIVATE` constant for use with `mmap`.

Signed-off-by: Robert Hrusecky <roberth@cs.utexas.edu>
Signed-off-by: Omar Jamil <omarj2898@gmail.com>
Signed-off-by: Sachin Beldona <sachinbeldona@utexas.edu>
Signed-off-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #179

3 years agolib/ukcpio: Add CPIO extraction functionality
Alexander Jung [Mon, 12 Apr 2021 10:38:24 +0000 (12:38 +0200)]
lib/ukcpio: Add CPIO extraction functionality

Modeled after the FreeBSD libarchive:
https://github.com/freebsd/freebsd/blob/master/contrib/libarchive/libarchive/archive_read_support_format_cpio.c

The implementation is mostly complete except that it does not yet
support symlinks.

Signed-off-by: Robert Hrusecky <roberth@cs.utexas.edu>
Signed-off-by: Omar Jamil <omarj2898@gmail.com>
Signed-off-by: Sachin Beldona <sachinbeldona@utexas.edu>
Signed-off-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #179

3 years agolib/ukcpio: Create empty CPIO extraction library
Alexander Jung [Mon, 12 Apr 2021 09:21:39 +0000 (11:21 +0200)]
lib/ukcpio: Create empty CPIO extraction library

Information about the CPIO file format can be found here:
https://www.kernel.org/doc/Documentation/early-userspace/buffer-format.txt

Signed-off-by: Robert Hrusecky <roberth@cs.utexas.edu>
Signed-off-by: Omar Jamil <omarj2898@gmail.com>
Signed-off-by: Sachin Beldona <sachinbeldona@utexas.edu>
Signed-off-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #179

3 years agoplat/arm64: Fix extregs allocation on Arm
Jia He [Fri, 14 May 2021 01:21:12 +0000 (09:21 +0800)]
plat/arm64: Fix extregs allocation on Arm

Implement the extregs (currently only fpsimd registers) allocation
related helpers. Otherwise, Unikraft can't be built on Arm kvm plat
due to the missing of several helpers.

Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Răzvan Vîrtan <virtanrazvan@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #206

3 years agoplat/common: Add invalidate_dcache_range for arm64
Michalis Pappas [Wed, 17 Feb 2021 10:52:04 +0000 (11:52 +0100)]
plat/common: Add invalidate_dcache_range for arm64

Introduces an additional cache maintenance function that invalidates
cache without cleaning. This is useful when reading memory updated
from a different core, after turning on the caches.

Signed-off-by: Michalis Pappas <Michalis.Pappas@opensynergy.com>
Reviewed-by: Răzvan Vîrtan <virtanrazvan@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #171

3 years agoplat/kvm: Provide udelay and mdelay implementations
cristian-vijelie [Wed, 30 Jun 2021 16:22:30 +0000 (19:22 +0300)]
plat/kvm: Provide udelay and mdelay implementations

The delay functions are required by the SMP module and can be used in
places where setting up a timer in not worth the effort or cannot be
safely done (e.g., early boot code, drivers).

Signed-off-by: cristian-vijelie <cristianvijelie@gmail.com>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #184

3 years agoplat/kvm: Fix ACPI entry in Makefile.uk
cristian-vijelie [Wed, 30 Jun 2021 16:21:37 +0000 (19:21 +0300)]
plat/kvm: Fix ACPI entry in Makefile.uk

Signed-off-by: cristian-vijelie <cristianvijelie@gmail.com>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #184

3 years agoplat/ukplatkvm: Provide ACPI structures and functionalities
cristian-vijelie [Fri, 25 Jun 2021 16:08:22 +0000 (19:08 +0300)]
plat/ukplatkvm: Provide ACPI structures and functionalities

Signed-off-by: cristian-vijelie <cristianvijelie@gmail.com>
Reviewed-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #183

3 years agolib/ukboot: add bindings for tinyalloc allocator
Hugo Lefeuvre [Fri, 25 Jun 2021 11:17:23 +0000 (13:17 +0200)]
lib/ukboot: add bindings for tinyalloc allocator

This commits allows users to select tinyalloc as default system
allocator. Previously users had to patch the main tree to achieve this.

This is the tinyalloc counter part of 4b31168 (Mimalloc).

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #238

3 years agolib/syscall_shim: Adjust the sign of `errno` to be positive
Sergiu Moga [Tue, 22 Jun 2021 09:35:05 +0000 (12:35 +0300)]
lib/syscall_shim: Adjust the sign of `errno` to be positive

Ensure that `errno` is assigned the positive value of what the raw
system calls return.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #236

3 years agolib/ukboot: add bindings for Mimalloc allocator
Hugo Lefeuvre [Fri, 25 Jun 2021 08:28:28 +0000 (10:28 +0200)]
lib/ukboot: add bindings for Mimalloc allocator

This commits allows users to select Mimalloc as default system
allocator. Previously users had to patch the main tree to achieve this.
While adding more an more "hardcoded" allocators like this is certainly
not a long term solution, this is the only one we have for now.

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #237

3 years agolib/ukalloc: per-library stats: Return ENOMEM
Simon Kuenzer [Mon, 23 Nov 2020 12:10:58 +0000 (13:10 +0100)]
lib/ukalloc: per-library stats: Return ENOMEM

THe per-library wrapper returns ENOMEM instead of failing in an assertions
when the default allocator is not yet initialized.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/nolibc: Enable per-library allocator statistics
Simon Kuenzer [Tue, 17 Nov 2020 16:28:33 +0000 (17:28 +0100)]
lib/nolibc: Enable per-library allocator statistics

Instruments <stdlib.h> so that per-library allocator statistics are
possible. We make sure that libraries using `malloc()`, `free()`, and
company will resolve `uk_alloc_get_default()` within their scope so that
the individual wrapper allocators can be used.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Use Unikraft internal types
Simon Kuenzer [Tue, 17 Nov 2020 16:27:19 +0000 (17:27 +0100)]
lib/ukalloc: Use Unikraft internal types

Use Unikraft-internal types for the API headers in order to have minimal
dependency to libc definitions. This is done so that libcs can integrate
`<uk/alloc.h> directly with their header files without breaking the
declaration set of libc headers.
This is done towards receiving per-library statistics
(see the following commit).

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Iterator for per-library statistics
Simon Kuenzer [Tue, 17 Nov 2020 15:48:24 +0000 (16:48 +0100)]
lib/ukalloc: Iterator for per-library statistics

Provides the `uk_alloc_foreach_libstats()` helper macro that can be used
to iterate over the available library allocator statistics.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Per-library allocation statistics
Simon Kuenzer [Thu, 12 Nov 2020 23:20:12 +0000 (00:20 +0100)]
lib/ukalloc: Per-library allocation statistics

Per-library allocation statistics is achieved by replacing the default
allocator for each library with a wrapper. This wrapper forwards operations
to the actual default allocator while recording changes of the statistics
caused by the operations.
Some statistic counters are updated to support signed values (e.g.,
current memory usage or current number of allocations). This is
needed to cover cases where, for instance, a library A is allocating while
a library B is freeing.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukallocpool: Instrumentation for statistics
Simon Kuenzer [Tue, 22 Dec 2020 12:56:32 +0000 (13:56 +0100)]
lib/ukallocpool: Instrumentation for statistics

Instruments the allocator to record allocation statistics.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukallocregion: Instrumentation for statistics
Simon Kuenzer [Thu, 12 Nov 2020 23:17:37 +0000 (00:17 +0100)]
lib/ukallocregion: Instrumentation for statistics

Instruments the allocator to record allocation statistics.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukallocregion: Internal functions as `static`
Simon Kuenzer [Thu, 12 Nov 2020 15:54:50 +0000 (16:54 +0100)]
lib/ukallocregion: Internal functions as `static`

Declares internal functions as static in order to enable potentially
more aggressive optimizations by the compiler.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukallocbbuddy: Instrumentation for statistics
Simon Kuenzer [Thu, 12 Nov 2020 23:16:37 +0000 (00:16 +0100)]
lib/ukallocbbuddy: Instrumentation for statistics

Instruments the allocator to record allocation statistics.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Global statistics
Simon Kuenzer [Thu, 12 Nov 2020 23:12:15 +0000 (00:12 +0100)]
lib/ukalloc: Global statistics

Provides a configuration option that collects a consolidated global
statistic over all allocators.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Allocator statistics
Simon Kuenzer [Thu, 12 Nov 2020 16:24:30 +0000 (17:24 +0100)]
lib/ukalloc: Allocator statistics

This commit introduces an implementation for the configuration option
`LIBUKALLOC_IFSTATS`. When enabled, allocators keep allocation statistics,
like number of current allocations, maximum memory usage due to
allocations, or how often ENOMEM was returned.
The statistics are kept on the `uk_alloc` struct while the instrumentation
of an allocator is minimal: An allocator has only to be modified with
the following macros:
 - `uk_alloc_stats_count_alloc()`, `uk_alloc_stats_count_palloc()`
 - `uk_alloc_stats_count_free()`, `uk_alloc_stats_count_pfree()`
 - `uk_alloc_stats_count_enomem()`, `uk_alloc_stats_count_penomem()`
Current statistics can be queried with `uk_alloc_stats()`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Introduce `uk_alloc_availmem_total(), `uk_alloc_pavail_total()`
Simon Kuenzer [Thu, 12 Nov 2020 16:13:36 +0000 (17:13 +0100)]
lib/ukalloc: Introduce `uk_alloc_availmem_total(), `uk_alloc_pavail_total()`

This commit introduces helper functions to retrieve the total available
memory of all registered allocators. In case an allocator does not support
querying the amount of free memory, it is considered as 0 bytes free for
this particular allocator.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Iterator helper for allocators
Simon Kuenzer [Thu, 12 Nov 2020 16:11:00 +0000 (17:11 +0100)]
lib/ukalloc: Iterator helper for allocators

This commit provides `uk_alloc_foreach()`, a helper macro for
iterating over all registered allocators.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Cross-compatibility wrappers for "free memory" APIs
Simon Kuenzer [Thu, 12 Nov 2020 16:10:03 +0000 (17:10 +0100)]
lib/ukalloc: Cross-compatibility wrappers for "free memory" APIs

This commit provides cross compatibility wrappers between page and non-page
allocators: `uk_alloc_availmem()`, `uk_alloc_maxalloc()`,
`uk_alloc_pavailmem()`, and `uk_alloc_pmaxalloc()`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Introduce `uk_alloc_pavailmem()`, `uk_alloc_pmaxalloc()`
Simon Kuenzer [Thu, 12 Nov 2020 16:06:10 +0000 (17:06 +0100)]
lib/ukalloc: Introduce `uk_alloc_pavailmem()`, `uk_alloc_pmaxalloc()`

This commit introduces
- `uk_alloc_pavailmem()` as an equivalent for `uk_alloc_availmem()`
  for page allocators.
- `uk_alloc_pmaxalloc()` as an equivalent for `uk_alloc_maxalloc()`
  for page allocators.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Introduce `uk_alloc_maxalloc()` and make `uk_alloc_availmem()` available
Simon Kuenzer [Thu, 12 Nov 2020 15:52:53 +0000 (16:52 +0100)]
lib/ukalloc: Introduce `uk_alloc_maxalloc()` and make `uk_alloc_availmem()` available

The purpose of this commit is to make `uk_alloc_availmem()` always
available because it is currently the only way to figure out how much heap
memory is still available. We also introduce `uk_alloc_maxalloc()` that
returns the biggest possible allocation that an allocator can currently
satisfy. The configuration option `CONFIG_IFSTAT` is removed because it
raises the expectation of an interface that returns detailed allocator
statistics.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Move `uk_zalloc()` after `uk_calloc()`
Simon Kuenzer [Thu, 12 Nov 2020 15:27:03 +0000 (16:27 +0100)]
lib/ukalloc: Move `uk_zalloc()` after `uk_calloc()`

Moves `uk_zalloc()` to a more appropriate location within the
`<uk/alloc.h> header.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: `extern C {}` at the beginning of <uk/alloc.h>
Simon Kuenzer [Thu, 12 Nov 2020 15:26:04 +0000 (16:26 +0100)]
lib/ukalloc: `extern C {}` at the beginning of <uk/alloc.h>

`<uk/alloc.h>`: Move the type `struct uk_alloc` declaration into the
C code block.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agolib/ukalloc: Move ifpages comment
Simon Kuenzer [Thu, 12 Nov 2020 15:24:41 +0000 (16:24 +0100)]
lib/ukalloc: Move ifpages comment

Moves the comment about the ifpages implementation within `alloc.c`
to the correct place.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #229

3 years agoplat/common/x86: Fix control protection trap
Marc Rittinghaus [Mon, 14 Jun 2021 09:47:16 +0000 (11:47 +0200)]
plat/common/x86: Fix control protection trap

The current trap number for the control protection exception (in
Unikraft called security trap) is wrong and the asm trap is missing. This
patch fixes these issues.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #228

3 years agoplat/xen: x86: Detect initrd entry from start_info
Simon Kuenzer [Thu, 1 Oct 2020 12:43:25 +0000 (14:43 +0200)]
plat/xen: x86: Detect initrd entry from start_info

Registers an init ramdisk as memory region.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Mocanu Gabriel<gabi.mocanu98@gmail.com>
3 years agodocs: Update version to 0.5.0
Simon Kuenzer [Thu, 20 May 2021 22:34:16 +0000 (00:34 +0200)]
docs: Update version to 0.5.0

Bump the version number within the documentation to 0.5.0:
`docs/` and `README.md`

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #214

3 years agolib/vfscore: Register `newfstatat` to syscall_shim
Sergiu Moga [Sat, 24 Apr 2021 17:27:25 +0000 (20:27 +0300)]
lib/vfscore: Register `newfstatat` to syscall_shim

Register `newfstatat` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #190

3 years agolib/vfscore: Register `getdents` to syscall_shim
Sergiu Moga [Thu, 22 Apr 2021 16:49:28 +0000 (19:49 +0300)]
lib/vfscore: Register `getdents` to syscall_shim

Register `getdents` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Laurentiu Barbulescu <lrbarbulescu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #189

3 years agolib/vfscore: Register `chroot` to syscall_shim
Sergiu Moga [Tue, 16 Mar 2021 21:25:57 +0000 (23:25 +0200)]
lib/vfscore: Register `chroot` to syscall_shim

Register `chroot` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Laurentiu Barbulescu <lrbarbulescu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #158

3 years agolib/uksched: Enable multiple `UK_THREAD_INIT()` in one source
Simon Kuenzer [Thu, 6 May 2021 13:03:11 +0000 (15:03 +0200)]
lib/uksched: Enable multiple `UK_THREAD_INIT()` in one source

In order to enable multiple UK_THREAD_INIT(_PRIO) definitions within
one source file, we generate file-unique symbol names for each entry
by using the priority level, init function name, and fini function name.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #201

3 years agolib/uksched: Remove unnecessary alignment for thread inittab
Simon Kuenzer [Thu, 6 May 2021 13:02:35 +0000 (15:02 +0200)]
lib/uksched: Remove unnecessary alignment for thread inittab

The align parameter within `extra.ld` for the `uk_thread_inttab` was
causing some alignment issues for the `text` section. Some builds
were not able to be executed. It turns out that this extra alignment
statement is not needed for the table.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #201

3 years agolib/vfscore: Register `unlink` to syscall_shim
Sergiu Moga [Mon, 15 Feb 2021 17:47:45 +0000 (19:47 +0200)]
lib/vfscore: Register `unlink` to syscall_shim

Register `unlink` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Florin Diaconescu <florin.diaconescu@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #132

3 years agolib/vfscore: Register `symlink` to syscall_shim
Sergiu Moga [Mon, 15 Feb 2021 17:53:13 +0000 (19:53 +0200)]
lib/vfscore: Register `symlink` to syscall_shim

Register `symlink` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Florin Diaconescu <florin.diaconescu@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #133

3 years agolib/vfscore: Register `pipe2` to syscall_shim
Sergiu Moga [Mon, 15 Feb 2021 18:14:49 +0000 (20:14 +0200)]
lib/vfscore: Register `pipe2` to syscall_shim

Register `pipe2` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Florin Diaconescu <florin.diaconescu@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #134

3 years agolib/vfscore: Register `umount2` to syscall_shim
Sergiu Moga [Mon, 15 Feb 2021 10:28:36 +0000 (12:28 +0200)]
lib/vfscore: Register `umount2` to syscall_shim

Register `umount2` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Cristian Vijelie <cristianvijelie@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #127

3 years agolib/ukmmap: Register `mremap` to syscall_shim
Sergiu Moga [Tue, 16 Mar 2021 20:49:39 +0000 (22:49 +0200)]
lib/ukmmap: Register `mremap` to syscall_shim

Register `mremap` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Cristian Vijelie <cristianvijelie@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #155

3 years agolib/vfscore: Register `mkdir` to syscall_shim
Sergiu Moga [Mon, 15 Feb 2021 17:07:37 +0000 (19:07 +0200)]
lib/vfscore: Register `mkdir` to syscall_shim

Register `mkdir` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Catalin Puscoci <catalinpuscoci@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #130

3 years agolib/vfscore: Register `stat` to syscall_shim
Sergiu Moga [Mon, 15 Feb 2021 09:48:15 +0000 (11:48 +0200)]
lib/vfscore: Register `stat` to syscall_shim

Register `stat` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Catalin Puscoci <catalinpuscoci@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #128

3 years agolib/vfscore: Register `chown` to syscall_shim
Sergiu Moga [Tue, 16 Mar 2021 21:00:04 +0000 (23:00 +0200)]
lib/vfscore: Register `chown` to syscall_shim

Register `chown` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Catalin Puscoci <catalinpuscoci@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #154

3 years agolib/vfscore: Register `lchown` to syscall_shim
Sergiu Moga [Tue, 16 Mar 2021 21:20:16 +0000 (23:20 +0200)]
lib/vfscore: Register `lchown` to syscall_shim

Register `lchown` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Catalin Puscoci <catalinpuscoci@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #157

3 years agolib/vfscore: Register `fchown` to syscall_shim
Sergiu Moga [Tue, 16 Mar 2021 21:13:52 +0000 (23:13 +0200)]
lib/vfscore: Register `fchown` to syscall_shim

Register `fchown` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Catalin Puscoci <catalinpuscoci@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #156

3 years agolib/posix-user: Register `setresgid` to syscall_shim
Sergiu Moga [Fri, 29 Jan 2021 18:03:32 +0000 (20:03 +0200)]
lib/posix-user: Register `setresgid` to syscall_shim

Register `setresgid` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #120

3 years agolib/posix-user: Register `getresuid` to syscall_shim
Sergiu Moga [Fri, 29 Jan 2021 17:56:05 +0000 (19:56 +0200)]
lib/posix-user: Register `getresuid` to syscall_shim

Register `getresuid` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #119

3 years agolib/posix-user: Register `setresuid` to syscall_shim
Sergiu Moga [Fri, 29 Jan 2021 17:51:44 +0000 (19:51 +0200)]
lib/posix-user: Register `setresuid` to syscall_shim

Register `setresuid` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #118

3 years agolib/posix-user: Register `capget` to syscall_shim
Sergiu Moga [Sat, 13 Mar 2021 16:00:50 +0000 (18:00 +0200)]
lib/posix-user: Register `capget` to syscall_shim

Register `capget` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Mocanu Viorel Gabriel <gabi.mocanu98@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #147

3 years agolib/posix-user: Register `setgroups` to syscall_shim
Sergiu Moga [Fri, 29 Jan 2021 17:46:53 +0000 (19:46 +0200)]
lib/posix-user: Register `setgroups` to syscall_shim

Register `setgroups` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Mocanu Viorel Gabriel <gabi.mocanu98@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #117

3 years agolib/posix-user: Register `setregid` to syscall_shim
Sergiu Moga [Fri, 29 Jan 2021 17:33:45 +0000 (19:33 +0200)]
lib/posix-user: Register `setregid` to syscall_shim

Register `setregid` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Mocanu Viorel Gabriel <gabi.mocanu98@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #115

3 years agolib/posix-user: Register `setreuid` to syscall_shim
Sergiu Moga [Fri, 29 Jan 2021 17:17:01 +0000 (19:17 +0200)]
lib/posix-user: Register `setreuid` to syscall_shim

Register `setreuid` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Mocanu Viorel Gabriel <gabi.mocanu98@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #114

3 years agolib/posix-user: Register `setgid` to syscall_shim
Sergiu Moga [Fri, 29 Jan 2021 16:45:47 +0000 (18:45 +0200)]
lib/posix-user: Register `setgid` to syscall_shim

Register `setgid` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Mocanu Viorel Gabriel <gabi.mocanu98@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #113

3 years agolib/posix-user: Register `getresgid` to syscall_shim
Sergiu Moga [Fri, 29 Jan 2021 18:06:38 +0000 (20:06 +0200)]
lib/posix-user: Register `getresgid` to syscall_shim

Register `getresgid` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Mocanu Viorel Gabriel <gabi.mocanu98@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #111

3 years agoplat/xen/drivers/net: Add receive operation
Costin Lupu [Tue, 17 Nov 2020 08:38:48 +0000 (10:38 +0200)]
plat/xen/drivers/net: Add receive operation

Incoming packets are written in pages allocated by the netfront. Such pages are
allocated and registered to the shared ring after completion of receiving
operations.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
3 years agoplat/xen/drivers/net: Add transmit operation
Costin Lupu [Tue, 17 Nov 2020 08:38:47 +0000 (10:38 +0200)]
plat/xen/drivers/net: Add transmit operation

Whenever a packet is transmitted, the request describing it is written in the
shared ring. The packet itself is written in a page referenced by the request
and shared, as well, with the backend. At the end of each transmit operation, a
cleanup operation is performed free'ing the resources allocated for the
previously transmitted packets.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
3 years agoplat/xen/drivers/net: Start netfront device
Costin Lupu [Tue, 17 Nov 2020 08:38:46 +0000 (10:38 +0200)]
plat/xen/drivers/net: Start netfront device

Starting the device implies establishing the connection between netfront and
netback. The connection is set up after a negociation between the two end
points. After configuring the device queues, the netfront publishes via
Xenstore the information associated with the queues which will be used by the
backend to connect.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
3 years agoplat/xen/drivers/net: Enable/disable interrupts for rx queues
Costin Lupu [Tue, 17 Nov 2020 08:38:45 +0000 (10:38 +0200)]
plat/xen/drivers/net: Enable/disable interrupts for rx queues

The user can enable/disable interrupts for devices according with the operation
mode he or she chooses for the device. This patch follows closely the logic
implemented in the virtio net driver.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
3 years agoplat/xen/drivers/net: Configure netfront rx queue
Costin Lupu [Tue, 17 Nov 2020 08:38:44 +0000 (10:38 +0200)]
plat/xen/drivers/net: Configure netfront rx queue

Incoming packets are saved in buffers allocated with user-provided callbacks.
Whenever such packet is available, the driver is notified via event channels.
This patch introduces the configuration logic for rx queues and the handler
used in dealing with the notifications.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
3 years agoplat/xen/drivers/net: Configure netfront tx queue
Costin Lupu [Tue, 17 Nov 2020 08:38:43 +0000 (10:38 +0200)]
plat/xen/drivers/net: Configure netfront tx queue

For each queue, either rx or tx, the packets references are kept in a Xen
shared ring. This patch introduces the initialization of tx shared ring. Each
time the driver will send a packet it will add a request on the tx shared ring
which will be serviced by the backend. Therefore we need to keep track of the
requests by keeping track of their IDs. Because our resources are limited, we
will maintain a pool of IDs (see `freelist` array) for this purpose.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
3 years agoplat/xen/drivers/net: Create netfront queues
Costin Lupu [Tue, 17 Nov 2020 08:38:42 +0000 (10:38 +0200)]
plat/xen/drivers/net: Create netfront queues

We continue with the device configuration by retrieving the Xenstore
information regarding the number of queues and their associated event channels.
Netfront devices operate pairs of Rx/Tx queues and for notifications we can
either use a single event channel per pair or split event channels.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
3 years agoplat/xen/drivers/net: Configure netfront device
Costin Lupu [Tue, 17 Nov 2020 08:38:41 +0000 (10:38 +0200)]
plat/xen/drivers/net: Configure netfront device

The information needed for configuring netfront devices is in the Xenstore. For
now, we only retrieve the MAC and IP addresses from there in order to
initialize the device.

This patch introduces the `netfront_dev` structure which integrates both netdev
and Xenbus device information and also keeps the configuration parameters.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
3 years agoplat/xen/drivers: Add skeleton for netfront driver
Costin Lupu [Tue, 17 Nov 2020 08:38:40 +0000 (10:38 +0200)]
plat/xen/drivers: Add skeleton for netfront driver

This patch introduces the skeleton for the Xen netfront driver.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@gmail.com>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
3 years agoplat/xen: Add vif device type
Costin Lupu [Tue, 17 Nov 2020 08:38:39 +0000 (10:38 +0200)]
plat/xen: Add vif device type

vif device type is used for virtual network interfaces.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Roxana Nicolescu <nicolescu.roxana1996@gmail.com>
3 years agolib/vfscore: Correct the macro name of UK_LIBC_SYSCALLS
Jia He [Thu, 13 May 2021 08:28:33 +0000 (16:28 +0800)]
lib/vfscore: Correct the macro name of UK_LIBC_SYSCALLS

Correct the name from UK_LIBC_SYSCALL to UK_LIBC_SYSCALLS

Otherwise the linking will report:
libs/newlib/musl-imported/src/termios/tcsetattr.c:35:
undefined reference to `ioctl'
/bin/ld:
apps/sqlite/build/sqlite_kvm-x86_64.o: in
function `tcgetattr':
libs/newlib/musl-imported/src/termios/tcgetattr.c:30:
undefined reference to `ioctl'

Reported-by: Alexander Jung <a.jung@lancs.ac.uk>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #204

3 years agolib/vfscore: Update registration of `sync` to syscall_shim
Sergiu Moga [Thu, 13 May 2021 08:49:25 +0000 (11:49 +0300)]
lib/vfscore: Update registration of `sync` to syscall_shim

Change `UK_LIBC_SYSCALL` to `UK_LIBC_SYSCALLS` for the `sync` system call
with respect to the updated documentation.

Reported-by: Alexander Jung <a.jung@lancs.ac.uk>
Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #204

3 years agodoc/developers: Change `UK_LIBC_SYSCALL` to `UK_LIBC_SYSCALLS`
Sergiu Moga [Thu, 13 May 2021 08:42:21 +0000 (11:42 +0300)]
doc/developers: Change `UK_LIBC_SYSCALL` to `UK_LIBC_SYSCALLS`

Change the macro definition from `UK_LIBC_SYSCALL` to `UK_LIBC_SYSCALLS`.

Reported-by: Alexander Jung <a.jung@lancs.ac.uk>
Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #204

4 years agobuild: Introduce `mk_sub_libbuild_dir`
Simon Kuenzer [Mon, 26 Apr 2021 14:28:29 +0000 (16:28 +0200)]
build: Introduce `mk_sub_libbuild_dir`

Inline with `mk_sub_build_dir`, this commit introduces
`mk_sub_libbuild_dir` that enables creating a sub build
directory for a library. This new Makefile command has
two parameters: (1) library name, (2) sub directory
structure.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #194

4 years agolib/uktime: Register time syscall to syscall shim
Razvan Deaconescu [Sun, 14 Feb 2021 19:50:13 +0000 (21:50 +0200)]
lib/uktime: Register time syscall to syscall shim

Signed-off-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #124

4 years agolib/vfscore: Register `fstatfs` to syscall_shim
Sergiu Moga [Mon, 8 Mar 2021 17:25:54 +0000 (19:25 +0200)]
lib/vfscore: Register `fstatfs` to syscall_shim

Register `fstatfs` system call to syscall_shim library.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #144

4 years agolib/*: Use `UK_WARN_STUBBED()`
Simon Kuenzer [Mon, 25 May 2020 01:53:53 +0000 (03:53 +0200)]
lib/*: Use `UK_WARN_STUBBED()`

Replaces the occurrences of `WARN_STUBBED()` to `UK_WARN_STUBBED()`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #172

4 years agolib/ukdebug: Provide `uk_printd_once()`, `uk_printk_once()`
Simon Kuenzer [Mon, 25 May 2020 01:44:01 +0000 (03:44 +0200)]
lib/ukdebug: Provide `uk_printd_once()`, `uk_printk_once()`

This commit introduces debug and kernel print helpers that print a
message just once. Any successive call of the same location of a
message will produce no output: `uk_printd_once()` and
`uk_printk_once()`, as well as `uk_pr_crit_once()`, `uk_pr_err_once()`,
`uk_pr_warn_once()`, and `uk_pr_info_once()`.
This can be used to limit the amount of shown messages.

This commit updates the macro `WARN_STUBBED()`. Since the
functionality of printing once is made generally available, the macro
is based on `uk_pr_warn_once()`. In order to be inline with the
Unikraft naming scheme and reducing the risk of naming conflicts,
the macro is also introduced under the name `UK_WARN_STUBBED()`.
`WARN_STUBBED()` should be considered as deprecated.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #172

4 years agolib/uktime: Register times syscall in syscall shim
Razvan Deaconescu [Sun, 14 Feb 2021 20:09:16 +0000 (22:09 +0200)]
lib/uktime: Register times syscall in syscall shim

The times syscall is marked as not supported, i.e. returns -ENOTSUP.

Signed-off-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #125