elf: reuse page_size definition from mmu headers

Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com>
Signed-off-by: Raphael S. Carvalho <raphaelsc@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
lib: Fix size of 'struct rusage'

We are currently stubbing getrusage, and zeroing out the whole structure. The
problem, is that the structure definition for OSv is just not conforming with
the one in the main page: it has a reserved field in the end.

That means that the memset() idiom will just overwrite 16 extra words in the
end with zero. That will cause a stack corruption (since getrusage comes from
the stack).

One could argue that once we would implement getrusage properly that would
disappear. While this is true, zeroing out the entire structure first keeps
being a perfectly valid idiom. There is absolutely no excuse for those reserved
fields in a structure that clearly defined in the syscall manpage.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: Fix RUSAGE definitions

1 is for RUSAGE_THREAD. Linux defines RUSAGE_CHILDREN as -1. That is what we
have to use, since this is how the programs will be compiled.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
time: move process_time to common code

It is useful in other locations. Inside OSv, it is a lot more convenient
to call it and have access to a richer structure than to go through the
clock API.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc: Basic getrusage implementation

Most fields will be null, which is in accordance with what we are
already doing for procfs, for example. We can revisit this later. Right
now, this implementation exposes process / thread times through the
getrusage interface, which is a lot more useful.

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
build.mk: aarch64: add --nomount to cmdline

don't try to mount zfs in our first simplified loader image.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
XXX add tests/tst-hello.so to the bootfs.manifest.skel

could find no way to do it better.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
runtime: make abort and __assert_fail callable early

backtrace functionality uses ELF functions which acquire lockfree
mutex locks, and they require threads to be initialized as in
(s_current != nullptr), as well as the ELF program to be
contructed (s_program != NULL).

abort used to print with debug_ll, but in the meantime debug_ll
changed in semantics due to the console framework changes.

Therefore we need to use debug_early to ensure that the message
ends up in the console at any time of call, in any condition.

This patch makes abort() and assert() callable even before
the full construction of the init array in premain and before
TLS is available.

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