tests: extract testing framework

This refactoring will allow to create more complex tests which are not
limited to running only one command inside the guest, but can also
perform actions and validations which are external to the guest. Such
test cases are managed by the common test runner (scripts/test.py) and
use the same guest-management infrastructure, error detection,
etc. The common code is extracted to testing.py module. This was in
done with intent to write tests which involve external TCP
communication.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: use singular form of a noun when count is one

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>
tests: introduce --test option

This option allows to run a single test using the test runner.

Example:

 scripts/test.py --test tst-async.so

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>
tests: add test for closing TCP connection with pending packets

The test is supposed to trigger the problem from issue #259. I was not
able to trigger the problem using guest-local communication, hence the
client is external to the guest.

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: Add upload script for standalone images

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
scripts: Rename Capstan release upload script

Rename the script to "upload-capstan-release" to match the naming
convention of "upload-standalone-release".

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
x64: Switch to "-msse2" GCC option

VirtualBox, for example, does not enable SSE 4.1 by default and Avi
tells me QEMU does not do that either.

To make OSv always bootable, switch to SSE2 which is guaranteed to be
present on x86-64.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
limits: provide alias for *limit64 functions

Signed-off-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
x64: make .fixup section writable

The content of .fixup section is sorted during boot. Moreover, since
.fixup contains pointers to locations in .text section it requires
R_X86_64_RELATIVE relocations.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
trace: make section .tracepoint_patch_sites writable

.tracepoint_patch_sites contains pointers to locations in .text section
which needs to be relocated.

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
elf: set segment permissions exactly as specified in p_flags

Reviewed-by: Glauber Costa <glommer@cloudius-systems.com>
Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
elf: make area described in GNU_RELRO read-only

Segment GNU_RELRO is used to inform dynamic linker which sections needs
to be writable only when relocating ELF file and can be made read-only
later. Usually GNU_RELRO overlaps with standard LOAD segment that contains
readable and writable data but ELF file is generated in such way that it
is possible to properly set per-page permissions.

Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: move memory permission check implementation to header file

This code is going to be shared by tst-mmap and tst-elf-permissions.

Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: test elf segments permissions

Signed-off-by: Pawel Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
build.mk: build arm-clock stub

forgot to build the arm-clock stub, which will cause
a NULL pointer dereference when we turn the mmu on.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
mmu: remove overloaded align_up and align_down

align.hh functions with the name name can be used instead
without any downside, and with the upside of less confusion.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
exceptions: add accessors for pc and error

in order to share most of the fault code in core/mmu.cc,
we add accessors to get the program counter and an error
code whose interpretation is arch-dependent
(error_code for x64, ESR for AArch64).

This also fixes an issue in jvm_balloon, where the
error code was checked incorrectly.

Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
aarch64: create initial page tables

create the initial page tables for TTBR0 / TTBR1
and set up the registers for the MMU.

Signed-off-by: Jani Kokkonen <jani.kokkonen@huawei.com>
Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
MMU: add flush_tlb_local and flush_tlb_all

add the APIs to flush a single processor tlb or all
tlbs in the cluster.

Signed-off-by: Jani Kokkonen <jani.kokkonen@huawei.com>
Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>
mmu: implement mmu for aarch64 with refactoring of x64

Signed-off-by: Jani Kokkonen <jani.kokkonen@huawei.com>
[claudio: some fixes]
Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com>