]> xenbits.xensource.com Git - unikraft/unikraft.git/log
unikraft/unikraft.git
6 years agoRelease: 0.3.1 Iapetus github/master origin/HEAD origin/master RELEASE-0.3.1
Florian Schmidt [Thu, 7 Mar 2019 16:20:38 +0000 (17:20 +0100)]
Release: 0.3.1 Iapetus

Release: 0.3.1 Iapetus

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Signed-off-by: Simon Kuenzer <florian.schmidt@neclab.eu>
Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
6 years agobuild: properly separate UK_EXTRAVERSION in version string
Florian Schmidt [Thu, 7 Mar 2019 16:09:33 +0000 (17:09 +0100)]
build: properly separate UK_EXTRAVERSION in version string

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/nolibc: add definition for pid_t
Florian Schmidt [Tue, 5 Mar 2019 15:04:56 +0000 (16:04 +0100)]
lib/nolibc: add definition for pid_t

Some headers already defined __NEED_pid_t, but the actual definition in
shareddefs.h didn't make it in. Fix that.

Using int for pid_t follows the typedef in musl, from which the code was
imported that had the __NEED_pid_t defines.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
6 years agolib/vfscore: fix checkpatch issues for uio.h and statfs.h
Yuri Volchkov [Mon, 4 Mar 2019 17:46:30 +0000 (18:46 +0100)]
lib/vfscore: fix checkpatch issues for uio.h and statfs.h

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
6 years agolib/vfscore: mark stdio as a character device
Yuri Volchkov [Mon, 4 Mar 2019 17:46:29 +0000 (18:46 +0100)]
lib/vfscore: mark stdio as a character device

Newlib implements printf via writing to stdout. I does a couple of
checks before writing into the file. Make sure these checks are
passed.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
6 years agolib/vfscore: fix conflicts with newlib
Yuri Volchkov [Mon, 4 Mar 2019 17:46:28 +0000 (18:46 +0100)]
lib/vfscore: fix conflicts with newlib

Consists of multiple tiny fixes:
  - syscalls.c: include dirent.h after unistd.h, because it requires
    off_t, ino_t and size_t declarations
  - vfs.h: kill unused OPEN_MAX definition
  - vnode.c: prefix S_BLKSIZE

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
6 years agolib/vfscore: prefix defines conflicting with Newlib
Yuri Volchkov [Mon, 4 Mar 2019 17:46:27 +0000 (18:46 +0100)]
lib/vfscore: prefix defines conflicting with Newlib

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
6 years agolib/vfscore: tabify fs.h
Yuri Volchkov [Mon, 4 Mar 2019 17:46:26 +0000 (18:46 +0100)]
lib/vfscore: tabify fs.h

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
6 years agoplat/kvm: arm64: Remove superfluous blank line
Wei Chen [Fri, 1 Mar 2019 14:54:39 +0000 (22:54 +0800)]
plat/kvm: arm64: Remove superfluous blank line

There is superfluous blank line before _dtb_get_cmdline,
we remove it in passing.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: arm64: Ensure there is no stall data in cache when boot
Wei Chen [Fri, 1 Mar 2019 14:54:38 +0000 (22:54 +0800)]
plat/kvm: arm64: Ensure there is no stall data in cache when boot

We will disable MMU and CACHE before pagetable is ready. This
means we will change memory with cache disabled, so we need to
invalidate the cache to ensure there is no stall data in it.
But we don't know the size of the RAM either. And it would be
expensive to invalidate the whole cache. In this case, just
just need to invalidate what we are going to use:
DTB, TEXT, DATA, BSS, pagetables and bootstack.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Reviewed-by: Julien Grall <julien.grall@arm.com>
6 years agoplat/kvm: arm64: Remove needless semicolons in assembly
Wei Chen [Fri, 1 Mar 2019 14:54:37 +0000 (22:54 +0800)]
plat/kvm: arm64: Remove needless semicolons in assembly

Some semicolons are needless in assembly source code. So we remove
them from code.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: arm64: Support build L3 table for large image size
Wei Chen [Fri, 1 Mar 2019 14:54:36 +0000 (22:54 +0800)]
plat/kvm: arm64: Support build L3 table for large image size

We have updated the L3 table build function to support large memory
range. In this case, we can support build L3 tables for images exceeded
2MB.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: arm64: Build L3 page table for range greater than 2MB
Wei Chen [Fri, 1 Mar 2019 14:54:35 +0000 (22:54 +0800)]
plat/kvm: arm64: Build L3 page table for range greater than 2MB

