From patchwork Tue Nov 17 23:41:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 545810 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 1F01C14141A for ; Wed, 18 Nov 2015 10:41:36 +1100 (AEDT) Received: from localhost ([::1]:32898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZypsU-0008CT-4S for incoming@patchwork.ozlabs.org; Tue, 17 Nov 2015 18:41:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZypsB-0007qL-7n for qemu-devel@nongnu.org; Tue, 17 Nov 2015 18:41:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zyps8-0001mZ-21 for qemu-devel@nongnu.org; Tue, 17 Nov 2015 18:41:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46119) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zyps7-0001lk-RL for qemu-devel@nongnu.org; Tue, 17 Nov 2015 18:41:11 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id F1BB78A031; Tue, 17 Nov 2015 23:41:10 +0000 (UTC) Received: from gimli.home (ovpn-113-92.phx2.redhat.com [10.3.113.92]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAHNf9ZC014030; Tue, 17 Nov 2015 18:41:10 -0500 From: Alex Williamson To: alex.williamson@redhat.com Date: Tue, 17 Nov 2015 16:41:09 -0700 Message-ID: <20151117234028.23385.99569.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Ronnie Swanink , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] vfio/pci-quirks: Only quirk to size of PCI 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 For quirks that support the full PCIe extended config space, limit the quirk to only the size of config space available through vfio. This allows host systems with broken MMCONFIG regions to still make use of these quirks without generating bad address faults trying to access beyond the end of config space exposed through vfio. This may expose direct access to parts of extended config space that we'd prefer not to expose, but that's why we have an IOMMU. Signed-off-by: Alex Williamson Reported-by: Ronnie Swanink Reviewed-by: Laszlo Ersek --- hw/vfio/pci-quirks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 30c68a1..e117c41 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -328,7 +328,7 @@ static void vfio_probe_ati_bar4_quirk(VFIOPCIDevice *vdev, int nr) window->data_offset = 4; window->nr_matches = 1; window->matches[0].match = 0x4000; - window->matches[0].mask = PCIE_CONFIG_SPACE_SIZE - 1; + window->matches[0].mask = vdev->config_size - 1; window->bar = nr; window->addr_mem = &quirk->mem[0]; window->data_mem = &quirk->mem[1]; @@ -674,7 +674,7 @@ static void vfio_probe_nvidia_bar5_quirk(VFIOPCIDevice *vdev, int nr) window->matches[0].match = 0x1800; window->matches[0].mask = PCI_CONFIG_SPACE_SIZE - 1; window->matches[1].match = 0x88000; - window->matches[1].mask = PCIE_CONFIG_SPACE_SIZE - 1; + window->matches[1].mask = vdev->config_size - 1; window->bar = nr; window->addr_mem = bar5->addr_mem = &quirk->mem[0]; window->data_mem = bar5->data_mem = &quirk->mem[1]; @@ -765,7 +765,7 @@ static void vfio_probe_nvidia_bar0_quirk(VFIOPCIDevice *vdev, int nr) memory_region_init_io(mirror->mem, OBJECT(vdev), &vfio_nvidia_mirror_quirk, mirror, "vfio-nvidia-bar0-88000-mirror-quirk", - PCIE_CONFIG_SPACE_SIZE); + vdev->config_size); memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem, mirror->offset, mirror->mem, 1);