From patchwork Sat Aug 27 14:16:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 111878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3563CB70B7 for ; Sun, 28 Aug 2011 00:16:51 +1000 (EST) Received: from localhost ([::1]:33098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QxJgi-0005gp-LK for incoming@patchwork.ozlabs.org; Sat, 27 Aug 2011 10:16:44 -0400 Received: from eggs.gnu.org ([140.186.70.92]:47616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QxJga-0005fQ-4I for qemu-devel@nongnu.org; Sat, 27 Aug 2011 10:16:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QxJgY-0003VN-Rh for qemu-devel@nongnu.org; Sat, 27 Aug 2011 10:16:36 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:52301) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QxJgY-0003VJ-EE for qemu-devel@nongnu.org; Sat, 27 Aug 2011 10:16:34 -0400 Received: from smtp02.web.de ( [172.20.0.184]) by fmmailgate02.web.de (Postfix) with ESMTP id F0C401A9362D2; Sat, 27 Aug 2011 16:16:32 +0200 (CEST) Received: from [88.65.42.74] (helo=mchn199C.mchp.siemens.de) by smtp02.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1QxJgW-0007wQ-00; Sat, 27 Aug 2011 16:16:32 +0200 Message-ID: <4E58FC3F.6080809@web.de> Date: Sat, 27 Aug 2011 16:16:31 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Anthony Liguori , qemu-devel X-Enigmail-Version: 1.3.1 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX19XRYDqyji5MXKo6q/UrFduolqgl6fFKPAFT+Tz E2Y2NfIZHVtzNDxFcGEyRkTUPvCBjU6bba5beNg3gE3AR0eEX0 PfYia6/hw= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.227 Cc: Lucas Meneghel Rodrigues , Marcelo Tosatti , Avi Kivity , Gerd Hoffmann Subject: [Qemu-devel] [PATCH] pc: Clean up PIC-to-APIC IRQ path 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 From: Jan Kiszka The master PIC is connected to the LINTIN0 of the APICs. As the APIC currently does not track the state of that line, we have to ask the PIC to re-inject its IRQ after the CPU picked up an event from the APIC. Adds the proper state tracking so that we can already re-assert the CPU IRQ at APIC level if there is a pending PIC IRQ. This allows to remove all the old workarounds. The patch also fixes some failures of the kvm unit tests apic and eventinj by enabling a proper CPU IRQ deassert when the guest masks some pending IRQs at PIC level. Signed-off-by: Jan Kiszka --- It turned out that this patch from a larger cleanup series has no dependencies and can be applied directly to master to fix the observed bug. hw/apic.c | 4 +++- hw/i8259.c | 10 ++-------- hw/pc.c | 3 --- hw/pc.h | 1 - 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/hw/apic.c b/hw/apic.c index d8f56c8..22ad635 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -104,6 +104,7 @@ struct APICState { QEMUTimer *timer; int sipi_vector; int wait_for_sipi; + int pic_level; }; static APICState *local_apics[MAX_APICS + 1]; @@ -186,6 +187,7 @@ void apic_deliver_pic_intr(DeviceState *d, int level) { APICState *s = DO_UPCAST(APICState, busdev.qdev, d); + s->pic_level = level; if (level) { apic_local_deliver(s, APIC_LVT_LINT0); } else { @@ -397,7 +399,7 @@ static void apic_update_irq(APICState *s) if (!(s->spurious_vec & APIC_SV_ENABLE)) { return; } - if (apic_irq_pending(s) > 0) { + if (apic_irq_pending(s) > 0 || s->pic_level) { cpu_interrupt(s->cpu_env, CPU_INTERRUPT_HARD); } } diff --git a/hw/i8259.c b/hw/i8259.c index c0b96ab..cc6f76b 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -144,8 +144,7 @@ static int pic_get_irq(PicState *s) /* raise irq to CPU if necessary. must be called every time the active irq may change */ -/* XXX: should not export it, but it is needed for an APIC kludge */ -void pic_update_irq(PicState2 *s) +static void pic_update_irq(PicState2 *s) { int irq2, irq; @@ -172,14 +171,9 @@ void pic_update_irq(PicState2 *s) printf("pic: cpu_interrupt\n"); #endif qemu_irq_raise(s->parent_irq); - } - -/* all targets should do this rather than acking the IRQ in the cpu */ -#if defined(TARGET_MIPS) || defined(TARGET_PPC) || defined(TARGET_ALPHA) - else { + } else { qemu_irq_lower(s->parent_irq); } -#endif } #ifdef DEBUG_IRQ_LATENCY diff --git a/hw/pc.c b/hw/pc.c index 263fb1a..b7b5d6f 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -156,9 +156,6 @@ int cpu_get_pic_interrupt(CPUState *env) intno = apic_get_interrupt(env->apic_state); if (intno >= 0) { - /* set irq request if a PIC irq is still pending */ - /* XXX: improve that */ - pic_update_irq(isa_pic); return intno; } /* read the irq from the PIC */ diff --git a/hw/pc.h b/hw/pc.h index dae736e..f5ff4c0 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -65,7 +65,6 @@ void pic_set_irq(int irq, int level); void pic_set_irq_new(void *opaque, int irq, int level); qemu_irq *i8259_init(qemu_irq parent_irq); int pic_read_irq(PicState2 *s); -void pic_update_irq(PicState2 *s); uint32_t pic_intack_read(PicState2 *s); void pic_info(Monitor *mon); void irq_info(Monitor *mon);