From patchwork Fri Apr 29 09:05:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 740571 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 p3T95nlX025446 for ; Fri, 29 Apr 2011 09:05:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754197Ab1D2JFp (ORCPT ); Fri, 29 Apr 2011 05:05:45 -0400 Received: from thoth.sbs.de ([192.35.17.2]:26318 "EHLO thoth.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752853Ab1D2JFn (ORCPT ); Fri, 29 Apr 2011 05:05:43 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by thoth.sbs.de (8.13.6/8.13.6) with ESMTP id p3T95Yvr013871; 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 p3T95XVY011781; 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 6/6] pci-assign: Convert need_emulate_cmd into a bitmask Date: Fri, 29 Apr 2011 11:05:33 +0200 Message-Id: <86260105e6e8022c211c466f24aede0ae3b9f13d.1304067929.git.jan.kiszka@siemens.com> 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:49 +0000 (UTC) Define a mask of PCI command register bits that need to be emulated, i.e. read back from their shadow state. We will need this for selectively emulating the INTx mask bit. Note: No initialization of emulate_cmd_mask to zero needed, the device state is already zero-initialized. Signed-off-by: Jan Kiszka --- hw/device-assignment.c | 11 +++++------ hw/device-assignment.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/device-assignment.c b/hw/device-assignment.c index 7db34c4..4625527 100644 --- a/hw/device-assignment.c +++ b/hw/device-assignment.c @@ -533,9 +533,9 @@ again: 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) { + if (pci_dev->emulate_cmd_mask) { val = merge_bits(val, pci_default_read_config(d, address, len), - address, len, PCI_COMMAND, 0xffff); + address, len, PCI_COMMAND, pci_dev->emulate_cmd_mask); } virt_val = pci_default_read_config(d, address, len); @@ -802,10 +802,9 @@ again: /* dealing with virtual function device */ snprintf(name, sizeof(name), "%sphysfn/", dir); - if (!stat(name, &statbuf)) - pci_dev->need_emulate_cmd = 1; - else - pci_dev->need_emulate_cmd = 0; + if (!stat(name, &statbuf)) { + pci_dev->emulate_cmd_mask = 0xffff; + } dev->region_number = r; return 0; diff --git a/hw/device-assignment.h b/hw/device-assignment.h index 86af0a9..ae1bc58 100644 --- a/hw/device-assignment.h +++ b/hw/device-assignment.h @@ -109,7 +109,7 @@ typedef struct AssignedDevice { void *msix_table_page; target_phys_addr_t msix_table_addr; int mmio_index; - int need_emulate_cmd; + uint32_t emulate_cmd_mask; char *configfd_name; int32_t bootindex; QLIST_ENTRY(AssignedDevice) next;