core/tools: Protect result of ARRAY_SIZE

Prevent any operator prioritization issues when embedding ARRAY_SIZE
into an expression by protecting the result with braces. This is a
defensive measure, no current user was affected by it.

Do not convert all the generated or copy&pasted ARRAY_SIZE defines in
the config files as long as they are not affected by the issue.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: Clarify usage constraints of strcmp

Using strcmp quickly attracts the attention of reviews: Is this really
safe regarding buffer overflows? It is, but that's not obvious. So
document what enables the safe usage of strcmp in this case.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: vtd: Drop bogus vector check 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 device_id / 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.

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.

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.

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.

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>