]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/intc: apic: disallow APIC reads when disabled
authorMohamed Mediouni <mohamed@unpredictable.fr>
Wed, 22 Apr 2026 21:42:02 +0000 (23:42 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 30 Apr 2026 15:55:03 +0000 (17:55 +0200)
!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>
hw/intc/apic.c

index 8766ed00b92aedace4895bbacd40146454c1db4f..e5ea8312617d463cffb4ee28a790856b3df99b6e 100644 (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);