hw/intc: apic: disallow APIC reads when disabled

!APICBASE_ENABLE + attempting to read xAPIC registers is not an allowed combination.

And neither is x2APIC enabled + attempting to read xAPIC registers

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260422214225.2242-15-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Mohamed Mediouni
2026-04-22 23:42:02 +02:00
committed by Paolo Bonzini
parent fad1e8a98e
commit 72bef33b15

View File

@@ -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 (is_x2apic_mode(s)) {
return 0xffffffff;
}
index = (addr >> 4) & 0xff;
apic_register_read(s, index, &val);