@samitouri / QOSamiQemu / commits / 72bef33b15

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>

Mohamed Mediouni committed Apr 22, 2026 at 23:42 UTC 72bef33b1553497079a5feff9f46c64c7d3f1ad3
1 file changed +9
hw/intc/apic.c
+9
@@ -875,6 +875,15 @@ static uint64_t apic_mem_read(void *opaque, hwaddr addr, unsigned size)
875 return -1;
876 }
877
878 + /* if the xAPIC is disabled, return early. */
879 + if (!(s->apicbase & MSR_IA32_APICBASE_ENABLE)) {
880 + return 0xffffffff;
881 + }
882 +
883 + if (is_x2apic_mode(s)) {
884 + return 0xffffffff;
885 + }
886 +
887 index = (addr >> 4) & 0xff;
888 apic_register_read(s, index, &val);
889