core: Explain asm-defines generation code origins

Explicitly mention code that was taken from Linux kernel in corresponding
source files' licensing headers.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
core: remove redundant test on error-code

The global error-state is checked before a call to cpu_init and checked
again in it. Because this happens under a lock and the global state is
never touched in cpu_init - or any sub-call -, the second check is
redundant and will always be true, thus remove it.

Signed-off-by: Benjamin Block <bebl@mageta.org>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
vtd: intremap: fix calculation of maximum amount of msi(x) vectors

Fix typo that prevented MSI-X remapping regions to get freed correctly.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Bounds check for apic_reserved_bits[] array

apic_accessing_reserved_bits() function doesn't sanitize 'reg' argument.
Malicious cell can use this fact to perform out-of-bounds read in
apic_reserved_bits[] array in host mode, which should never happen.

With this patch, all APIC register bits not listed in apic_reserved_bits[]
are considered reserved.

Signed-off-by: Valentine Sinitsyn <valentine.sinitsyn@gmail.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Fix mask of reserved bits for error LVT

Only bit 16 (mask) is writable, not bits 17 and 18. Was copied & pasted
from timer LVT.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
x86: Handle Extended APIC Register Space better

Extended APIC Register Space is AMD feature which was initially supported
in Jailhouse with a quick hack. It's fixed with this patch: now, the presence
of Extended APIC Register Space is determined as per APMv2, Sect. 16.3.4, and
the number of Extended Local Vector Tables is also determined in runtime.

As all of these is now done inside apic.c, and there is no need to keep
apic_reserved_bits[] public anymore.

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