From patchwork Sat Oct 30 16:59:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 292242 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 o9UH22aG031880 for ; Sat, 30 Oct 2010 17:02:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755114Ab0J3Q7u (ORCPT ); Sat, 30 Oct 2010 12:59:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58853 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755935Ab0J3Q7p (ORCPT ); Sat, 30 Oct 2010 12:59:45 -0400 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 o9UGxO3u008135 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 30 Oct 2010 12:59:25 -0400 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 o9UGxOJs028698; Sat, 30 Oct 2010 12:59:24 -0400 From: Alex Williamson Subject: [PATCH 2/5] vfio: Fix requested regions To: pugs@cisco.com Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, avi@redhat.com, chrisw@redhat.com, mst@redhat.com, alex.williamson@redhat.com Date: Sat, 30 Oct 2010 10:59:23 -0600 Message-ID: <20101030165917.885.98984.stgit@s20.home> In-Reply-To: <20101030164626.885.89216.stgit@s20.home> References: <20101030164626.885.89216.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]); Sat, 30 Oct 2010 17:02:02 +0000 (UTC) diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c index 3b7d352..f671795 100644 --- a/drivers/vfio/vfio_main.c +++ b/drivers/vfio/vfio_main.c @@ -316,6 +316,18 @@ static int vfio_mmap(struct file *filep, struct vm_area_struct *vma) if (requested > actual || actual == 0) return -EINVAL; + /* + * Even though we don't make use of the barmap for the mmap, + * we need to request the region and the barmap tracks that. + */ + if (!vdev->barmap[pci_space]) { + ret = pci_request_selected_regions(pdev, (1 << pci_space), + vdev->name); + if (ret) + return ret; + vdev->barmap[pci_space] = pci_iomap(pdev, pci_space, 0); + } + start = vma->vm_pgoff << PAGE_SHIFT; len = vma->vm_end - vma->vm_start; if (allow_unsafe_intrs && (vma->vm_flags & VM_WRITE)) { diff --git a/drivers/vfio/vfio_rdwr.c b/drivers/vfio/vfio_rdwr.c index b75bf92..83ae38a 100644 --- a/drivers/vfio/vfio_rdwr.c +++ b/drivers/vfio/vfio_rdwr.c @@ -67,7 +67,7 @@ ssize_t vfio_io_readwrite( int ret; ret = pci_request_selected_regions(pdev, - (1 << pci_space), "vfio"); + (1 << pci_space), vdev->name); if (ret) return ret; vdev->barmap[pci_space] = pci_iomap(pdev, pci_space, 0); @@ -164,7 +164,7 @@ ssize_t vfio_mem_readwrite( int ret; ret = pci_request_selected_regions(pdev, - (1 << pci_space), "vfio"); + (1 << pci_space), vdev->name); if (ret) return ret; vdev->barmap[pci_space] =