Current L3 table build function only supports to build L3 table for
memory range not exceeded than 2MB. But as we mentioned in previous
patch, the image size will be greater than 2MB. So in this case, build
L3 table for bigger image is not convenient. We have improve the
function of building L3 table to support bigger memory range.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: arm64: Calculate pagetable size dynamically by image size
Wei Chen [Fri, 1 Mar 2019 14:54:34 +0000 (22:54 +0800)]
plat/kvm: arm64: Calculate pagetable size dynamically by image size

The previous L3 page table size is a fixed value based on the
assumption that, image size will not exceed 2MB. But that's not
true, some applications like node.js will be about 40MB after
converting to Unikernel. So in this patch, we calculate the
page table size by real image size. In order to mapping the
image occupied memory to L3 page table, we round up the image
size with 2MB. If we don't round up the image size with 2MB.
Some memory that is not occupied by image but shared the same
2MB block with image tail will be unmapped in page table.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>`
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: arm64: Clear pagetable memory with boot stack
Wei Chen [Fri, 1 Mar 2019 14:54:33 +0000 (22:54 +0800)]
plat/kvm: arm64: Clear pagetable memory with boot stack

The pagetable memory and boot stack are contiguous, so we can
clear these two areas at the same time.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: Invalidate D-Cache that may have been modified for Arm64
Wei Chen [Fri, 1 Mar 2019 14:54:32 +0000 (22:54 +0800)]
plat/kvm: Invalidate D-Cache that may have been modified for Arm64

DTB, TEXT and RODATA would not be modified while booting, so we just
need to invalidate and clean the area that may have been modified:
DATA, BSS, PAGETABLE and BOOTSTACK.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: Rename pagetable.S to pagetable64.S for Arm64
Wei Chen [Fri, 1 Mar 2019 14:54:31 +0000 (22:54 +0800)]
plat/kvm: Rename pagetable.S to pagetable64.S for Arm64

This file is for Arm64 only, so we rename it to pagetable64.S.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: Force align the stack pointer for Arm64 EL1 exceptions
Wei Chen [Fri, 1 Mar 2019 14:54:30 +0000 (22:54 +0800)]
plat/kvm: Force align the stack pointer for Arm64 EL1 exceptions

If we enable the SCTLR_ELx.SA, Arm64 stack pointer must be aligned to
16-byte before being used as base address. But some valid EL1 exceptions
don't guarantee that SP_EL1 was aligned when entering the exceptions.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: Remove redundant space while entering trap for Arm
Wei Chen [Fri, 1 Mar 2019 14:54:29 +0000 (22:54 +0800)]
plat/kvm: Remove redundant space while entering trap for Arm

Remove redundant space while entering trap.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: Add __TRAP_STACK_SIZE for stack pointer while exiting trap
Wei Chen [Fri, 1 Mar 2019 14:54:28 +0000 (22:54 +0800)]
plat/kvm: Add __TRAP_STACK_SIZE for stack pointer while exiting trap

We have subtract the __TRAP_STACK_SIZE from sp while entering the tarp,
but while exiting the trap, we forgot to add __TRAP_STACK_SIZE back to
sp.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoarch/include: Add a _regs member to save origial stack pointer
Wei Chen [Fri, 1 Mar 2019 14:54:27 +0000 (22:54 +0800)]
arch/include: Add a _regs member to save origial stack pointer

There is a issue about stack alignment check in url[1]. There
might be case where the stack pointer is not aligned at EL1
exception. We will force align the stack for EL1 exceptions,
so we add a sp to save original stack pointer in this patch.

[1] https://www.spinics.net/lists/arm-kernel/msg678761.html

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: Get VIRT_BITS from id_aa64mmfr0_el1.PARange for Arm64
Wei Chen [Fri, 1 Mar 2019 14:54:26 +0000 (22:54 +0800)]
plat/kvm: Get VIRT_BITS from id_aa64mmfr0_el1.PARange for Arm64

As we use VA == PA mapping, so the VIRT_BITS must be the same as
PA_BITS. We can get PA_BITS from ID_AA64MMFR0_EL1.PARange and the
TxSZ of TCR_INIT_FLAGS will be calculate dynamically.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: Correct invalid indent character for Arm64
Wei Chen [Fri, 1 Mar 2019 14:54:25 +0000 (22:54 +0800)]
plat/kvm: Correct invalid indent character for Arm64

Using tab to replace spaces for the indent before ukplat_entry_argp.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/common: Add referred source code URL for cache operation
Wei Chen [Fri, 1 Mar 2019 14:54:24 +0000 (22:54 +0800)]
plat/common: Add referred source code URL for cache operation

We'd better to mention where our code comes from, this helps to
check whether code has been updated afterwards.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/common: Use correct dsb operation flag for Arm64
Wei Chen [Fri, 1 Mar 2019 14:54:23 +0000 (22:54 +0800)]
plat/common: Use correct dsb operation flag for Arm64

Before MMU turn on, the DSB operation only need to apply out
to the point of unification.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/common: Clean and invalidate D-Cache only when boot for Arm64
Wei Chen [Fri, 1 Mar 2019 14:54:22 +0000 (22:54 +0800)]
plat/common: Clean and invalidate D-Cache only when boot for Arm64

The boot code will not rewrite itself, and we don't have any relocation
operation for code area. So clean&invalidate I-Cache is unnecessary.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/common: Remove earlycloberr from SYSREG_READ32 for Arm64
Wei Chen [Fri, 1 Mar 2019 14:54:21 +0000 (22:54 +0800)]
plat/common: Remove earlycloberr from SYSREG_READ32 for Arm64

As the operand will not be written before the instruction has finished.
So, we don't need the earlycloberr (&) in SYSREG_READ32.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat: Clean up kernel image symbols
Wei Chen [Fri, 1 Mar 2019 14:54:20 +0000 (22:54 +0800)]
plat: Clean up kernel image symbols

There is a potential undefined behaviour for pointer comparision.
How to avoid this gcc optimization is under discussing. Since it
is not a block issue. I will follow it up in the future.
Provide macro definitions for text,bss,data... is the precondition
for future solution.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/common: Move global variables defined in link scripts to a header
Wei Chen [Fri, 1 Mar 2019 14:54:19 +0000 (22:54 +0800)]
plat/common: Move global variables defined in link scripts to a header

The global variables defined in link scripts like _text, _etext and _end
are declared in multiple files. We use a header to include these global
variables to avoid so many duplicated declarations.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/include: Use macro-ed helper to simplify ioreg_read/write for Arm64
Wei Chen [Fri, 1 Mar 2019 14:54:18 +0000 (22:54 +0800)]
plat/include: Use macro-ed helper to simplify ioreg_read/write for Arm64

As discussed in mailing list [1], we can use macro-ed helpers to avoid
having to write 4 times of the same things of ioreg_read_8/16/32/64 and
ioreg_write8/16/32/64.

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agobuild: Remove the check of '--enable-default-pie' in Makefile.uk
Wei Chen [Fri, 1 Mar 2019 14:54:17 +0000 (22:54 +0800)]
build: Remove the check of '--enable-default-pie' in Makefile.uk

As discussed in mailing list [1], the check for '--enable-default-pie'
is unnecessary, because GCC supports '-no-pie' as soon as it.
We have checked '-no-pie' already. So we can remove the check for
'--enable-default-pie' to get rid of the console command.

[1]https://lists.xenproject.org/archives/html/minios-devel/2018-09/msg00067.html

Signed-off-by: Wei Chen <wei.chen@arm.com>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agosupport/build: Add support for the tar.xz and .txz format
Vlad Badoiu [Wed, 9 Jan 2019 13:52:44 +0000 (13:52 +0000)]
support/build: Add support for the tar.xz and .txz format

This patch adds the .txz and tar.xz formats into the build system.
This is needed for the C++ libraries since LLVM uses tar.xz
for their releases (http://releases.llvm.org/download.html).

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
6 years agoRelease: 0.3 Iapetus RELEASE-0.3
Simon Kuenzer [Wed, 20 Feb 2019 13:28:15 +0000 (14:28 +0100)]
Release: 0.3 Iapetus

Release: 0.3 Iapetus

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
6 years agolib/vfscore: fix memory leak at sys_write
Yuri Volchkov [Wed, 20 Feb 2019 17:38:01 +0000 (18:38 +0100)]
lib/vfscore: fix memory leak at sys_write

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/ramfs: fix style issues
Yuri Volchkov [Wed, 20 Feb 2019 15:58:12 +0000 (16:58 +0100)]
lib/ramfs: fix style issues

The non-negative return codes types of check-patch complains are
ignored for now, because this will brake compatibility with current
vfscore.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/ramfs: fix debug printouts
Yuri Volchkov [Wed, 20 Feb 2019 15:58:11 +0000 (16:58 +0100)]
lib/ramfs: fix debug printouts

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/ramfs: adapt imported ramfs to Unikraft
Yuri Volchkov [Wed, 20 Feb 2019 15:58:10 +0000 (16:58 +0100)]
lib/ramfs: adapt imported ramfs to Unikraft

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/ramfs: update license header for imported files
Yuri Volchkov [Wed, 20 Feb 2019 15:58:09 +0000 (16:58 +0100)]
lib/ramfs: update license header for imported files

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/ramfs: tabify imported ramfs code
Yuri Volchkov [Wed, 20 Feb 2019 15:58:08 +0000 (16:58 +0100)]
lib/ramfs: tabify imported ramfs code

To comply with Unikraft coding style, indents must be tabs, not
spaces. Imported code was a mixture of both.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/ramfs: initial import from OSv
Yuri Volchkov [Wed, 20 Feb 2019 15:58:07 +0000 (16:58 +0100)]
lib/ramfs: initial import from OSv

git tag: v0.52.0
commit: 00299190414e4c7c5b0f2d74cd11763dac34e5b9

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/vfscore: Introduce `vfscore_put_file`
Simon Kuenzer [Wed, 20 Feb 2019 13:34:02 +0000 (14:34 +0100)]
lib/vfscore: Introduce `vfscore_put_file`

As counterpart to `vfscore_get_file`, we export `vfscore_put_file`
as a way to release the refcount on a file.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
6 years agolib/nolibc: Provide stdbool.h
Simon Kuenzer [Tue, 19 Feb 2019 15:50:29 +0000 (16:50 +0100)]
lib/nolibc: Provide stdbool.h

Introduce a minimal `stdbool.h` header that provides definitions
of `bool`, `true`, and `false`.
The file is copied from LLVM Clang 7.0.1 (https://clang.llvm.org/).

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/vfscore: remove sys prefix from vfs api functions
Yuri Volchkov [Mon, 18 Feb 2019 14:54:40 +0000 (15:54 +0100)]
lib/vfscore: remove sys prefix from vfs api functions

Fucntions sys(mount|umount|umount2|sync) are complete function
calls. User applications should use them directly anyways. Let's
rename them accordingly.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/vfscore: re-implement stdio and enable new code
Yuri Volchkov [Mon, 18 Feb 2019 14:54:39 +0000 (15:54 +0100)]
lib/vfscore: re-implement stdio and enable new code

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/nolibc: add prototypes for functions from vfscore
Yuri Volchkov [Mon, 18 Feb 2019 14:54:38 +0000 (15:54 +0100)]
lib/nolibc: add prototypes for functions from vfscore

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/vfscore: add main constructor
Yuri Volchkov [Mon, 18 Feb 2019 14:54:37 +0000 (15:54 +0100)]
lib/vfscore: add main constructor

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/vfscore: fix compiler complains
Yuri Volchkov [Mon, 18 Feb 2019 14:54:36 +0000 (15:54 +0100)]
lib/vfscore: fix compiler complains

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/vfscore: add necessary internal prototypes
Yuri Volchkov [Mon, 18 Feb 2019 14:54:35 +0000 (15:54 +0100)]
lib/vfscore: add necessary internal prototypes

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/vfscore: introduce fdclose
Yuri Volchkov [Mon, 18 Feb 2019 14:54:34 +0000 (15:54 +0100)]
lib/vfscore: introduce fdclose

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/vfscore: remove _KERNEL ifdefs
Yuri Volchkov [Mon, 18 Feb 2019 14:54:33 +0000 (15:54 +0100)]
lib/vfscore: remove _KERNEL ifdefs

All this code is running in kernel

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/vfscore: add necessary field in vfscore_file
Yuri Volchkov [Mon, 18 Feb 2019 14:54:32 +0000 (15:54 +0100)]
lib/vfscore: add necessary field in vfscore_file

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/vfscore: introduce fget, fdrop, fdalloc
Yuri Volchkov [Mon, 18 Feb 2019 14:54:31 +0000 (15:54 +0100)]
lib/vfscore: introduce fget, fdrop, fdalloc

These functions are used in the imported code, which is not enabled
yet. This required to expand functionality of vfscore_install_fd and
friends with locking and reference counting.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/vfscore: prefix exported functions
Yuri Volchkov [Mon, 18 Feb 2019 14:54:30 +0000 (15:54 +0100)]
lib/vfscore: prefix exported functions

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/vfscore: introduce UK_FS_REGISTER
Yuri Volchkov [Mon, 18 Feb 2019 14:54:29 +0000 (15:54 +0100)]
lib/vfscore: introduce UK_FS_REGISTER

The macro registers the filesystem in the static array

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/vfscore: add utility funcs&defs to support imported
Yuri Volchkov [Mon, 18 Feb 2019 14:54:28 +0000 (15:54 +0100)]
lib/vfscore: add utility funcs&defs to support imported

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/vfscore: use Unikraft types and functions
Yuri Volchkov [Mon, 18 Feb 2019 14:54:27 +0000 (15:54 +0100)]
lib/vfscore: use Unikraft types and functions

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/vfscore: use Unikraft includes
Yuri Volchkov [Mon, 18 Feb 2019 14:54:26 +0000 (15:54 +0100)]
lib/vfscore: use Unikraft includes

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/vfscore: remove obvious c++isms and irrelevant code
Yuri Volchkov [Mon, 18 Feb 2019 14:54:25 +0000 (15:54 +0100)]
lib/vfscore: remove obvious c++isms and irrelevant code

Some c++isms are keep because bigger pieces needed to be redone around
them.

Some code is just disabled with #if 0, as we will make use of it later

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/vfscore: update license header for imported files
Yuri Volchkov [Mon, 18 Feb 2019 14:54:24 +0000 (15:54 +0100)]
lib/vfscore: update license header for imported files

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/vfscore: tabify imported vfs code
Yuri Volchkov [Mon, 18 Feb 2019 14:54:23 +0000 (15:54 +0100)]
lib/vfscore: tabify imported vfs code

To comply with Unikraft coding style, indents must be tabs, not
spaces. Imported code was a mixture of both.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/vfscore: Initial import of OSv vfs
Yuri Volchkov [Mon, 18 Feb 2019 14:54:22 +0000 (15:54 +0100)]
lib/vfscore: Initial import of OSv vfs

The code is imported as is.

Commit f1f42915a33bebe120e70af1f32c1a4d92bac780

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/nolibc: adapt mount.h to Unikraft
Yuri Volchkov [Mon, 18 Feb 2019 14:54:21 +0000 (15:54 +0100)]
lib/nolibc: adapt mount.h to Unikraft

Style problems and proper includes

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/nolibc: import mount.h
Yuri Volchkov [Mon, 18 Feb 2019 14:54:20 +0000 (15:54 +0100)]
lib/nolibc: import mount.h

tag: v1.1.20
commit: 0fa1e638e87cf257e9f96b4019b2076afd674a19

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoinclude/uk: introduce __weak_alias macro
Yuri Volchkov [Mon, 18 Feb 2019 14:54:19 +0000 (15:54 +0100)]
include/uk: introduce __weak_alias macro

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/linuxu: Acknowledge all interrupts on controller
Simon Kuenzer [Mon, 18 Feb 2019 12:58:15 +0000 (13:58 +0100)]
plat/linuxu: Acknowledge all interrupts on controller

Like on plat/kvm, we acknowledge interrupts even in the
case when there was no handler for it. We do this to get
similar platform behaviour.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/kvm: Acknowledge all interrupts
Simon Kuenzer [Sun, 17 Feb 2019 18:46:46 +0000 (19:46 +0100)]
plat/kvm: Acknowledge all interrupts

Acknowledge interrupts even in the case when there was no
handler for it. We do this to (1) compensate potential
spurious interrupts like currently happening on virtio,
and (2) to minimize impact on device drivers that share
one interrupt line that got previously disabled. Whenever
an interrupt was unhandled a critical warning is still
printed to the kernel console.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/ukdebug: Align hexdump with print system
Simon Kuenzer [Tue, 12 Feb 2019 17:07:49 +0000 (18:07 +0100)]
lib/ukdebug: Align hexdump with print system

With the recent update of the print system, the hexdump functionality
was not adopted. This made this functionality useless. With this
commit hexdump is align with the printing again system. For instance,
uk_hexdumpd() is only enabled in the code when either UK_DEBUG is
defined for the compilation unit or debug messages are enabled
globally. uk_hexdumpk() depends on having kernel console enabled and
on the configured maximum message level.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/xen: Arm32, x86_64: Unify linker scripts
Simon Kuenzer [Tue, 12 Feb 2019 14:21:39 +0000 (15:21 +0100)]
plat/xen: Arm32, x86_64: Unify linker scripts

Unify linker scripts of both architectures of the Xen platform.
For simplicity, the layout and linker-provided symbols should
be as close as possible.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/xen: arm: Initialize the bss section to 0
Dafna Hirschfeld [Tue, 12 Feb 2019 13:03:11 +0000 (14:03 +0100)]
plat/xen: arm: Initialize the bss section to 0

Clear the bss section during boot so that it is initialized with 0.
Additonally, we make sure with the linker script that all
bss-related symbols are placed within the bss area marked with
_end and __bss_start when the compile option "dropping of unused
symbols" is enabled.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/xen: CPU definition for Arm32
Simon Kuenzer [Wed, 13 Feb 2019 13:07:37 +0000 (14:07 +0100)]
plat/xen: CPU definition for Arm32

Introduce minimal CPU definitons to enable compiling for Arm32.
This commits also removes x86 specific CPU functions from the
Arm32 build unit and introduces CONFIG_XN_HVMLITE as invisible
menu configuraiton. Its intention is to support switching
between PV and PVH mode later. For now, we set PV mode for x86
and PVH mode for Arm.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/xen: Split emergency and hypervisor console
Simon Kuenzer [Wed, 13 Feb 2019 12:26:26 +0000 (13:26 +0100)]
plat/xen: Split emergency and hypervisor console

Splits the two console implemetations (hvc, emergency) from each other.
Similar to plat/kvm, a console option menu is populated in the platform
configuration where each console can be individually selected as output
for kernel or debug messages. Because hvc is currently not yet supported
on Arm32, we set the debug console as default output on Arm32.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/xen: Grant table support as menu option
Simon Kuenzer [Tue, 12 Feb 2019 16:09:49 +0000 (17:09 +0100)]
plat/xen: Grant table support as menu option

Introduces a menu option to enable or disable grant table support.
The reason is that our grant table implementation depends on
libuklock, libuksched, and libukalloc. A minimal configuration
requires these libraries selected, too. This may be an obstacle
when running implementation written in higher-level languages.
Additionally, some of these libraries are currenlty not supported
on Arm32. It is wiser to give an option for disabling grant table
support.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agobuild: Add HAVE_NW_STACK feature symbol
Simon Kuenzer [Wed, 13 Feb 2019 13:36:17 +0000 (14:36 +0100)]
build: Add HAVE_NW_STACK feature symbol

Provide HAVE_NW_STACK feature symbol in lib/Config.uk.
When liblwip is used, it is set.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agobuild: Notice user when to do `make clean`
Simon Kuenzer [Mon, 11 Feb 2019 17:01:10 +0000 (18:01 +0100)]
build: Notice user when to do `make clean`

The little helper script `configupdate` did not detect any config changes
with `.config` anymore because it did prefix `CONFIG_` prefix for the
configuration symbols.
This commit makes sure that `configupdate` can detect changes
(e.g., CPU architecture, code optimizations) that requires `make clean`
before continuing. It is still called automatically by the build system.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoplat/common: Add cpu.h for Arm32
Simon Kuenzer [Fri, 8 Feb 2019 15:19:26 +0000 (16:19 +0100)]
plat/common: Add cpu.h for Arm32

Adds a minimal cpu.h for Arm32 so that linux user space
can be built again.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoarch/arm: Correct source paths in libarmmath
Dafna Hirschfeld [Fri, 8 Feb 2019 15:19:25 +0000 (16:19 +0100)]
arch/arm: Correct source paths in libarmmath

The source files of libarmmath were moved to a subdirectory
without modifiying the corresponding Makefile.uk. This caused
compilation erros.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agolib/ukboot: include uk/essentials.h in weak_main
Yuri Volchkov [Tue, 12 Feb 2019 22:26:54 +0000 (23:26 +0100)]
lib/ukboot: include uk/essentials.h in weak_main

In case of compiling with newlib enabled, essentials.h is not getting
included. Because of that, compiler does not know what '__weak' means,
and the compilation fails. Let's include essentials.h explicitly.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agoplat/kvm: Disconnect console options from ukdebug
Simon Kuenzer [Fri, 8 Feb 2019 10:38:08 +0000 (11:38 +0100)]
plat/kvm: Disconnect console options from ukdebug

Like on the other platforms, the console options for debugging
messages should not be hidden when global debug output is not
enabled. One may still want to enable individual debugging for a
particular library or file. This commit makes this configuration
option independent in the menu.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/ukboot: move weak main in separate sub-lib
Yuri Volchkov [Fri, 4 Jan 2019 16:18:00 +0000 (17:18 +0100)]
lib/ukboot: move weak main in separate sub-lib

Link Time Optimization does not work well with incremental linking (ld
-r), which is heavily used by Unikraft.

The ukboot has a weak main() function, which is supposed to be called
if no other library/application provided a proper main. However gcc
resolves main() to whatever is available while linking the
libukboot.ld.o. Which is the weak one.

In the upcoming gcc v9 release a better support of incremental link
optimization is announced. Which hopefully will fix this issue. But
for now, let's fix it with a workaround.

Let's create a sublib under the ukboot, containing only the weak
main. This way we will leave no chance for the first "ld -r" to link
with the wrong main. The next "ld -r" will have all the objects, so it
will be able to make correct decision.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agobuild: limit gcc version to 6.1 if LTO is enabled
Yuri Volchkov [Fri, 4 Jan 2019 16:17:59 +0000 (17:17 +0100)]
build: limit gcc version to 6.1 if LTO is enabled

Unikraft is using incremental linking, which is not supported by lto
in gcc earlier then 6.1.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agobuild: mark LTO as experimental
Yuri Volchkov [Wed, 6 Feb 2019 16:14:04 +0000 (17:14 +0100)]
build: mark LTO as experimental

Currently LTO during incremental linking is not supported well enough
by gcc.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agosupport: don't throw error message when not in a git repo
Florian Schmidt [Thu, 17 Jan 2019 12:39:29 +0000 (13:39 +0100)]
support: don't throw error message when not in a git repo

The gitsha1 script is used to create a version string for unikraft that
includes the git hash. However, if we are not building from a git repo
checkout, it will throw error messages on the command line. Suppress
these because there's little gain in them.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agobuild: `print-libs`, `print-objs`, `print-srcs` depend on `.config`
Simon Kuenzer [Thu, 31 Jan 2019 11:12:52 +0000 (11:12 +0000)]
build: `print-libs`, `print-objs`, `print-srcs` depend on `.config`

As soon as no configuration `.config` is available, the Make targets
`print-libs`, `print-objs`, and `print-srcs` will return an error
message. Without a configuration file these targets are not able
to do any listing of which units are used or created by a build.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agobuild: `print-vars` target is a `null_targets`
Simon Kuenzer [Thu, 31 Jan 2019 11:12:51 +0000 (11:12 +0000)]
build: `print-vars` target is a `null_targets`

Include the `print-vars` target to the `null_targets` variable. This
is done for consistency.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agobuild: `distclean`, `properclean` independent of `.config`
Simon Kuenzer [Thu, 31 Jan 2019 11:12:50 +0000 (11:12 +0000)]
build: `distclean`, `properclean` independent of `.config`

Until now, the targets `distclean` and `properclean` were not
available if `.config` file is not present. This does not make sense,
because these targets have nothing to do with the configuration. They
just clean everything (except .config in case of properclean).
Since these targets use some functions declared in
`support/build/Makefile.rules`, we include this file at an earlier
point.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/nolibc/string: fix checkpatch issues in strlcpy and strlcat
Yuri Volchkov [Tue, 4 Dec 2018 17:16:28 +0000 (18:16 +0100)]
lib/nolibc/string: fix checkpatch issues in strlcpy and strlcat

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/nolibc/string: import strlcpy and strlcat from musl
Yuri Volchkov [Tue, 4 Dec 2018 17:16:27 +0000 (18:16 +0100)]
lib/nolibc/string: import strlcpy and strlcat from musl

git tag v1.1.20
commit <0fa1e638e87cf257e9f96b4019b2076afd674a19>

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/nolibc/string: fix underflow in strnlen
Yuri Volchkov [Tue, 4 Dec 2018 17:16:26 +0000 (18:16 +0100)]
lib/nolibc/string: fix underflow in strnlen

The memchr return NULL if it did not find '\0' character. The strnlen
did not take this into account and always did subtraction to count the
string length.

Return the provided length limit if the line ending is not found
within this limit.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/ukdebug: Fix spelling in configuration menu
Simon Kuenzer [Wed, 30 Jan 2019 23:44:58 +0000 (23:44 +0000)]
lib/ukdebug: Fix spelling in configuration menu

The help text of LIBUKDEBUG_PRINTK was speaking about debug messages
although the option configures kernel messages.
The option LIBUKDEBUG_PRINTK_INFO enables all types of kernel messages
instead of debug messages.
The message redirection option does not have a dependency on
LIBUKDEBUG_PRINTD neither on LIBUKDEBUG_PRINTK.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoinclude/uk: introduce ukarch_dec
Yuri Volchkov [Wed, 30 Jan 2019 19:25:10 +0000 (20:25 +0100)]
include/uk: introduce ukarch_dec

This is a function symmetric to ukarch_inc, which we already have. The
ukarch_dec does atomic decrement, applying a full memory barrier.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/nolibc/string: import memrchr and strrchr from musl
Yuri Volchkov [Mon, 28 Jan 2019 10:51:13 +0000 (11:51 +0100)]
lib/nolibc/string: import memrchr and strrchr from musl

tag: v1.1.20
commit <0fa1e638e87cf257e9f96b4019b2076afd674a19>

Only style modifications have been applied on top of the original code

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/uklock: introduce UK_MUTEX_INITIALIZER
Yuri Volchkov [Wed, 9 Jan 2019 11:33:59 +0000 (12:33 +0100)]
lib/uklock: introduce UK_MUTEX_INITIALIZER

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/uklock: introduce mutex_is_locked
Yuri Volchkov [Wed, 9 Jan 2019 11:33:58 +0000 (12:33 +0100)]
lib/uklock: introduce mutex_is_locked

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/uklock: rename mutex functions to match pthread_ analogues
Yuri Volchkov [Wed, 9 Jan 2019 11:33:57 +0000 (12:33 +0100)]
lib/uklock: rename mutex functions to match pthread_ analogues

People are more used to functions like mutex_lock and mutex_unlock,
then mutex_hold and mutex_release.

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agodrivers/virtio: Memory barrier before notifying host on virtqueue updates
Simon Kuenzer [Thu, 31 Jan 2019 15:48:44 +0000 (15:48 +0000)]
drivers/virtio: Memory barrier before notifying host on virtqueue updates

Before notifying the virtio backend on the host we should make
sure that the virtqueue index update operation actually happened.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agodrivers/virtio: virtio_netdev_recv(): Remove disabling interrupts
Simon Kuenzer [Thu, 31 Jan 2019 15:48:43 +0000 (15:48 +0000)]
drivers/virtio: virtio_netdev_recv(): Remove disabling interrupts

Disabling interrupts by virtio_netdev_recv() is not needed because in
normal cases they are already disabled by the internal receive
interrupt handler, right before a uknetdev API program can call the
receive function. When the device is used in pure polling mode, queue
interrutps are never enabled.
We remove this step because of performance reasons. An assertion is
making sure that the API is used as intended.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/uknetdev: Flag-based status report on rx and tx functions
Simon Kuenzer [Thu, 31 Jan 2019 15:48:42 +0000 (15:48 +0000)]
lib/uknetdev: Flag-based status report on rx and tx functions

Introduce flag based status return codes on receive and transmit
functions. They are replacing the current enum-like return codes. The
flags are able to inform the API user about additional driver
states (e.g., queue underruns).

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/uknetdev: Introduce receive buffer allocator callback
Simon Kuenzer [Thu, 31 Jan 2019 15:48:41 +0000 (15:48 +0000)]
lib/uknetdev: Introduce receive buffer allocator callback

The idea of having a fill-up parameter on the receive function is
inconvenient because a user never knows how many receive buffers have
to be programmed before calling the receive function.
This commit introduces registering a callback when configuring a
receive queue. This callback has to be provided by the NETDEV API user
and is called by the driver whenever it programs new receive buffers to
the receive queue. In order to still provide performance, this
allocation callback function is called for a batch of receive buffers.
This new mechanism replaces the fill-up parameter on the receive function.

This commit also adopts virtio-net in order to comply with the API change.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/uklock: Debug level for semaphore messages
Simon Kuenzer [Wed, 30 Jan 2019 17:33:34 +0000 (17:33 +0000)]
lib/uklock: Debug level for semaphore messages

Use debug prints also for semaphore initialization message.
This is done in order to be inline with other messages
produced by libuklock.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agolib/nolibc: Introduce fd_set operation macros
Simon Kuenzer [Wed, 30 Jan 2019 17:33:33 +0000 (17:33 +0000)]
lib/nolibc: Introduce fd_set operation macros

Port FD_CLR, FD_ISSET, FD_SET, and FD_ZERO macros from FreeBSD.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>