mmu: flush tlb after clearing PDE entry

CPU may have PDE cache, even if all PTEs are invalid, which need to be
flushed when PDE changes.

Signed-off-by: Gleb Natapov <gleb@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
loader: add --delay option

Delay boot by the specified number of seconds, so that slow log collectors
such as ec2 can catch up.

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>
x64: Move kernel image start at 32 MB

Make some room for statically linked executables that are loaded at
fixed addresses.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
elf: Support statically linked ELF executables

The ELF linker assumes that it's loading dynamically linked ELF
libraries and does not check if dynamic array tags are present. Fix them
to make statically linked ELF executables load.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
elf: Fix statically linked executable entry point

Statically linked executable may not have PT_INTERP present so we also
need to check for ET_EXEC object file type when looking up the entry
point.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
tests: Add static ELF test case

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
elf: Load static objects at fixed base address

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
elf: Fix statically-linked executable base address

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
elf: Fix permissions for static executables

A statically linked "hello, world" C++ application will page fault on
its stack because there's a PT_RELRO segment type present that sets the
stack page to read-only...

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
x64: Fix ELF initial stack state

Fix ELF initial stack state as per Figure 3.9 ("Initial Process Stack")
in the x86-64 ABI specification. This is needed for statically linked
executables.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
x64: Make DUMMY_HANDLER less dumb

It's nice to at least see the RIP where the invalid opcode exception
happened at...

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
x64: 'syscall' instruction support

Enable "fast system calls" via the 'syscall' instruction on OSv. The
instruction is used by Go programs on Linux/x86-64 for system calls.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
linux: Make syscall() return ENOSYS if syscall not supported

Make the syscall() function return ENOSYS if a syscall number is not
supported. Keep a debug printout, though, as our system call coverage is
very low.

This is needed for statically linked programs to limp along even if a
syscall isn't supported.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
linux: Fix futex() command bitmask

The "op" argument passed to futex() also include flags so we need to
mask the command bits.

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
linux: Wire up uname system call

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
libc/mman: Add brk() stub

Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
linux: Wire up brk system call

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