From: Simon Xue <xxm@rock-chips.com>
To: "Joerg Roedel (AMD)" <joro@8bytes.org>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Heiko Stuebner <heiko@sntech.de>
Cc: Simon Xue <xxm@rock-chips.com>,
iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] iommu/rockchip: Reject unsupported physical addresses
Date: Tue, 25 Aug 2026 17:21:32 +0800 [thread overview]
Message-ID: <20260825092132.154150-3-xxm@rock-chips.com> (raw)
In-Reply-To: <20260825092132.154150-1-xxm@rock-chips.com>
A paddr with bits above the range the hardware can address is silently
truncated, pointing the device at the wrong page. Reject it using
paddr_mask before writing any PTE.
Signed-off-by: Simon Xue <xxm@rock-chips.com>
---
drivers/iommu/rockchip-iommu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 9a5aabb2b9c8..93dde18ce33d 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -794,6 +794,10 @@ static int rk_iommu_map_iova(struct rk_iommu_domain *rk_domain, u32 *pte_addr,
assert_spin_locked(&rk_domain->dt_lock);
+ /* Reject addresses the hardware cannot support */
+ if ((paddr + size - 1) & ~rk_domain->rk_ops->paddr_mask)
+ return -ERANGE;
+
for (pte_count = 0; pte_count < pte_total; pte_count++) {
u32 pte = pte_addr[pte_count];
--
2.34.1
prev parent reply other threads:[~2026-08-25 9:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 9:21 [PATCH 0/2] iommu/rockchip: turn rk_iommu_ops into data Simon Xue
2026-08-25 9:21 ` [PATCH 1/2] iommu/rockchip: Reduce rk_iommu_ops to pure data Simon Xue
2026-08-25 9:21 ` Simon Xue [this message]
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=20260825092132.154150-3-xxm@rock-chips.com \
--to=xxm@rock-chips.com \
--cc=heiko@sntech.de \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/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