From patchwork Tue Sep 4 14:42:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 181598 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 5592C2C00A0 for ; Wed, 5 Sep 2012 00:43:13 +1000 (EST) Received: from localhost ([::1]:60987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8uLP-0005Rj-Fy for incoming@patchwork.ozlabs.org; Tue, 04 Sep 2012 10:43:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8uLD-0005Pm-AZ for qemu-devel@nongnu.org; Tue, 04 Sep 2012 10:43:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8uL3-0000gT-Pk for qemu-devel@nongnu.org; Tue, 04 Sep 2012 10:42:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27928) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8uL3-0000gK-Fv for qemu-devel@nongnu.org; Tue, 04 Sep 2012 10:42:49 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q84EgfQD021733 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 Sep 2012 10:42:41 -0400 Received: from yakj.usersys.redhat.com (ovpn-112-23.ams2.redhat.com [10.36.112.23]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q84EgZl2030974; Tue, 4 Sep 2012 10:42:39 -0400 Message-ID: <5046135B.2080200@redhat.com> Date: Tue, 04 Sep 2012 16:42:35 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: "Maciej W. Rozycki" References: <1346640974-30974-1-git-send-email-mmogilvi_qemu@miniinfo.net> <1346640974-30974-6-git-send-email-mmogilvi_qemu@miniinfo.net> <50446F9A.4070809@web.de> In-Reply-To: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Jan Kiszka , Matthew Ogilvie , qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH v4 5/5] i8259: fix dynamically masking slave IRQs with IMR register 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 Il 04/09/2012 16:29, Maciej W. Rozycki ha scritto: > So first of all, the *output* of the 8259A is always edge triggered, > regardless of whether it's the master or one of the slaves (only one slave > is used in the PC/AT architecture, but up to eight are supported; the > PC/XT had none). I swear I read all your message :) but this seems to be the crux. It means that something like this ought to fix the bug too. Matthew, can you post your code or test it? Both patches untested. Paolo diff --git a/hw/i8259.c b/hw/i8259.c index 53daf78..3dc1dff 100644 --- a/hw/i8259.c +++ b/hw/i8259.c @@ -104,12 +104,11 @@ static void pic_update_irq(PICCommonState *s) int irq; irq = pic_get_irq(s); + qemu_irq_lower(s->int_out[0]); if (irq >= 0) { DPRINTF("pic%d: imr=%x irr=%x padd=%d\n", s->master ? 0 : 1, s->imr, s->irr, s->priority_add); qemu_irq_raise(s->int_out[0]); - } else { - qemu_irq_lower(s->int_out[0]); } } The logic of the in-kernel 8259 is a bit different, but something like this should do it, too: diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c index 81cf4fa..feb6d5b 100644 --- a/arch/x86/kvm/i8259.c +++ b/arch/x86/kvm/i8259.c @@ -174,9 +174,11 @@ static void pic_update_irq(struct kvm_pic *s) /* * if irq request by slave pic, signal master PIC */ + pic_set_irq1(&s->pics[0], 2, 0); pic_set_irq1(&s->pics[0], 2, 1); + } else if (s->pics[0].irr & (1 << 2)) pic_set_irq1(&s->pics[0], 2, 0); - } + irq = pic_get_irq(&s->pics[0]); pic_irq_request(s->kvm, irq >= 0); }