* [PATCH v2] iommu: Defer the early return in arm_(v7s/lpae)_map
@ 2020-12-07 11:57 Keqian Zhu
2020-12-08 14:20 ` Robin Murphy
2020-12-08 15:54 ` Will Deacon
0 siblings, 2 replies; 3+ messages in thread
From: Keqian Zhu @ 2020-12-07 11:57 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, iommu
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, wanghaibin.wang, jiangkunkun,
Keqian Zhu
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-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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] iommu: Defer the early return in arm_(v7s/lpae)_map
2020-12-07 11:57 [PATCH v2] iommu: Defer the early return in arm_(v7s/lpae)_map Keqian Zhu
@ 2020-12-08 14:20 ` Robin Murphy
2020-12-08 15:54 ` Will Deacon
1 sibling, 0 replies; 3+ messages in thread
From: Robin Murphy @ 2020-12-08 14:20 UTC (permalink / raw)
To: Keqian Zhu, linux-kernel, linux-arm-kernel, iommu
Cc: Will Deacon, Marc Zyngier, Joerg Roedel, Catalin Marinas,
James Morse, Suzuki K Poulose, Sean Christopherson,
Julien Thierry, Mark Brown, Thomas Gleixner, Andrew Morton,
Alexios Zavras, wanghaibin.wang, jiangkunkun
On 2020-12-07 11:57, Keqian Zhu wrote:
> 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.
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Keqian Zhu <zhukeqian1@huawei.com>
> ---
> 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);
> /*
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] iommu: Defer the early return in arm_(v7s/lpae)_map
2020-12-07 11:57 [PATCH v2] iommu: Defer the early return in arm_(v7s/lpae)_map Keqian Zhu
2020-12-08 14:20 ` Robin Murphy
@ 2020-12-08 15:54 ` Will Deacon
1 sibling, 0 replies; 3+ messages in thread
From: Will Deacon @ 2020-12-08 15:54 UTC (permalink / raw)
To: iommu, Keqian Zhu, linux-arm-kernel, linux-kernel
Cc: catalin.marinas, kernel-team, Will Deacon, Joerg Roedel,
Suzuki K Poulose, jiangkunkun, wanghaibin.wang,
Sean Christopherson, Robin Murphy, Andrew Morton, Mark Brown,
Marc Zyngier, Thomas Gleixner, Julien Thierry, Alexios Zavras,
James Morse
On Mon, 7 Dec 2020 19:57:58 +0800, Keqian Zhu wrote:
> 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.
Applied to arm64 (for-next/iommu/misc), thanks!
[1/1] iommu: Defer the early return in arm_(v7s/lpae)_map
https://git.kernel.org/arm64/c/f12e0d22903e
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-08 15:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 11:57 [PATCH v2] iommu: Defer the early return in arm_(v7s/lpae)_map Keqian Zhu
2020-12-08 14:20 ` Robin Murphy
2020-12-08 15:54 ` Will Deacon
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).