diff options
author | Robin Murphy <robin.murphy@arm.com> | 2019-10-25 19:08:32 +0100 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2019-11-04 19:34:31 +0000 |
commit | 67f3e53d2a37ab27b00610eb25724103055beafc (patch) | |
tree | 9b6e8eec7a44f1785e46cd606a2f455ef9c3a86c /drivers/iommu/io-pgtable-arm.c | |
parent | f7b90d2c7422a815c094961751582347935045cd (diff) | |
download | lwn-67f3e53d2a37ab27b00610eb25724103055beafc.tar.gz lwn-67f3e53d2a37ab27b00610eb25724103055beafc.zip |
iommu/io-pgtable-arm: Simplify bounds checks
We're merely checking that the relevant upper bits of each address
are all zero, so there are cheaper ways to achieve that.
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'drivers/iommu/io-pgtable-arm.c')
-rw-r--r-- | drivers/iommu/io-pgtable-arm.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index abe794576e8f..5da3cbdb76f7 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -491,8 +491,7 @@ static int arm_lpae_map(struct io_pgtable_ops *ops, unsigned long iova, if (WARN_ON(!size || (size & cfg->pgsize_bitmap) != size)) return -EINVAL; - if (WARN_ON(iova >= (1ULL << data->iop.cfg.ias) || - paddr >= (1ULL << data->iop.cfg.oas))) + if (WARN_ON(iova >> data->iop.cfg.ias || paddr >> data->iop.cfg.oas)) return -ERANGE; prot = arm_lpae_prot_to_pte(data, iommu_prot); @@ -663,7 +662,7 @@ static size_t arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova, if (WARN_ON(!size || (size & cfg->pgsize_bitmap) != size)) return 0; - if (WARN_ON(iova >= (1ULL << data->iop.cfg.ias))) + if (WARN_ON(iova >> data->iop.cfg.ias)) return 0; return __arm_lpae_unmap(data, gather, iova, size, lvl, ptep); |