Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2331519pxu; Mon, 7 Dec 2020 04:01:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyeg2beC+IV6GL2a0pQwcf9L8cDgXw4lEOo3HwbI0hHdPtk/24Y4QgaNAaryR5XGoyQzgnP X-Received: by 2002:a17:906:6606:: with SMTP id b6mr18402833ejp.151.1607342511707; Mon, 07 Dec 2020 04:01:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607342511; cv=none; d=google.com; s=arc-20160816; b=S5UWbmre9cA3X35L4MM456XFBqupzuenycG3NMrW+TNFlZiF7K0WonRlc1GxiTBTrP yoqft+Mng24KUetQsFnLseIfecC7kEkFeGEYLXrlgLViFLLGmsiRVwcQLPtLINzWrVd6 wamP27KPaFZl3AJeSEJWc51kUzOy6k9POgE8xQlFGKO3fXewgaaVP6styK87ggm3zoFb 41wZklIa7YOopIXPmoQ1LXoCc4/QskvnycYt9zKA5D0MRufqK9eDuLRc10ve5hVzpk5e ylOX8o/1JcB+x8DKROfVhY/QHIPIvLJiKg1Ov1JsTJZgdLK2OhftrEqlBx71mF2hUqJb jYMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=ihZe90lX918PuJJ2pbWbBXiHR/yNP7XsfxT/6RP1hB4=; b=XLD07DW0UlxsCOTRLx8KnsZStdNOYgBO3VxVTslDzmluFFCA/YwqNoX+UUCviesn3w ylDLwEnBpgFfWVoLHqn9WMEZRo0dA5DUiD1r4Edkh47Jl6mUw/4QuISPEhMmoOhrvYuQ l7or0vRR5V6YUo1GmLzxKKs7GQZLN/qi0GrLzzZdAPuNySxC994uYdB7YSG5SYM2hS+P gwmT83yPTw6B7487PNh6l6salCYcMvEpwA/ifWb3Ep59aJjLfqhIvo9XsiJCjcRQ6Cf8 SFgOlUTDI1UG5bPosoCQPJt5t957t/x81sQIDKDV0c2gQKi+05EL6fhcAJaCNID/jhba BT1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs1si9381978edb.320.2020.12.07.04.01.24; Mon, 07 Dec 2020 04:01:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727099AbgLGL7A (ORCPT + 99 others); Mon, 7 Dec 2020 06:59:00 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8719 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727096AbgLGL7A (ORCPT ); Mon, 7 Dec 2020 06:59:00 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CqMHz0MXpzklsJ; Mon, 7 Dec 2020 19:57:35 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.187.37) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Mon, 7 Dec 2020 19:58:06 +0800 From: Keqian Zhu To: , , CC: Will Deacon , Marc Zyngier , Robin Murphy , Joerg Roedel , Catalin Marinas , James Morse , "Suzuki K Poulose" , Sean Christopherson , Julien Thierry , Mark Brown , "Thomas Gleixner" , Andrew Morton , Alexios Zavras , , , Keqian Zhu Subject: [PATCH v2] iommu: Defer the early return in arm_(v7s/lpae)_map Date: Mon, 7 Dec 2020 19:57:58 +0800 Message-ID: <20201207115758.9400-1-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.37] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Although handling a mapping request with no permissions is a trivial no-op, defer the early return until after the size/range checks so that we are consistent with other mapping requests. Signed-off-by: Keqian Zhu --- drivers/iommu/io-pgtable-arm-v7s.c | 8 ++++---- drivers/iommu/io-pgtable-arm.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index a688f22cbe3b..359b96b0fa3e 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -522,14 +522,14 @@ static int arm_v7s_map(struct io_pgtable_ops *ops, unsigned long iova, struct io_pgtable *iop = &data->iop; int ret; - /* If no access, then nothing to do */ - if (!(prot & (IOMMU_READ | IOMMU_WRITE))) - return 0; - if (WARN_ON(iova >= (1ULL << data->iop.cfg.ias) || paddr >= (1ULL << data->iop.cfg.oas))) return -ERANGE; + /* If no access, then nothing to do */ + if (!(prot & (IOMMU_READ | IOMMU_WRITE))) + return 0; + ret = __arm_v7s_map(data, iova, paddr, size, prot, 1, data->pgd, gfp); /* * Synchronise all PTE updates for the new mapping before there's diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index a7a9bc08dcd1..8ade72adab31 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -444,10 +444,6 @@ static int arm_lpae_map(struct io_pgtable_ops *ops, unsigned long iova, arm_lpae_iopte prot; long iaext = (s64)iova >> cfg->ias; - /* If no access, then nothing to do */ - if (!(iommu_prot & (IOMMU_READ | IOMMU_WRITE))) - return 0; - if (WARN_ON(!size || (size & cfg->pgsize_bitmap) != size)) return -EINVAL; @@ -456,6 +452,10 @@ static int arm_lpae_map(struct io_pgtable_ops *ops, unsigned long iova, if (WARN_ON(iaext || paddr >> cfg->oas)) return -ERANGE; + /* If no access, then nothing to do */ + if (!(iommu_prot & (IOMMU_READ | IOMMU_WRITE))) + return 0; + prot = arm_lpae_prot_to_pte(data, iommu_prot); ret = __arm_lpae_map(data, iova, paddr, size, prot, lvl, ptep, gfp); /* -- 2.23.0