Support 'make osv.vmdk' without 'make all'

Add 'all' as dependent target of osv.vmdk/.vdi, to prevent build error.

Signed-off-by: Takuya ASADA <syuu@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
bsd: set a smaller default stack for BSD threads.

All threads created through the bsd/porting/kthread interface are threads that
used to be kernel threads in BSD, which means they are expected to use less
stack. Although I have no idea what is the default stack size for BSD, in Linux
things need as little as 4k. More importantly, they are threads whose memory
usage are under our control, and we could fix heavy offenders without a
problem.

If we don't say anything, they will start with 64k which is way, way, too much.
I am proposing here we go lower and get to 16k - which is even still quite
conservative, but so am I.

Measuring memory before and after the mount - because ZFS is currently our
heaviest user, I can save around 7Mb with this patch.

Passes make check (except for tst-kill, which is broken AFAICT) and misc-fs-stress.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tst-kill: fix crash

tst-kill runs various signal handlers, which we run in separate threads.
When the test completes, we may be unlucky enough for the last signal
handler to still be running, at which point when the module's memory
is unmapped (e.g., in test.py -s each test is unmapped when it ends)
we can get a page fault and a crash.

This patch sleeps for a second at the end of tst-kill, to make sure that
the signal handler has completed; This sleep is a bit ugly, but I can't
think of a cleaner way - Posix provides no way to check if there's a
running handler, and I wouldn't like to add a new API just for this test.

Fixes #249.

Reviewed-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: Print number of threads in 'osv info threads'

The id of the last thread might mislead people's thinking about
the number of threads in OSv, so let's simply print the nr after all
threads were already printed.

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>
sigaction() error checking

Add signal number verification to sigaction().
Also add a FIXME comment that we don't support mode sa_flags.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
signal() using sigaction()

Instead of duplicating sigaction()'s code, let's just use it.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
__sysv_signal()

Implement __sysv_signal(), which is used by code using signal() when compiled
with _XOPEN_SOURCE, -std=..., or something similar (see signal(2) manual page
for a full discussion of the two variants of signal()).

Fixes #238.

Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
sched: change timer state inside atomic context

timer_base is a thread-agnostic interface for per-CPU timers.  The
current code is prone to a race condition involving set() and
cancel(). The latter may attempt to remove the timer before it was
inserted into timer tree.

Found during code inspection.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts/gen-vmx.sh: Reduce virtualHW version

ESXi 5.5 can not edit virtualHW.version = 10 vmx file. Reducing to 8
works in ESXi.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
build: be forgiving to missing newlines in manifest

Running "make image=mgmt,iperf" failed because the last line in
apps/iperf/usr.manifest did not have a newline, and was copied
without a newline, which caused it to be stuck together to the first
line of mgmt's manifest.

Fix this by explicitly adding a newline character to each line we add to
the generated manifest file - whether or not the original manifest had one.

Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
mgmt: update to latest

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: pass -X to less

Option -F should always be used with -X. Without this flag if output
is smaller than the screen then no output will be shown.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: add minimal support for AArch64

this contains still prototyped code, which if reached either
hangs (setjmp, longjmp), aborts (all that requires mmu::),
or implements differently (allocating with malloc instead of mmap)
This is enough libc AArch64 support for reaching the end of premain.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
bsd/aarch64: improve inline assembly for atomic and endian ops

use %wn when referring to the non-extended register n,
and %n when referring to the extended register n,
emit the right memory barrier instructions, get the
semantics of atomic_store_rel hopefully right.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
bsd: add stubs for AArch64

virt_to_phys just returns the virtual address again
for AArch64 for now, while mmu_unmap will abort.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
arch.hh: introduce arch::halt_no_interrupts

rename processor::halt_no_interrupts to cli_hlt, which
logically matches existing processor::sti_hlt.

Make use of arch::halt_no_interrupts in core/power.cc,
enclose x64-specific code in ifdefs, as well as putting
code on AArch64.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
arch/aarch64: first implementation

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
drivers: move debug-console to arch-specific dir

Signed-off-by: Jani Kokkonen <jani.kokkonen@huawei.com>
Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
include/api/aarch64: first implementation

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
debug: add debug_early functionality

the functions debug_early, debug_early_u64 and
debug_early_entry can be used very early, before premain.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>