Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 1 | From 4829da131996548dc86775b8b97a29c436f3d130 Mon Sep 17 00:00:00 2001 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2 | From: Mark Asselstine <mark.asselstine@windriver.com> |
| 3 | Date: Tue, 26 Feb 2013 11:43:28 -0500 |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 4 | Subject: [PATCH] apic: fixup fallthrough to PIC |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5 | |
| 6 | Commit 0e21e12bb311c4c1095d0269dc2ef81196ccb60a [Don't route PIC |
| 7 | interrupts through the local APIC if the local APIC config says so.] |
| 8 | missed a check to ensure the local APIC is enabled. Since if the local |
| 9 | APIC is disabled it doesn't matter what the local APIC config says. |
| 10 | |
| 11 | If this check isn't done and the guest has disabled the local APIC the |
| 12 | guest will receive a general protection fault, similar to what is seen |
| 13 | here: |
| 14 | |
| 15 | https://lists.gnu.org/archive/html/qemu-devel/2012-12/msg02304.html |
| 16 | |
| 17 | The GPF is caused by an attempt to service interrupt 0xffffffff. This |
| 18 | comes about since cpu_get_pic_interrupt() calls apic_accept_pic_intr() |
| 19 | (with the local APIC disabled apic_get_interrupt() returns -1). |
| 20 | apic_accept_pic_intr() returns 0 and thus the interrupt number which |
| 21 | is returned from cpu_get_pic_interrupt(), and which is attempted to be |
| 22 | serviced, is -1. |
| 23 | |
| 24 | Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com> |
| 25 | Upstream-Status: Submitted [https://lists.gnu.org/archive/html/qemu-devel/2013-04/msg00878.html] |
| 26 | Signed-off-by: He Zhe <zhe.he@windriver.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 27 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 28 | --- |
| 29 | hw/intc/apic.c | 2 +- |
| 30 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 31 | |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 32 | diff --git a/hw/intc/apic.c b/hw/intc/apic.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 33 | index 97ffdd82..ef23430e 100644 |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 34 | --- a/hw/intc/apic.c |
| 35 | +++ b/hw/intc/apic.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 36 | @@ -603,7 +603,7 @@ int apic_accept_pic_intr(DeviceState *dev) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 37 | APICCommonState *s = APIC(dev); |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 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]; |