blob: 034ac57821de468e73a1c147c961126c077b27a3 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001From a59a98d100123030a4145e7efe3b8a001920a9f1 Mon Sep 17 00:00:00 2001
Brad Bishopc342db32019-05-15 21:57:59 -04002From: Mark Asselstine <mark.asselstine@windriver.com>
3Date: Tue, 26 Feb 2013 11:43:28 -0500
4Subject: [PATCH] apic: fixup fallthrough to PIC
5
6Commit 0e21e12bb311c4c1095d0269dc2ef81196ccb60a [Don't route PIC
7interrupts through the local APIC if the local APIC config says so.]
8missed a check to ensure the local APIC is enabled. Since if the local
9APIC is disabled it doesn't matter what the local APIC config says.
10
11If this check isn't done and the guest has disabled the local APIC the
12guest will receive a general protection fault, similar to what is seen
13here:
14
15https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg02304.html
16
17The GPF is caused by an attempt to service interrupt 0xffffffff. This
18comes about since cpu_get_pic_interrupt() calls apic_accept_pic_intr()
19(with the local APIC disabled apic_get_interrupt() returns -1).
20apic_accept_pic_intr() returns 0 and thus the interrupt number which
21is returned from cpu_get_pic_interrupt(), and which is attempted to be
22serviced, is -1.
23
24Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
25Upstream-Status: Submitted [https://lists.gnu.org/archive/html/qemu-devel/2013-04/msg00878.html]
26Signed-off-by: He Zhe <zhe.he@windriver.com>
27
28---
29 hw/intc/apic.c | 2 +-
30 1 file changed, 1 insertion(+), 1 deletion(-)
31
Andrew Geissler635e0e42020-08-21 15:58:33 -050032Index: qemu-5.1.0/hw/intc/apic.c
33===================================================================
34--- qemu-5.1.0.orig/hw/intc/apic.c
35+++ qemu-5.1.0/hw/intc/apic.c
36@@ -603,7 +603,7 @@ int apic_accept_pic_intr(DeviceState *de
Brad Bishopc342db32019-05-15 21:57:59 -040037 APICCommonState *s = APIC(dev);
38 uint32_t lvt0;
39
40- if (!s)
41+ if (!s || !(s->spurious_vec & APIC_SV_ENABLE))
42 return -1;
43
44 lvt0 = s->lvt[APIC_LVT_LINT0];