From 72bef33b1553497079a5feff9f46c64c7d3f1ad3 Mon Sep 17 00:00:00 2001 From: Mohamed Mediouni Date: Wed, 22 Apr 2026 23:42:02 +0200 Subject: [PATCH] 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 Link: https://lore.kernel.org/r/20260422214225.2242-15-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini --- hw/intc/apic.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 8766ed00b9..e5ea831261 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 (is_x2apic_mode(s)) { + return 0xffffffff; + } + index = (addr >> 4) & 0xff; apic_register_read(s, index, &val);