kvm-unit-tests's apic.c tests for:
!APICBASE_ENABLE + attempting to read xAPIC registers is not an allowed
combination.
And neither is x2APIC enabled + attempting to read xAPIC registers
This was tested on WHPX with kernel-irqchip=off with x2APIC emulation
enabled (in a posted series) and TCG.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
---
hw/intc/apic.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/hw/intc/apic.c b/hw/intc/apic.c
index 8766ed00b9..c09dddef39 100644
--- a/hw/intc/apic.c
+++ b/hw/intc/apic.c
@@ -875,6 +875,15 @@ static uint64_t apic_mem_read(void *opaque, hwaddr addr, unsigned size)
return -1;
}
+ /* if the xAPIC is disabled, return early. */
+ if (!(s->apicbase & MSR_IA32_APICBASE_ENABLE)) {
+ return 0xffffffff;
+ }
+
+ if (s->apicbase & MSR_IA32_APICBASE_EXTD) {
+ return 0xffffffff;
+ }
+
index = (addr >> 4) & 0xff;
apic_register_read(s, index, &val);
--
2.50.1 (Apple Git-155)