From patchwork Mon Jul 9 14:42:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 169865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8E11B2C0203 for ; Tue, 10 Jul 2012 00:43:00 +1000 (EST) Received: from localhost ([::1]:55197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoFAw-00081W-Dm for incoming@patchwork.ozlabs.org; Mon, 09 Jul 2012 10:42:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoFAi-0007t9-H4 for qemu-devel@nongnu.org; Mon, 09 Jul 2012 10:42:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoFAb-0001GC-Qv for qemu-devel@nongnu.org; Mon, 09 Jul 2012 10:42:44 -0400 Received: from goliath.siemens.de ([192.35.17.28]:25222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoFAb-0001FN-H4 for qemu-devel@nongnu.org; Mon, 09 Jul 2012 10:42:37 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id q69EgXBo025247; Mon, 9 Jul 2012 16:42:33 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q69EgWkA022363; Mon, 9 Jul 2012 16:42:33 +0200 From: Jan Kiszka To: qemu-devel Date: Mon, 9 Jul 2012 16:42:30 +0200 Message-Id: X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.28 Cc: Gleb Natapov , Marcelo Tosatti , Avi Kivity , kvm , Anthony Liguori Subject: [Qemu-devel] [PATCH 1/3] apic: Resolve potential endless loop around apic_update_irq X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Commit d96e173769 refactored the reinjection of pending PIC interrupts. However, it missed the potential loop of apic_update_irq -> apic_deliver_pic_intr -> apic_local_deliver -> apic_set_irq -> apic_update_irq that /could/ occur if LINT0 is injected as APIC_DM_FIXED and that vector is currently blocked via TPR. Resolve this by reinjecting only where it matters: inside apic_get_interrupt. This function may clear a vector while a PIC-originated reason still exists. Signed-off-by: Jan Kiszka --- hw/apic.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/apic.c b/hw/apic.c index 60552df..e65a35f 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -363,9 +363,6 @@ static void apic_update_irq(APICCommonState *s) } if (apic_irq_pending(s) > 0) { cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD); - } else if (apic_accept_pic_intr(&s->busdev.qdev) && - pic_get_output(isa_pic)) { - apic_deliver_pic_intr(&s->busdev.qdev, 1); } } @@ -560,7 +557,14 @@ int apic_get_interrupt(DeviceState *d) reset_bit(s->irr, intno); set_bit(s->isr, intno); apic_sync_vapic(s, SYNC_TO_VAPIC); + + /* re-inject if there is still a pending PIC interrupt */ + if (apic_accept_pic_intr(&s->busdev.qdev) && pic_get_output(isa_pic)) { + apic_deliver_pic_intr(&s->busdev.qdev, 1); + } + apic_update_irq(s); + return intno; }