build: allow side-by-side aarch64 and x64 builds

Build into build/release.x64 and build/release.aarch64 instead of
build/release.  A build/release symlink is retained to avoid confusion in
the transition period, as all the tooling plus everyone's fingers are used
to it.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: provide a default for CROSS_PREFIX

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: CROSS_PREFIX is always defined

Now that we provide a default, CROSS_PREFIX is always defined, so we can
drop the ifndef.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: use build/$(mode).$(arch) in preference to the build/$(mode) symlink

The symlink is ambiguous when working with multiple targets, so avoid it,
esp. when embedding the output path in the build directory Makefile.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: avoid referring to $(out) in internal Makefile

We're already building in the output directory, no need to state it
explicitly.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: rename *.mak to *.mk

For consistency, and because eclipse groks .mk better.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
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: move mode-related configuration to conf/*.mk

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
build: move arch-specific configuration to conf/$(arch).mk

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Merge branch 'build'

Some build cleanups.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
virtio-vring: bug fix in use_indirect()

Use indirect if number of needed descriptors is greater than the number of
currently available descriptors.

This fixes a possible dead-lock situation when the number of needed descriptors is
greater than the size of a virtio ring and add_buf_wait() is used.

A side effect of this fix is that it will also make use_indirect() return TRUE in
cases where add_buf() would fail before: e.g. when _avail_count >= _num / 4 and
desc_needed > _avail_count; which is also a good thing.

Reviewed-by: Dor Laor <dor@cloudius-systems.com>
Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
virtio-vring: Make use_indirect() inline since it's heavily used in a fast path

Signed-off-by: Vlad Zolotarov <vladz@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
java: set OSv version in 'osv.version' system property

The 'osv.version' system property can be used from the Java code
to query system version at run-time.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
zfs: call vnode_pager_setsize() to set vnode size in zfs_write()

This is what original frebsd zfs code has and it was changed by
c218cd1ed55f6903f3 because OSv lacked this function, but the function
was introduce in a063ab93059e123fc9.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
vfs: change vfs_lookup to CPP code

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: delete dentry of removed directory in sys_rmdir

Signed-off-by: Prasad Joshi <prasadjoshi.linux@gmail.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>