From patchwork Sat Apr 9 11:18:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 90461 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 64C30B6F14 for ; Sat, 9 Apr 2011 21:20:38 +1000 (EST) Received: from localhost ([127.0.0.1]:41218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8WDT-0002hQ-D9 for incoming@patchwork.ozlabs.org; Sat, 09 Apr 2011 07:20:35 -0400 Received: from [140.186.70.92] (port=37867 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8WCE-0002ct-Ef for qemu-devel@nongnu.org; Sat, 09 Apr 2011 07:19:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q8WCC-0007t8-Bh for qemu-devel@nongnu.org; Sat, 09 Apr 2011 07:19:17 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:42672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q8WCC-0007sW-0z for qemu-devel@nongnu.org; Sat, 09 Apr 2011 07:19:16 -0400 Received: from smtp02.web.de ( [172.20.0.184]) by fmmailgate02.web.de (Postfix) with ESMTP id C3EBC19BF777B; Sat, 9 Apr 2011 13:18:59 +0200 (CEST) Received: from [88.65.39.184] (helo=mchn199C.mchp.siemens.de) by smtp02.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #2) id 1Q8WBv-0000hw-00; Sat, 09 Apr 2011 13:18:59 +0200 Message-ID: <4DA040A3.2070309@web.de> Date: Sat, 09 Apr 2011 13:18:59 +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: Isaku Yamahata , Aurelien Jarno References: <20110403195314.GB23034@volta.aurel32.net> <20110403234207.GD11748@valinux.co.jp> <20110404021511.GF11748@valinux.co.jp> <4DA01AF2.3040309@web.de> <20110409110549.GA23309@valinux.co.jp> In-Reply-To: <20110409110549.GA23309@valinux.co.jp> X-Enigmail-Version: 1.1.2 X-Sender: jan.kiszka@web.de X-Provags-ID: V01U2FsdGVkX1/XRaj8D5Lc/6/E/LdVFq2MK6GWsDrxc5jJX3MN Pwbnmg1sFPqLmWR0yBI7NubqhXKDCz3sEQ4mlgaRCMq9IpnC4t Q16eWQhfk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.227 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] ioapic: Do not set irr for masked edge IRQs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 2011-04-09 13:05, Isaku Yamahata wrote: > On Sat, Apr 09, 2011 at 10:38:10AM +0200, Jan Kiszka wrote: >> On 2011-04-04 04:15, Isaku Yamahata wrote: >>> On Mon, Apr 04, 2011 at 08:42:07AM +0900, Isaku Yamahata wrote: >>>>> Thank you for applying. But I found that the patch is wrong and >>>>> I'm preparing the new one. Can you please revert it? >>> Here is the corrected patch. The first wrong patch clears the interrupts >>> bit unconditionally. Which caused losing interrupt. >>> >>> From 5ed177d35ab14f3b070a0eba2c49400279a3a14b Mon Sep 17 00:00:00 2001 >>> Message-Id: <5ed177d35ab14f3b070a0eba2c49400279a3a14b.1301883258.git.yamahata@valinux.co.jp> >>> In-Reply-To: >>> References: >>> From: Isaku Yamahata >>> Date: Wed, 16 Mar 2011 14:00:13 +0900 >>> Subject: [PATCH 01/30] ioapic: when switches to level trigger mode, interrupts raised repeatedly. >>> >>> - the trigger mode is edge at first by reset. >>> - During initializatoin, the interrupt is raised as edge which is masked. >>> The corresponding bit of irr is set. >> >> ...and that is the actual problem. The spec says: "Interrupt Mask?R/W. >> When this bit is 1, the interrupt signal is masked. Edge-sensitive >> interrupts signaled on a masked interrupt pin are ignored (i.e., not >> delivered or held pending)." >> >> So this should do the trick in a correct way (untested, please >> validate): > > Thank you for referring the spec. It works. > Here's the updated patch with your signed-off-by and my tested-by. Thanks for testing. I would prefer the following more compact wordings. Jan ---------8<---------- From: Jan Kiszka So far we set IRR for edge IRQs even if the pin is masked. If the guest later on unmasks and switches the pin to level-triggered mode, irr will remain set, causing an IRQ storm. The point is that setting IRR is not correct in this case according to the spec, and avoiding this resolves the issue. Reported-and-tested-by: Isaku Yamahata Signed-off-by: Jan Kiszka --- hw/ioapic.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/ioapic.c b/hw/ioapic.c index 569327d..6c26e82 100644 --- a/hw/ioapic.c +++ b/hw/ioapic.c @@ -160,8 +160,9 @@ static void ioapic_set_irq(void *opaque, int vector, int level) s->irr &= ~mask; } } else { - /* edge triggered */ - if (level) { + /* According to the 82093AA manual, we must ignore edge requests + * if the input pin is masked. */ + if (level && !(entry & IOAPIC_LVT_MASKED)) { s->irr |= mask; ioapic_service(s); }