x86: Park CPU in guest mode while waiting for SIPI

Instead of spinning inside the hypervisor while in wait-for-SIPI state,
introduce and use vmx_park_cpu. This functions stops the guest CPU in
halted state, interrupts disabled, so that only external events that
trigger a guest exit will wake it up again. This feature will also allow
us to keep the CPU for a longer period in the parked state without
burning lots of energy.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Use symbolic EPT_TYPE_WRITEBACK for feature testing

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Add strcmp function

Will be needed cell destruction hypercall.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Enforce unique cell names

This is required as we will address running cells by name.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
driver/core: Forward cell destruction command to the hypervisor

Nothing implemented down there yet.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
driver/tools: Rework cell destruction API

Reference a cell to be destructed via its config file. The API to the
hypervisor is still based on names, but the driver IOCTL now takes a
reference to a fully loaded config.

This allows the driver to bring the CPUs that were used by the
destructed cell online again. It is also more handy for the user as
creation and destruction now both use the same token to reference a
cell.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Keep a copy of configuration for cell lifetime

This will simplify the cell destruction where we have to assign the
memory regions and devices of the closing cell back to Linux.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Factor out vmx_map_memory_region

We will reuse the function during cell destruction.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Factor out flush_linux_cpu_caches

Will be reused for arch_cell_destroy.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Implement cell destruction

When a cell is destroyed, we need to stop its CPUs and assigned all
its resources that Linux used to have before back to that cell. Like for
shutdown, access control is still missing.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Cosmetic cleanup of vmcs_field enumeration

No functional change.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Fix validation of xAPIC LDR register

LDR will be set to 0 for any CPU with an ID >= 8. This is fine, it just
means the CPU is not addressable in logical destination mode.

This fixes startup in xAPIC mode on systems with more than 8 CPUs.

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