Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1084883ybl; Wed, 21 Aug 2019 09:54:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwaXZ2ZPgR9EHrSRY+uFmGfZl5hIsLfpFtb1dX0UuU1Ssf7hFyhO645EzvaGyReWmS07AuI X-Received: by 2002:aa7:8dcc:: with SMTP id j12mr36958520pfr.137.1566406479131; Wed, 21 Aug 2019 09:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566406479; cv=none; d=google.com; s=arc-20160816; b=h5a46bcBA0NT+vMGUF345lsALAu2Czc+Ua2tBKnfJcBVE8MbpBARQIbF1jUyiBQP3B kqCI+2Y3BYw2LKp5AvJ6zZncvDWqyiSeNBd/GJOX/EUSG6iztT2Jk+XjcRSVlHpAV7ix Vp7mQpeGkJT1agy/bBy444DbrwzYB24i50JV1uHHEaayjmkTxCR1EIgxRW2O/AfTl0Xm aSCAVPJABJzcHgm2TO5+A6mfJfPcFjVzF7Te8vhFtmVcls4zLvIJRXAnoX+DnlMiTlJx M3/c24oOrhrmaXCKJK10H9yXenHqDSYYBXSnvHs1N/FhV+08wKmrch4J5cqM2aTDidnA te/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=pJ/GXB9UzhPPrnm68QjubO4ftZY8YEnu20uFxDmEFTY=; b=YaeD3jZe8dyN7QXuV+UenejECnnWIV0ywTjCU3KfmVnHELReIV82ruaMIoCI6bPecJ vYA4/xvF8DNUb1zWql108GnkPUTFSCc6xuTGSl/5jLSHJO4fsWx+id+fXSFGOEp2VlGe 17+aLcX8/F8Z9DiebbZ/k0/EVgP1dZDXfTtbRTtJhirTcIvIlqNuBqzFR4qflE8hjX2/ xLqzxz4qA91hE547jXQzaOwMgGONALWz9tm2sdBnJdCGnQHSozPI3Cf+PUuq0mwc/D1S PRL8WgjqkwPg9Enk4ARBGGuk1OvhHwqpfIXErFxjdo+qU5YKMIoY4aA4nUEFq79brrgV lVBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 78si3561840pga.419.2019.08.21.09.54.23; Wed, 21 Aug 2019 09:54:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbfHUNzS (ORCPT + 99 others); Wed, 21 Aug 2019 09:55:18 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:56526 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729114AbfHUNzS (ORCPT ); Wed, 21 Aug 2019 09:55:18 -0400 X-UUID: 8f3dea1f210946af885448893f51ac04-20190821 X-UUID: 8f3dea1f210946af885448893f51ac04-20190821 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 147302319; Wed, 21 Aug 2019 21:55:10 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 21 Aug 2019 21:55:08 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 21 Aug 2019 21:55:07 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Robin Murphy , Will Deacon CC: Rob Herring , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Matthias Kaehlcke , , , Subject: [PATCH v10 07/23] iommu/io-pgtable-arm-v7s: Use ias/oas to check the valid iova/pa Date: Wed, 21 Aug 2019 21:53:10 +0800 Message-ID: <1566395606-7975-8-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1566395606-7975-1-git-send-email-yong.wu@mediatek.com> References: <1566395606-7975-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use ias/oas to check the valid iova/pa. Synchronize this checking with io-pgtable-arm.c. Signed-off-by: Yong Wu --- drivers/iommu/io-pgtable-arm-v7s.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 72f1880..fa1b38f 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -504,7 +504,8 @@ static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned long iova, if (!(prot & (IOMMU_READ | IOMMU_WRITE))) return 0; - if (WARN_ON(upper_32_bits(iova) || upper_32_bits(paddr))) + if (WARN_ON(iova >= (1ULL << data->iop.cfg.ias) || + paddr >= (1ULL << data->iop.cfg.oas))) return -ERANGE; ret = __arm_v7s_map(data, iova, paddr, size, prot, 1, data->pgd); -- 1.9.1