From: sashiko-bot@kernel.org
To: "Chen-Yu Tsai" <wens@kernel.org>
Cc: conor+dt@kernel.org, linux-sunxi@lists.linux.dev,
robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 6/7] arm64: dts: allwinner: sun50i-h6: Add missing IOMMU for video engine
Date: Sat, 11 Jul 2026 14:08:13 +0000 [thread overview]
Message-ID: <20260711140814.5C4071F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260711135959.3616919-7-wens@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The sun50i-iommu driver fails to properly detach domains from the hardware due to an unbalanced refcount, leading to a use-after-free of the domain structure.
- [High] The sun50i-iommu driver assigns a separate IOMMU group/domain per device despite the hardware only supporting a single global translation table, causing devices to overwrite each other's page tables.
--
--- Patch [6]: [PATCH v2 6/7] arm64: dts: allwinner: sun50i-h6: Add missing IOMMU for video engine ---
commit 8a79dfe07f469620b0b60592b02052d1c198fe97
Author: Chen-Yu Tsai <wens@kernel.org>
arm64: dts: allwinner: sun50i-h6: Add missing IOMMU for video engine
This commit adds a missing IOMMU port ("VE_R") to the video engine node
in the sun50i-h6 device tree.
> diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> index 88c6e3e105c07..48c771223af4d 100644
> --- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> +++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
> @@ -206,7 +206,7 @@ video-codec@1c0e000 {
> resets = <&ccu RST_BUS_VE>;
> interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
> allwinner,sram = <&ve_sram 1>, <&de2_sram 1>;
> - iommus = <&iommu 3>;
> + iommus = <&iommu 3>, <&iommu 1>;
[Severity: High]
This is a pre-existing issue, but does adding a second IOMMU trigger a
use-after-free during device unbind?
Looking at the sun50i-iommu driver, sun50i_iommu_domain_alloc_paging() sets
the domain refcount to 1:
drivers/iommu/sun50i-iommu.c:sun50i_iommu_domain_alloc_paging() {
...
refcount_set(&sun50i_domain->refcnt, 1);
...
}
Later, when a device is detached, sun50i_iommu_identity_attach()
decrements it:
drivers/iommu/sun50i-iommu.c:sun50i_iommu_identity_attach() {
...
sun50i_domain = to_sun50i_domain(iommu->domain);
if (refcount_dec_and_test(&sun50i_domain->refcnt))
sun50i_iommu_detach_domain(iommu, sun50i_domain);
...
}
Because the reference count drops from 2 to 1 here, it fails to reach 0 and
bypasses the domain detachment. This leaves iommu->domain as a dangling
pointer which is later freed by sun50i_iommu_domain_free(). Could this
cause a kernel panic on a subsequent IOMMU page fault interrupt since it
dereferences the freed pointer?
[Severity: High]
This isn't a bug introduced by this patch, but does adding another IOMMU
reference here break DMA due to a single global translation table?
The sun50i-iommu driver assigns a separate IOMMU group per device:
drivers/iommu/sun50i-iommu.c:
static const struct iommu_ops sun50i_iommu_ops = {
...
.device_group = generic_single_device_group,
...
};
Since the hardware only supports a single global translation table
(IOMMU_TTB_REG), placing every device into its own independent group and
domain means multiple devices will repeatedly overwrite the shared IOMMU's
domain on probe. Will enabling this second IOMMU port overwrite previously
configured translation tables and corrupt memory for other devices?
> };
>
> gpu: gpu@1800000 {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260711135959.3616919-1-wens@kernel.org?part=6
next prev parent reply other threads:[~2026-07-11 14:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 13:59 [PATCH v2 0/7] arm64: allwinner: h616: Support Video Engine Chen-Yu Tsai
2026-07-11 13:59 ` [PATCH v2 1/7] dt-bindings: media: sun4i-a10-video-engine: Fix IOMMU count for H6 Chen-Yu Tsai
2026-07-11 13:59 ` [PATCH v2 2/7] dt-bindings: media: sun4i-a10-video-engine: Fix SRAM " Chen-Yu Tsai
2026-07-11 13:59 ` [PATCH v2 3/7] dt-bindings: media: sun4i-a10-video-engine: Add H616 compatible Chen-Yu Tsai
2026-07-11 13:59 ` [PATCH v2 4/7] drivers: staging: media: sunxi: cedrus: add H616 variant Chen-Yu Tsai
2026-07-11 13:59 ` [PATCH v2 5/7] arm64: dts: allwinner: sun50i-h6: Add missing SRAM region for video engine Chen-Yu Tsai
2026-07-11 14:08 ` sashiko-bot
2026-07-11 14:51 ` Chen-Yu Tsai
2026-07-11 13:59 ` [PATCH v2 6/7] arm64: dts: allwinner: sun50i-h6: Add missing IOMMU " Chen-Yu Tsai
2026-07-11 14:08 ` sashiko-bot [this message]
2026-07-11 13:59 ` [PATCH v2 7/7] arm64: dts: allwinner: sun50i-h616: Add " Chen-Yu Tsai
2026-07-11 14:11 ` sashiko-bot
2026-07-11 15:13 ` Andre Przywara
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=20260711140814.5C4071F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wens@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