From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91198C433FE for ; Mon, 7 Dec 2020 10:59:12 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1B35321BE5 for ; Mon, 7 Dec 2020 10:59:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B35321BE5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A67D5877DF; Mon, 7 Dec 2020 10:59:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F-vDlkiCICFX; Mon, 7 Dec 2020 10:59:10 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 54AD587306; Mon, 7 Dec 2020 10:59:10 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 31018C0FA7; Mon, 7 Dec 2020 10:59:10 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id ACFA9C013B for ; Mon, 7 Dec 2020 10:59:08 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 9A71486FB1 for ; Mon, 7 Dec 2020 10:59:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tJaeilaseo5y for ; Mon, 7 Dec 2020 10:59:08 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by whitealder.osuosl.org (Postfix) with ESMTPS id 048D486F90 for ; Mon, 7 Dec 2020 10:59:08 +0000 (UTC) Date: Mon, 7 Dec 2020 10:59:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1607338747; bh=5X4Wa2tCGKFImboi89kNZo+q4agi1Sa5rC9nKY4bhJQ=; h=From:To:Cc:Subject:References:In-Reply-To:From; b=jrzTGziG9p7kWufm4+jEWs1AcM3mYrffolvbVjt22y4jw6bR3+ct20YSRnbiynHtY ZKE4tl6T1gvC3TKkkMTo/b8kXbzkCoXXHxURN09nnRyqZFNrEPrEn83Z41+TK1Zqwk G/615OmtLz2u9VS2i5XQ0/7GIGsucMsjONeks3mxeOu1f+arJCjNu3kaZUeUFxelQr DNGxIeO6iSofrDL7Ns3ta0vdln1BnNkwvVlXYvmKDJTZ/qSrzCa6t+mACfEOgZYdQH frsrxtr2ZGwh5MPOQK6sc+0eE+hXtrY1f3UI29nQvj6YO4X00Zq/0NUDIJzW2ji1UD dX4ymbMZkAhKg== From: Will Deacon To: Keqian Zhu Subject: Re: [PATCH] iommu: Up front sanity check in the arm_lpae_map Message-ID: <20201207105900.GB4198@willie-the-truck> References: <20201205082957.12544-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201205082957.12544-1-zhukeqian1@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Suzuki K Poulose , Marc Zyngier , jiangkunkun@huawei.com, linux-kernel@vger.kernel.org, Sean Christopherson , Alexios Zavras , iommu@lists.linux-foundation.org, Mark Brown , James Morse , Julien Thierry , Catalin Marinas , wanghaibin.wang@huawei.com, Thomas Gleixner , Robin Murphy , Andrew Morton , linux-arm-kernel@lists.infradead.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Sat, Dec 05, 2020 at 04:29:57PM +0800, Keqian Zhu wrote: > ... then we have more chance to detect wrong code logic. This could do with being a bit more explicit. Something like: 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.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > 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; This looks sensible to me, but please can you make the same change for io-pgtable-arm-v7s.c so that the behaviour is consistent across the two formats? Thanks, Will _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu