From patchwork Fri Feb 28 17:23:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 325294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 10A482C00B5 for ; Sat, 1 Mar 2014 04:26:53 +1100 (EST) Received: from localhost ([::1]:52476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJRD0-00051R-RG for incoming@patchwork.ozlabs.org; Fri, 28 Feb 2014 12:26:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJRCW-0004pJ-Vb for qemu-devel@nongnu.org; Fri, 28 Feb 2014 12:26:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WJRCR-0007F8-D2 for qemu-devel@nongnu.org; Fri, 28 Feb 2014 12:26:20 -0500 Received: from mail-qc0-x236.google.com ([2607:f8b0:400d:c01::236]:51639) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WJRCQ-0007EY-W9 for qemu-devel@nongnu.org; Fri, 28 Feb 2014 12:26:15 -0500 Received: by mail-qc0-f182.google.com with SMTP id e16so1084476qcx.13 for ; Fri, 28 Feb 2014 09:26:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=UxgAougWdvoQUMpqs+0bHWr2El7lBUsFgXRHKhQ74aw=; b=MxRdHQ9lcEUfov0fzL1hCY9AMp+RkgosxJM7OvLFKioYHay8dwOTZdtSQZ7fKw0CHY uXXMej1epfTlZyp5SDlV1sjCVP1LRVPUPCpcyRcnX0qbDydYmSN6Bkl/W7t6LC6AsTue NTVtC4dNQRYMzGeo9UGgNiGANMp30iq9RaHgbqbvqpaewW2AcxnAuFvAkWvtRz2FlqAZ fIk4E/UZMJZE2CZwkB6v2Yl4521TldvxhZmL0DtdDdPuhY3wOEaYN+sXb0HpES/TT0RV z77QmfPKHRcJIuKjcxt6DjMu0ttcmX9UsxxQfHMlsRJTR7z+T+ZR8sdfCuQaeKz1o1KO fOtA== X-Received: by 10.140.98.33 with SMTP id n30mr5213907qge.8.1393608373957; Fri, 28 Feb 2014 09:26:13 -0800 (PST) Received: from ERROL.INI.CMU.EDU (ERROL.INI.CMU.EDU. [128.2.16.43]) by mx.google.com with ESMTPSA id r7sm3151174qgr.17.2014.02.28.09.26.13 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 28 Feb 2014 09:26:13 -0800 (PST) Date: Fri, 28 Feb 2014 12:23:44 -0500 From: "Gabriel L. Somlo" To: qemu-devel@nongnu.org Message-ID: <20140228172343.GI17184@ERROL.INI.CMU.EDU> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140228040617.GA22103@crash.ini.cmu.edu> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c01::236 Cc: pbonzini@redhat.com, agraf@suse.de, mst@redhat.com Subject: [Qemu-devel] [RFC PATCH] qemu: x86: ignore ioapic polarity 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 Both QEMU and KVM have already accumulated a significant number of optimizations based on the hard-coded assumption that ioapic polarity will always use the ActiveHigh convention, where the logical and physical states of level-triggered irq lines always match (i.e., active(asserted) == high == 1, inactive == low == 0). QEMU guests are expected to follow directions given via ACPI and configure the ioapic with polarity 0 (ActiveHigh). However, even when misbehaving guests (e.g. OS X <= 10.9) set the ioapic polarity to 1 (ActiveLow), QEMU will still use the ActiveHigh signaling convention when interfacing with KVM. This patch modifies QEMU to completely ignore ioapic polarity as set by the guest OS, enabling misbehaving guests to work alongside those which comply with the ActiveHigh polarity specified by QEMU's ACPI tables. Signed-off-by: Gabriel L. Somlo --- On Fri, Feb 28, 2014 at 09:11:08AM +0100, Paolo Bonzini wrote: > Il 28/02/2014 05:55, Michael S. Tsirkin ha scritto: > >Or we can do a patch like we did for kvm and ignore polarity, > >treating levels as logical rather than physical. > > Yes. OK, this would "harmonize" TCG with KVM, in terms of acknowledging the realities of hard-coded ActiveHigh behavior throughout the rest of the code base. Let me know what you think. Thanks, Gabriel hw/intc/ioapic.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index 652dd47..b527932 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -93,9 +93,6 @@ static void ioapic_set_irq(void *opaque, int vector, int level) uint32_t mask = 1 << vector; uint64_t entry = s->ioredtbl[vector]; - if (entry & (1 << IOAPIC_LVT_POLARITY_SHIFT)) { - level = !level; - } if (((entry >> IOAPIC_LVT_TRIGGER_MODE_SHIFT) & 1) == IOAPIC_TRIGGER_LEVEL) { /* level triggered */