From patchwork Thu Mar 26 12:43:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 6098561 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0365BBF910 for ; Thu, 26 Mar 2015 12:47:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 216F6203F7 for ; Thu, 26 Mar 2015 12:47:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5347420394 for ; Thu, 26 Mar 2015 12:47:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yb7Bg-0001LL-71; Thu, 26 Mar 2015 12:47:04 +0000 Received: from 8bytes.org ([81.169.241.247] helo=theia.8bytes.org) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yb78o-00072E-Ne; Thu, 26 Mar 2015 12:44:08 +0000 Received: by theia.8bytes.org (Postfix, from userid 1000) id 36F48374; Thu, 26 Mar 2015 13:43:42 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1427373822; bh=yAqcNDeCP0Ns4r9bAQ84VaAz9URtTAuwGoUXEgrcBfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=No5Oop7EhGIpz13vToMK6n50Wg1RyP+2553UcPXCal7akZXR6Gz9G+EX1trsYPYiv VZSi4kUBTFG/7hrQuJTs6FWX4EPFrta1e3V/H1uFvYsYBi8PmYm0RWnefOhKjrL/XD OfmJDCdaXmsT6QkMiXDrvzS5iv6ppiQ0FNjM8zBpEikl+uDO/oY3NmN+q1+Du8HNRX 4+PKNtsuPNDEi4ueuJ3bfTKkXX0nm9X9GtP3XbyDFZVO8V9KLB1b3JdSEOFFAqGgQ+ PYOV7t75CmHf7To45K1iNbB6PKM/DF4swh1yZ7rr/Y+f1ianPjpC4yZy1EFMNMpDJG kS97KTborJjfw== From: Joerg Roedel To: iommu@lists.linux-foundation.org Subject: [PATCH 03/16] iommu: Only allow iommu_map/unmap for paging domains Date: Thu, 26 Mar 2015 13:43:06 +0100 Message-Id: <1427373799-18662-4-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427373799-18662-1-git-send-email-joro@8bytes.org> References: <1427373799-18662-1-git-send-email-joro@8bytes.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150326_054407_023102_654B1673 X-CRM114-Status: UNSURE ( 7.36 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.1 (/) Cc: Alexandre Courbot , linux-samsung-soc@vger.kernel.org, Heiko Stuebner , Arnd Bergmann , Stephen Warren , Joerg Roedel , Will Deacon , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Alex Williamson , Kukjin Kim , Thierry Reding , jroedel@suse.de, linux-tegra@vger.kernel.org, Yingjoe Chen , David Woodhouse , linux-arm-kernel@lists.infradead.org, Hiroshi Doyu X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel Check for the new __IOMMU_DOMAIN_PAGING flag before calling into the iommu drivers ->map and ->unmap call-backs. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 4920605..656b949 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1063,6 +1063,9 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, domain->ops->pgsize_bitmap == 0UL)) return -ENODEV; + if (unlikely(!(domain->type & __IOMMU_DOMAIN_PAGING))) + return -EINVAL; + /* find out the minimum page size supported */ min_pagesz = 1 << __ffs(domain->ops->pgsize_bitmap); @@ -1114,6 +1117,9 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size) domain->ops->pgsize_bitmap == 0UL)) return -ENODEV; + if (unlikely(!(domain->type & __IOMMU_DOMAIN_PAGING))) + return -EINVAL; + /* find out the minimum page size supported */ min_pagesz = 1 << __ffs(domain->ops->pgsize_bitmap);