x86: vtd: Drop bogus checks in iommu_get_remapped_root_int

These checks make no sense: At this stage, we actually don't care if
there is a corresponding entry in the hypervisor remapping table for the
device. And the check of the vector number is actually comparing apples
(hypervisor-side base_index) to onions (guest-side irt_entries).
Finally, the tuple of device_id and vector stored in this function will
be validated by iommu_map_interrupt before use in case it gets forwarded
to it.

So drop this code. This will also make the function directly usable for
virtual devices that have no corresponding entry in the hypervisor's
interrupt remapping table.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Move cpu_suspended setting into arch_panic_stop

cpu_suspended is an x86-specific control, nothing every arch needs to
provide. Leave it up to the arch how to set the CPU's state on panic.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Refactor struct mmio_access to mmio_instruction

The current mmio_access rather contains information about the accessing
instruction. ARM's mmio_access will hold data about the actual access.
To clarify the meaning and free the namespace, rework the preexisting
struct to mmio_instruction.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Move mmio_parse and struct mmio_instruction into arch header

There will be no need for and implementation of this service outside of
x86 in the foreseeable future. So make it arch-private until we have
more users.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Rename vcpu_entry_failure back to vmx_entry_failure

This function is only used for VMX, so move it to the proper namespace.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Remove unused cpu_data argument from vmx_entry_failure

panic_stop no longer requires it, so it became useless.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Remove debug output from SVM NMI handler

This message no longer provides valuable information as the related code
path is stable now.

CC: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Remove cpu_data parameter from interrupt handling path

We can obtain a reference on demand now.

CC: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Privatize names of static vendor-specific functions

vcpu_set_cell_config, vcpu_reset, vcpu_vendor_get_io_intercept and
vcpu_vendor_get_pf_intercept - they share the same parameters across the
vendor-specific implementations, but they are invoked only locally. So
rename them to something which is prefixed by vmx and svm, respectively,
so that they can be locally refactored as desired with risking confusion
that they might have to usable in a cross-vendor fashion.

CC: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Remove cpu_data parameter from vmx_set_cell_config

As a consequence, this allows to remove it also from vmx_vcpu_reset. All
functions always work against the invoking CPU.

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

Factor out the generic part of x86's arch_config_commit into
config_commit so that we don't need to replicate it into other archs.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Adjust some indentions after vcpu/iommu refactorings

No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
inmates/x86: Initialize jailhouse_use_vmcall

Jailhouse relies on the caller to define and initialize jailhouse_use_vmcall
global variable for hypercalls to work properly. As no inmates currently use
hypercalls, the code was stripped from the original patch.

This patch re-introduces jailhouse_use_vmcall initialization, this time with
hypercall_init() function, which should be called during inmate initialization
the same way other *_init() function are called. This way, inmates that don't
need hypercalls (or timers) can skip initializing them.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Eliminate dead code in vcpu_activate_vmm()

There is no point in clearing host-side MSRs in vcpu_activate_vmm()
(svm.c version), as they get restored as soon as vmload is executed
few lines below.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Explicit %rax for SVM instructions

vmload, vmsave and vmrun use %rax implicitly, but to make Clang happy,
it needs to be part of the mnemonic.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>