From patchwork Fri Apr 29 09:05:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 740551 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 p3T95iGr025388 for ; Fri, 29 Apr 2011 09:05:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753570Ab1D2JFl (ORCPT ); Fri, 29 Apr 2011 05:05:41 -0400 Received: from david.siemens.de ([192.35.17.14]:18846 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752403Ab1D2JFj (ORCPT ); Fri, 29 Apr 2011 05:05:39 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.13.6/8.13.6) with ESMTP id p3T95Ysw005216; Fri, 29 Apr 2011 11:05:34 +0200 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id p3T95XVV011781; Fri, 29 Apr 2011 11:05:34 +0200 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Cc: kvm@vger.kernel.org, Alex Williamson Subject: [PATCH v2 3/6] pci-assign: Fix dword read at PCI_COMMAND Date: Fri, 29 Apr 2011 11:05:30 +0200 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: 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.6 (demeter1.kernel.org [140.211.167.41]); Fri, 29 Apr 2011 09:05:44 +0000 (UTC) If we emulate the command register, we must only read its content from the shadow config space. For dword read of both PCI_COMMAND and PCI_STATUS, at least the latter must be read from the device. For simplicity reasons and as the code path is not considered performance critical for the affected SRIOV devices, the fix performes device access to the command word unconditionally, even if emulation is enabled and only that word is read. Signed-off-by: Jan Kiszka --- hw/device-assignment.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index ea1d7f1..cea072e 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -482,14 +482,11 @@ static uint32_t assigned_dev_pci_read_config(PCIDevice *d, uint32_t address, /* * Catch access to * - vendor & device ID - * - command register (if emulation needed) * - base address registers * - ROM base address & capability pointer * - interrupt line & pin */ if (ranges_overlap(address, len, PCI_VENDOR_ID, 4) || - (pci_dev->need_emulate_cmd && - ranges_overlap(address, len, PCI_COMMAND, 2)) || ranges_overlap(address, len, PCI_BASE_ADDRESS_0, 24) || ranges_overlap(address, len, PCI_ROM_ADDRESS, 5) || ranges_overlap(address, len, PCI_INTERRUPT_LINE, 2)) { @@ -521,6 +518,11 @@ do_log: DEBUG("(%x.%x): address=%04x val=0x%08x len=%d\n", (d->devfn >> 3) & 0x1F, (d->devfn & 0x7), address, val, len); + if (pci_dev->need_emulate_cmd) { + val = merge_bits(val, pci_default_read_config(d, address, len), + address, len, PCI_COMMAND, 0xffff); + } + if (!pci_dev->cap.available) { /* kill the special capabilities */ if (address == PCI_COMMAND && len == 4) {