From patchwork Tue May 28 16:27:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 246921 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 DBE972C02F5 for ; Wed, 29 May 2013 02:28:25 +1000 (EST) Received: from localhost ([::1]:36419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhMl5-0001ox-S3 for incoming@patchwork.ozlabs.org; Tue, 28 May 2013 12:28:23 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhMkm-0001nD-O2 for qemu-devel@nongnu.org; Tue, 28 May 2013 12:28:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhMke-0003fD-BR for qemu-devel@nongnu.org; Tue, 28 May 2013 12:28:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhMke-0003f3-34 for qemu-devel@nongnu.org; Tue, 28 May 2013 12:27:56 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4SGRr1e010152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 28 May 2013 12:27:53 -0400 Received: from bling.home (ovpn-113-181.phx2.redhat.com [10.3.113.181]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4SGRqMw000675; Tue, 28 May 2013 12:27:53 -0400 To: alex.williamson@redhat.com From: Alex Williamson Date: Tue, 28 May 2013 10:27:52 -0600 Message-ID: <20130528162637.28848.76733.stgit@bling.home> In-Reply-To: <20130524171613.14229.84050.stgit@bling.home> References: <20130524171613.14229.84050.stgit@bling.home> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kvm@vger.kernel.org, konrad.wilk@oracle.com, linux-kernel@vger.kernel.org, qemu-devel@nongnu.org, iommu@lists.linux-foundation.org, chegu_vinod@hp.com Subject: [Qemu-devel] [PATCH 3/2] vfio: Provide module option to disable vfio_iommu_type1 hugepage support 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 Add a module option to vfio_iommu_type1 to disable IOMMU hugepage support. This causes iommu_map to only be called with single page mappings, disabling the IOMMU driver's ability to use hugepages. This option can be enabled by loading vfio_iommu_type1 with disable_hugepages=1 or dynamically through sysfs. If enabled dynamically, only new mappings are restricted. Signed-off-by: Alex Williamson Reviewed-by: Konrad Rzeszutek Wilk Tested-by: Chegu Vinod --- As suggested by Konrad. This is cleaner to add as a follow-on drivers/vfio/vfio_iommu_type1.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 6654a7e..8a2be4e 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -48,6 +48,12 @@ module_param_named(allow_unsafe_interrupts, MODULE_PARM_DESC(allow_unsafe_interrupts, "Enable VFIO IOMMU support for on platforms without interrupt remapping support."); +static bool disable_hugepages; +module_param_named(disable_hugepages, + disable_hugepages, bool, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(disable_hugepages, + "Disable VFIO IOMMU support for IOMMU hugepages."); + struct vfio_iommu { struct iommu_domain *domain; struct mutex lock; @@ -270,6 +276,11 @@ static long vfio_pin_pages(unsigned long vaddr, long npage, return -ENOMEM; } + if (unlikely(disable_hugepages)) { + vfio_lock_acct(1); + return 1; + } + /* Lock all the consecutive pages from pfn_base */ for (i = 1, vaddr += PAGE_SIZE; i < npage; i++, vaddr += PAGE_SIZE) { unsigned long pfn = 0;