[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <94799248-f9d1-3a2e-6b82-23d613d4e74b@huawei.com>
Date: Mon, 7 Dec 2020 19:37:04 +0800
From: zhukeqian <zhukeqian1@...wei.com>
To: Will Deacon <will@...nel.org>
CC: <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<iommu@...ts.linux-foundation.org>, Marc Zyngier <maz@...nel.org>,
"Robin Murphy" <robin.murphy@....com>,
Joerg Roedel <joro@...tes.org>,
"Catalin Marinas" <catalin.marinas@....com>,
James Morse <james.morse@....com>,
"Suzuki K Poulose" <suzuki.poulose@....com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
Julien Thierry <julien.thierry.kdev@...il.com>,
Mark Brown <broonie@...nel.org>,
"Thomas Gleixner" <tglx@...utronix.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Alexios Zavras <alexios.zavras@...el.com>,
<wanghaibin.wang@...wei.com>, <jiangkunkun@...wei.com>
Subject: Re: [PATCH] iommu: Up front sanity check in the arm_lpae_map
Hi Will,
On 2020/12/7 18:59, Will Deacon wrote:
> 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.
This looks well, thanks.
>
>> Signed-off-by: Keqian Zhu <zhukeqian1@...wei.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?
>
OK. I can do it right now.
Thanks,
Keqian
> Thanks,
>
> Will
> .
>
Powered by blists - more mailing lists