From: Will Deacon <will@kernel.org>
To: Keqian Zhu <zhukeqian1@huawei.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>,
Marc Zyngier <maz@kernel.org>,
jiangkunkun@huawei.com, linux-kernel@vger.kernel.org,
Sean Christopherson <sean.j.christopherson@intel.com>,
Alexios Zavras <alexios.zavras@intel.com>,
iommu@lists.linux-foundation.org, Mark Brown <broonie@kernel.org>,
James Morse <james.morse@arm.com>,
Julien Thierry <julien.thierry.kdev@gmail.com>,
Catalin Marinas <catalin.marinas@arm.com>,
wanghaibin.wang@huawei.com, Thomas Gleixner <tglx@linutronix.de>,
Robin Murphy <robin.murphy@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] iommu: Up front sanity check in the arm_lpae_map
Date: Mon, 7 Dec 2020 10:59:01 +0000 [thread overview]
Message-ID: <20201207105900.GB4198@willie-the-truck> (raw)
In-Reply-To: <20201205082957.12544-1-zhukeqian1@huawei.com>
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 <zhukeqian1@huawei.com>
> ---
> 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
next prev parent reply other threads:[~2020-12-07 10:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-05 8:29 [PATCH] iommu: Up front sanity check in the arm_lpae_map Keqian Zhu
2020-12-07 10:59 ` Will Deacon [this message]
2020-12-07 11:37 ` zhukeqian
2020-12-07 12:01 ` Robin Murphy
2020-12-07 12:05 ` Will Deacon
2020-12-07 12:15 ` zhukeqian
2020-12-07 12:46 ` Robin Murphy
2020-12-07 13:36 ` zhukeqian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201207105900.GB4198@willie-the-truck \
--to=will@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexios.zavras@intel.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=iommu@lists.linux-foundation.org \
--cc=james.morse@arm.com \
--cc=jiangkunkun@huawei.com \
--cc=julien.thierry.kdev@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=robin.murphy@arm.com \
--cc=sean.j.christopherson@intel.com \
--cc=suzuki.poulose@arm.com \
--cc=tglx@linutronix.de \
--cc=wanghaibin.wang@huawei.com \
--cc=zhukeqian1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).