Skip to contentSkip to conversation

hw/intc: apic: stop register accesses for invalid situations

PATCH New Mohamed Mediouni 1 participant 1 message Apr 11

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/intc: apic: stop register accesses for invalid situations

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.

---
 hw/intc/apic.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/intc/apic.c +9 -0
index 8766ed00b9..c09dddef39 100644
@@ -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);
 
Signature · 1 line
2.50.1 (Apple Git-155)