early-console: implement arch independent early console

includes an implementation of arch_early_console for x64
using isa-serial, and an implementation for aarch64
using the (for now write-only) pl011.

This restores output functionality for AArch64 lost in
commit 9bbbe9dc.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: prepare read uio in get_arcbuf()

It was accidentally changed to "write" by 4658e56364a6a31b197e0.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: remove unnecessary vcount() checks in rename()

Elevated vnode reference count should not prevent rename() from working.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
pagecache: save vnode pointer instead of dentry in write page cache

dentry object represents a directory, vnode represent a file, so it is
better to use vnode in the page cache.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mmu: do not destroy pt roots with double initialization

the class construction of the page_table_root must happen
before priority "mempool", or all the work in arch-setup
will be destroyed by the class constructor.
Problem noticed while working on the page fault handler for AArch64.

Signed-off-by: Jani Kokkonen <jani.kokkonen@huawei.com>
Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
aarch64: gic: implement GICv2

implement simple GIC class for interacting with
the GIC distributor and CPU interface.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
trace: introduce trace.py prof-lock command

The command shows a profile with amount of time threads were blocked
on a mutex. This can be used to estimate lock contention.

To use the profile the 'mutex_lock_wa*' tracepoints need to be enabled
with backtrace.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: fix symbol resolving for addr2line v2.23

The script did not parse the response properly in case the symbol is
unknown. That version of addr2line responds in two lines:

 ??
 ??:0

but the script was assuming one line ?? ??:0, as returned by addr2line v2.24

Reported-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: LOCK() and UNLOCK() do not have to return a value

The return values of LOCK() and UNLOCK() are never used. Besides, in the
current Musl version these macros do not have return values at all.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
timerfd: Add nsec validity check to timerfd_settime

According to the manual page, the nsec field from both it_value
and it_interval must be checked, if wrong, return EINVAL.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
build.mk: remove --vga from cmdline on osv.vmdk/.vdi

Now we enabled both VGA and serial, we nolonger need to add --vga cmdline for VMW/VBox.

Reviewed-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
net: cleanup syncache_head construction

This change moves syncache_head construction to its constructor so that the
timer can be nicely embedded in the structure.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vmxnet3: support net channel on vmxnet3.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
assert: fix __assert_fail()

This patch changes the definition of __assert_fail() in api/assert.h which
would allow it and other header files which include it (such as debug.hh) to
be used in mgmt submodules. Fixes conflict with declaration of
__assert_fail() in external/x64/glibc.bin/usr/include/assert.h

Signed-off-by: Jaspal Singh Dhillon <jaspal.iiith@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
aarch64: mmu: remove spurious include

remove a spurious include <osv/prio.hh> which seems to be
a merge artifact.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
VFS: cleanup readdir() and friends

Our readdir_r() and friends were implemented in libc/dir.cc, calling
a function "ll_readdir()" from fs/vfs/main.cc. The name of this function
was confusing ("ll_" seemed to imply lock-less, which it isn't), and the way
it was "extern"ed was ugly, as a comment even admitted.

Moreover, when we want to implement more missing functions like rewinddir()
(see issue #77), we need to write more of these silly "ll_*" wrapper functions.

Instead, let's just move the few dir.cc functions into main.cc. The latter
already defines most of our filesystem system calls, so feels the right
place anyway. This change allows us to get rid of the silly ll_readdir()
layer, and makes implementing rewinddir() trivial (see next patch).

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
VFS: implement rewinddir(), telldir(), seekdir()

Implement three of the Linux functions we're still missing (see issue #77
for a list of more things to do).

These are pretty easy to add, because we just need to correctly call the
lower layer functions, sys_*, which already exist.

This patch also adds tests for the three functions to tst-readdir.cc.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
aarch64: mmu: add include to the proper place

add include <osv/prio.hh>, this time at the beginning of the file.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Fix bug booting with 64 CPUs

OSv is currently limited to 64 vCPUs, because we use a 64-bit bitmask for
wakeups (see max_cpus in sched.cc). Having exactly 64 CPUs *should* work,
but unfortunately didn't because of a bug:

cpu_set::operator++ first incremented the index, and then called advance()
to find the following one-bit. We had a bug when the index was 63: we then
expect operator++ to return 64 (end(), signaling the end of the iteration),
but what happened was that after it incremented the index to 64, advance()
wrongly handled the case idx=64 (1<<64 returns 1, unexpectedly) and moved
it back to idx=63.

The patch fixes operator++ to not call advance when idx=64 is reached,
so now it works correctly also for idx=63, and booting with 64 CPUs now
works.

Fixes #234.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
loader: poweroff() if cpus.size()>max_cpus

This patch fixes the case of silently hanging of OSv when >64 cpus are
provided.

Signed-off-by: Jaspal Singh Dhillon <jaspal.iiith@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>