From patchwork Thu Jan 24 00:46:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 215084 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 0CAC12C007B for ; Thu, 24 Jan 2013 11:46:30 +1100 (EST) Received: from localhost ([::1]:46642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyAxY-0000dW-Hh for incoming@patchwork.ozlabs.org; Wed, 23 Jan 2013 19:46:28 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59490) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyAxR-0000dR-C5 for qemu-devel@nongnu.org; Wed, 23 Jan 2013 19:46:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TyAxM-0006Vi-Ei for qemu-devel@nongnu.org; Wed, 23 Jan 2013 19:46:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:30324) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TyAxM-0006VW-7v for qemu-devel@nongnu.org; Wed, 23 Jan 2013 19:46:16 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0O0kEGr027299 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 23 Jan 2013 19:46:14 -0500 Received: from bling.home ([10.3.113.8]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0O0kERl006703; Wed, 23 Jan 2013 19:46:14 -0500 To: alex.williamson@redhat.com, qemu-devel@nongnu.org From: Alex Williamson Date: Wed, 23 Jan 2013 17:46:13 -0700 Message-ID: <20130124004551.3605.2059.stgit@bling.home> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH] vfio-pci: Enable PCIe extended config space 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 We don't know pre-init time whether the device we're exposing is PCIe or legacy PCI. We could ask for it to be specified via a device option, but that seems like too much to ask of the user. Instead we can assume everything will be PCIe, which makes PCI-core allocate enough config space. Removing the flag during init leaves the space allocated, but allows legacy PCI devices to report the real device config space size to rest of Qemu. Signed-off-by: Alex Williamson Acked-by: Michael S. Tsirkin --- hw/vfio_pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c index c51ae67..66537b7 100644 --- a/hw/vfio_pci.c +++ b/hw/vfio_pci.c @@ -1899,6 +1899,9 @@ static int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vdev) (unsigned long)reg_info.flags); vdev->config_size = reg_info.size; + if (vdev->config_size == PCI_CONFIG_SPACE_SIZE) { + vdev->pdev.cap_present &= ~QEMU_PCI_CAP_EXPRESS; + } vdev->config_offset = reg_info.offset; error: @@ -2121,6 +2124,7 @@ static void vfio_pci_dev_class_init(ObjectClass *klass, void *data) pdc->exit = vfio_exitfn; pdc->config_read = vfio_pci_read_config; pdc->config_write = vfio_pci_write_config; + pdc->is_express = 1; /* We might be */ } static const TypeInfo vfio_pci_dev_info = {