From patchwork Fri Nov 12 02:55:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 318642 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAC2t7t0000634 for ; Fri, 12 Nov 2010 02:55:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753864Ab0KLCzD (ORCPT ); Thu, 11 Nov 2010 21:55:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60682 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753289Ab0KLCzD (ORCPT ); Thu, 11 Nov 2010 21:55:03 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAC2t2NQ031918 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 11 Nov 2010 21:55:02 -0500 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAC2t1hE011414; Thu, 11 Nov 2010 21:55:01 -0500 From: Alex Williamson Subject: [PATCH 1/8] pci: pci_default_cap_write_config ignores wmask To: kvm@vger.kernel.org Cc: qemu-devel@nongnu.org, mst@redhat.com, alex.williamson@redhat.com, chrisw@redhat.com Date: Thu, 11 Nov 2010 19:55:01 -0700 Message-ID: <20101112025456.31423.497.stgit@s20.home> In-Reply-To: <20101112024710.31423.99667.stgit@s20.home> References: <20101112024710.31423.99667.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 12 Nov 2010 02:55:07 +0000 (UTC) diff --git a/hw/pci.c b/hw/pci.c index 92aaa85..12c47ac 100644 --- a/hw/pci.c +++ b/hw/pci.c @@ -1175,13 +1175,14 @@ uint32_t pci_default_read_config(PCIDevice *d, return pci_read_config(d, address, len); } -static void pci_write_config(PCIDevice *pci_dev, - uint32_t address, uint32_t val, int len) +static void pci_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) { int i; - for (i = 0; i < len; i++) { - pci_dev->config[address + i] = val & 0xff; - val >>= 8; + uint32_t config_size = pci_config_size(d); + + for (i = 0; i < l && addr + i < config_size; val >>= 8, ++i) { + uint8_t wmask = d->wmask[addr + i]; + d->config[addr + i] = (d->config[addr + i] & ~wmask) | (val & wmask); } } @@ -1207,18 +1208,14 @@ void pci_default_cap_write_config(PCIDevice *pci_dev, void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l) { - int i, was_irq_disabled = pci_irq_disabled(d); - uint32_t config_size = pci_config_size(d); + int was_irq_disabled = pci_irq_disabled(d); if (pci_access_cap_config(d, addr, l)) { d->cap.config_write(d, addr, val, l); return; } - for (i = 0; i < l && addr + i < config_size; val >>= 8, ++i) { - uint8_t wmask = d->wmask[addr + i]; - d->config[addr + i] = (d->config[addr + i] & ~wmask) | (val & wmask); - } + pci_write_config(d, addr, val, l); #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT if (kvm_enabled() && kvm_irqchip_in_kernel() &&