core: Add compiler barrier semantic to cpu_relax

Will eventually help to get rid of volatile for several synchronization
variables by enforcing a re-read in busy-wait loops:

        while (state_var == STATE)
                cpu_relax();

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Fix some minor style issues

Found by checkpatch. No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Introduce per-page TLB flushing

Reduce the overhead of MMIO parsing specifically by introducing a
per-page TLB flush. Restrict the existing global one to x86, that's
where is is used so far.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Fix stand-alone inclusion of vmx.h and vtd.h

This ensures compliance with our (yet unwritten) rule that all headers
should allow stand-alone inclusion. Exceptions are headers used also by
guests or the driver.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Replace __start with &hypervisor_header

These naturally point to the same address, so we can replace the extra
__start symbol.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Fix SIPI processing

Make sure that we only deliver a SIPI vector when there is actually one
pending. We park the CPU while in wait-for-SIPI state. If we receive an
IPI before a SIPI was defined, x86_handle_events will deliver a random
SIPI vector. Avoid this by encoding SIPI availability via the
sipi_vector fields.

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

Less duplication, no functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Reduce APIC MMIO value variable to 32-bit length

This avoids evaluating the higher 32 bits on writes. We only support
32-bit writes, so we must only look at the lower 32 bit of the input
register.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Clean up xAPIC-related magics and register accesses

Instead of open-coding, use mmio_read/write for accessing xAPIC
registers. Wrap the address calculations with the helper macro and
use a symbolic constant for the xAPIC ID shift.

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