core: Rename jailhouse_memory::access_flags to flags

We will encode more than access types in them. No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Introduce communication region

The communication region consists of memory shared between cells and the
hypervisor. One page is reserved for each cell so far, and an empty
jailhouse_comm_region structure is defined. The comm region is mapped
into a cell by defining a memory region with JAILHOUSE_MEM_COMM_REGION
set in its flags.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Prepare for error handling in shutdown

We are going to ask all none-Linux if they permit destruction. In case
they refuse, we need to handle this error and report it to all CPUs that
requested a shutdown via the hypercall.

Prepare the code for this by introducing a per-CPU shutdown_state. Its
default state is SHUTDOWN_NONE, thus no shutdown in progress. It is
set for all CPUs by the one that leads a shutdown either to
SHUTDOWN_STARTED or a negative error code. Then each CPU passing through
shutdown() can check if a) they are leading the shutdown and b) if an
already started shutdown failed and required to report the saved error
back.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Rename arch-specific hypercall headers

asm/jailhouse.h is too generic, these headers actually define the
arch-specific hypercall interface parts of Jailhouse. Rename them but
keep "jailhouse" as part of the name to avoid potential clashes over the
generic "asm/hypercall.h".

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Introduce messaging interface via comm region

This adds an interface to send messages from the hypervisor to cells and
receive answers back. Messages and replies currently consists of plain
integer values. Inline helpers are provided (for x86 only so far) to
ensure proper ordering of comm region field updates.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Introduce cell shutdown control interface

Using the messaging feature of the comm region, this introduces an
interface for cell to control their shutdown. The hypervisor sends a
shutdown request to a cell before destroying it. The cell can either
reject or accept the request in its reply message.

Cells can be excluded from this procedure and will continue to be
destructed immediately by setting the flag JAILHOUSE_CELL_UNMANAGED_EXIT
in their configuration file. For now we mark both demo cells as
unmanaged.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates: Demonstrate shutdown rejection in apic-demo

Enable managed shutdown in the apic-demo and reject the first request to
demonstrate the mechanism.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>