core: Fix code duplication in application::run()

No need to duplicate code for the specialized version of
application::run(). We can just call the more general one from it.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
include: Clean up osv/app.hh header

Clean up the osv/app.hh header file by reorganizing member definitions
and improving the API documentation.

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
shm: access iterator before invalidating it

Debug allocator was keen to point out that unordered_map<>::erase()
invalideates the iterator thus it erase, read operation pair should be
done in reverse order.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
mmu: fix freeing huge pages in shm_file::_pages

shm_file::_pages contains only huge pages allocated in shm_file::page(),
so they should be freed by calling memory::free_huge_page(), not
memory::free_page().

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
elf: make sure section '.note.osv-mlock' actually exists

LD is too serious linker to be fooled into creating an empty section.
A single .long 0 would be enough but .long 0, 0, 0 is actually a valid
entry in any notes section and readelf -n has no reason to complain
when reading a file containing it.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
tests: add OSV_ELF_MLOCK_OBJECT() to tests that need it

"tests that need it" = all tests which at least partially are executed
with preemption disabled. That includes but is not limited to using:
preempt_lock, rcu_read_lock or sched::thread::wait_until().

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc/multibyte: Migrate to upstream musl

Migrate all identical files under libc/multibyte to upstream musl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc/process: Migrate to upstream musl

Migrate all identical files under libc/process to upstream musl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
libc/unistd: Migrate to upstream musl

Migrate all identical files under libc/unistd to upstream musl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
tst-async: ensure that callback fires before cancellation

In test callback_fires_if_not_cancelled it is possible that the main thread
manages to acquire the mutex just after the value of 'proceed' is set
and before the callback acquires that mutex. If that happens the callback
gets cancelled and therefore do not fires. This patch moves setting the
value of 'proceed' after the callback actually fires so that it is never
prematurely cancelled.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Reviewed-by: Tomasz Grabiec <tgrabiec@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: simplify building musl files

Reviewed-by: Nadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc/env: Migrate to upstream musl

Migrate all identical files under libc/env to upstream musl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc/stdlib: Migrate to upstream musl

Migrate all identical files under libc/stdlib to upstream musl.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>