Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1426546ybl; Fri, 23 Aug 2019 20:09:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3skQVUYCI8KmFvnecRSBVCyHDgSNwC2fTj+UvVZJcxMLsveX0xs3qvOrxicH7zmmz1t8a X-Received: by 2002:a63:6f41:: with SMTP id k62mr6670844pgc.32.1566616152901; Fri, 23 Aug 2019 20:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566616152; cv=none; d=google.com; s=arc-20160816; b=nLyL0z0GtbOgN/b5UA5OsbRybdkWu7Ty/VRHRFWTBuPL95H8fA0Lqr/v2LMh60FiqN a2W2bYWpbUVOeF0IpG6o6ZTVU8uqbSMsxCBauP/EkQaKD2y/8hH0/sku5sJ96tphWnQ0 xUf8YEhmq7oCGh95lVWrHWeen/N8V628xb8svsP65E9mnr6UGF5N6Bj/6W2xUmdK3L1i vgb/UtjEEqedWw6azLYkyXVhL2MVBdHNp32scr5TJAmKkZo4fCnRzWG47mGbYfb/f9vb zqj3jeTGoJHaCH0ucWVJ6l3Tv4rIy5Cr9+QI2iLrvi8NCGKAPbhJojzmwyZdtRRqiUvX HCzw== 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=p8MoA5nYGsM1e1qJxEyEbz/Vspql1BlbxvkEyXSo3hY=; b=IaR5kv/eNm18JIcSyAi9BlK/D/LyoWPUCtfW4xG1yP1QzpSchRRbenV56imXzv+gsS UAJK0Ro3gPCbaTu5DmfoqdQmS0g5djo9E8nC08rO6rbwy/OsnDMQe/anCW5EaxS0YWIn mmOkMJi6Mr6k7jhcvDZShFU+LAUGVfkbk1jEuHjYBtubcrsSbSb8rX62CmsZVMiKY9Bc wBxM2eq2lIaq7yPEu8NwKvqkzCEeXgyukUt5idrge0iyq+dIIairYHOZH1uhqb1c9gQv g7BvcFFV5c/6Lrk7YznJvr4Irfb8xqf1uuv2+3NPoMH5WM1qYzTfEP6s07Ar4TI7V72l exqg== 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 t21si3298156pga.294.2019.08.23.20.08.57; Fri, 23 Aug 2019 20:09:12 -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 S1726999AbfHXDEN (ORCPT + 99 others); Fri, 23 Aug 2019 23:04:13 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:9458 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725930AbfHXDEN (ORCPT ); Fri, 23 Aug 2019 23:04:13 -0400 X-UUID: d2384303602e40d98ee421874bf114b4-20190824 X-UUID: d2384303602e40d98ee421874bf114b4-20190824 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.10 Build 0707 with TLS) with ESMTP id 1671727869; Sat, 24 Aug 2019 11:04:04 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sat, 24 Aug 2019 11:03:56 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Sat, 24 Aug 2019 11:03:55 +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 v11 07/23] iommu/io-pgtable-arm-v7s: Use ias/oas to check the valid iova/pa Date: Sat, 24 Aug 2019 11:01:52 +0800 Message-ID: <1566615728-26388-8-git-send-email-yong.wu@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1566615728-26388-1-git-send-email-yong.wu@mediatek.com> References: <1566615728-26388-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 Acked-by: Will Deacon --- 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