Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Francesco Saverio Pavone" <pavone.lawyer@gmail.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [RFC PATCH 1/3] iommu/rockchip: Report the reserved regions from the devicetree
Date: Fri, 04 Dec 2026 06:44:20 +0000	[thread overview]
Message-ID: <sashiko-outbox-249243@kernel.org> (raw)
In-Reply-To: <172d332977751cca112c89e91aaff8f3ab71c1a0.1796334467.git.pavone.lawyer@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] iommu/rockchip: >4 GiB reserved regions silently alias in
  rk_iommu_map()
--

commit a62eae58527cef7e91d832e94bf0e1249fddc4d9
Author: Francesco Saverio Pavone <pavone.lawyer@gmail.com>

iommu/rockchip: Report the reserved regions from the devicetree

This commit wires of_iommu_get_resv_regions() into rk_iommu_ops so that
devicetree reserved-memory regions listed in iommu-addresses are
reported for Rockchip IOMMUs.

> diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
> index 1fa3110b142ad..757532a86975c 100644
> --- a/drivers/iommu/rockchip-iommu.c
> +++ b/drivers/iommu/rockchip-iommu.c

[ ... ]

> @@ -1204,6 +1205,7 @@ static const struct iommu_ops rk_iommu_ops = {
>  	.probe_device = rk_iommu_probe_device,
>  	.release_device = rk_iommu_release_device,
>  	.device_group = generic_single_device_group,
> +	.get_resv_regions = of_iommu_get_resv_regions,

[Severity: Medium]
Can a devicetree reserved region at or above 4 GiB silently alias into
the low 32-bit IOVA space here?

iommu_create_device_direct_mappings() passes the 64-bit addresses from
of_iommu_get_resv_regions() straight to rk_iommu_iova_to_phys() and
rk_iommu_map() without checking domain->geometry.aperture_end.

Because rk_iova_dte_index() masks the IOVA with 0xffc00000 and casts to
u32, bits 63:32 are silently discarded.  On a 64-bit board with >4 GiB
RAM, a reserved region at or above 4 GiB installs PTEs at the wrapped
low 32-bit IOVA and returns 0 instead of failing.

Meanwhile, iova_reserve_iommu_regions() reserves the >4 GiB PFN range,
leaving the aliased low IOVAs unreserved.  Later DMA allocations in that
range fail with -EADDRINUSE, and DMA to unallocated low IOVAs (including
IOVA 0 for a 4 GiB-aligned region) silently hits the reserved memory.

A Rockchip get_resv_regions wrapper could filter out regions above
DMA_BIT_MASK(32), alongside bounds checks in rk_iommu_map(),
rk_iommu_unmap(), and rk_iommu_iova_to_phys() for the IOVA aperture and
physical address width.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796334467.git.pavone.lawyer@gmail.com?part=1

  parent reply	other threads:[~2026-12-04  6:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  6:24 [RFC PATCH 0/3] rockchip: keep the bootloader framebuffer mapped behind the VOP IOMMU Francesco Saverio Pavone
2026-12-04  6:24 ` [RFC PATCH 1/3] iommu/rockchip: Report the reserved regions from the devicetree Francesco Saverio Pavone
2026-12-04  6:32   ` Chaoyi Chen
2026-12-04  6:44   ` sashiko-bot [this message]
2026-12-04  6:24 ` [RFC PATCH 2/3] dt-bindings: display: vop2: Allow memory-region Francesco Saverio Pavone
2026-12-04  6:24 ` [RFC PATCH 3/3] drm/rockchip: Map the reserved regions 1:1 in the DRM IOMMU domain Francesco Saverio Pavone
2026-12-04  6:48   ` sashiko-bot
2026-12-04  7:14   ` Chaoyi Chen

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=sashiko-outbox-249243@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=pavone.lawyer@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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