x86: Simplify vtd_get_fault_rec_reg_addr

The logic remains readable when written in a single statement.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Refactor vtd constant definitions

Make use of BIT_MASK and refactor the constant definitions used for vtd
into a consistent form that is more easily verifiable against the spec.
Drop some unused constants.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Drop redundant call to vtd_init_fault_nmi

We already call this at the end of vtd_init via root cell
initialization.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Clean up vtd_init_fault_reporting

Remove the unneeded return code, compact the code and do some style
cleanups.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Extend vtd_init_fault_reporting to vtd_init_unit

Move the root table pointer setup from vtd_config_commit. More logic
will be added later.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Avoid warning on passing volatile pointers to page_map_hvirt2phys

This allows to swallow every pointer type without explicit casts.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Clean up vtd_init_fault_nmi, vtd_check_pending_faults and related MSI constants

Coding style fixes and clarifications of the comments. No functional
changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Park a CPU when a VM entry failed

Do not give up a CPU if only VM entry failed. For whatever reason, we
may have loaded an invalid CPU state from which we can still recover by
resetting the virtual CPU. This also simplifies the exit handling.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core/configs: Change IRQ line access control modeling

Change the configuration file to manage access to IRQ lines at IRQ chip
level. Each IRQ chip config entry consists an address, typically the
chip's MMIO address, a unique identifier that will be used for interrupt
remapping on x86, and a bitmap controlling access to individual IRQ pins
of that chip. This will simplify access control checks to IRQ chips.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Add support for Mod 1 to MMIO parser

The only difference to Mod 2 is the length of the displacement: 1
instead of 4 bytes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Add support for IOAPIC access control

This adds basic access control to the IOAPIC. Based on the IRQ chip
configuration, we permit or deny writing to redirection table entries.
This may require integration with interrupt remapping later on.

We furthermore allow reads from other valid IOAPIC registers but deny
any other write accesses.

EOI writing is currently passed through. This will have to be revisited
as well when interrupt remapping is added.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
configs: Make use of IOAPIC moderation

Remove the IOAPIC page from the memory regions and add the IOAPIC as
irqchip instead.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Make PAGE_ALIGN macro robust against complex parameter

Separate the parameter expression from the macro's own calculation.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Clean up jailhouse_system_config_size

Instead of open-coding the content of struct jailhouse_system for
calculating its size, simply adjust sizeof(*system) by that part of
system->system that is already included in jailhouse_cell_config_size().
Simplifies future extensions of struct jailhouse_system.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core/configs/driver: Rename jailhouse_system::system to root_cell

Now that we have a terminology for the first cell, use it. No functional
change, but local configs will require adjustments.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core/driver: Reintroduce a second hypercall argument

Now we have the use case: GET_CPU_INFO will take two arguments, so
reintroduce the capability to pass them. But not more. For now.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core/driver: Extend "CPU Get State" to "CPU Get Info" hypercall

Add a second argument to control which per-cpu information shall be
retrieved via JAILHOUSE_HC_CPU_GET_INFO. For now there will only be
JAILHOUSE_CPU_INFO_STATE, providing the original hypercall service.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Add support for per-CPU statistics

Record VM exits on a per-CPU basis and export this information via the
"CPU Get Info" hypercall.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
driver: Export cell statistics via sysfs

Provide an accumulation of per-CPU statistics for each cell via sysfs.
This can help analyzing potential performance issues of Jailhouse cells.

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