All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vikash Garodia" <vikash.garodia@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org,
	media-ci@linuxtv.org
Subject: Re: [PATCH 22/22] arm64: dts: qcom: talos: Reserve low IOVA range for Venus
Date: Fri, 07 Aug 2026 09:08:08 +0000	[thread overview]
Message-ID: <20260807090809.0ED401F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807-iris_iova_600mb_fix-v1-22-3996f67e33f9@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the parsing loop in `of_iommu_get_resv_regions` fails to properly advance the `maps` pointer when a tuple's `phandle` does not match the target device, leading to corrupt parsing and potential out-of-bounds reads.
- [High] This problem wasn't introduced by this patch, but an unchecked return value from `of_translate_dma_region()` in `of_iommu_get_resv_regions()` leads to uninitialized stack variable usage and a NULL pointer dereference.
--

--- Patch [22]: [PATCH 22/22] arm64: dts: qcom: talos: Reserve low IOVA range for Venus ---
commit c79264714a3878505bc5105c9bc703dbf039cc23
Author: Vikash Garodia <vikash.garodia@oss.qualcomm.com>

arm64: dts: qcom: talos: Reserve low IOVA range for Venus

This commit adds a reserved-memory IOVA reservation node for the Venus VPU
and references it to keep DMA allocations above 0x25800000. This prevents
unhandled SMMU page faults and spontaneous device reboots.

> diff --git a/arch/arm64/boot/dts/qcom/talos.dtsi b/arch/arm64/boot/dts/qcom/talos.dtsi
> index eedfdce3c479e..8645b04e26643 100644
> --- a/arch/arm64/boot/dts/qcom/talos.dtsi
> +++ b/arch/arm64/boot/dts/qcom/talos.dtsi
> @@ -687,6 +687,17 @@ adsp_rpc_remote_heap_mem: adsp-rpc-remote-heap {
>  			alignment = <0x0 0x400000>;
>  			size = <0x0 0x800000>;
>  		};
> +
> +		/*
> +		 * The Venus VPU reserves IOVA below 0x25800000 (600MB),
> +		 * primarily for non-pixel buffers using different Stream IDs.
> +		 * DMA into that range triggers unhandled SMMU faults and
> +		 * spontaneous reboots, so reserve it to keep IOMMU
> +		 * allocations above this boundary.
> +		 */
> +		venus_iova: venus-iova {
> +			iommu-addresses = <&venus 0x0 0x0 0x0 0x25800000>;

[Severity: High]
This isn't a bug introduced by this patch, but does adding an
iommu-addresses property expose an existing parsing issue in
of_iommu_get_resv_regions()?

When parsing the iommu-addresses property, if a tuple's phandle does not
match dev->of_node, the loop skips the match block but fails to properly
advance the maps pointer past the current tuple's address and size cells:

drivers/iommu/of_iommu.c:of_iommu_get_resv_regions() {
    ...
    while (maps < end) {
        phandle = be32_to_cpup(maps++);
        np = of_find_node_by_phandle(phandle);
        
        if (np == dev->of_node) {
            ...
        }
        /* maps is not advanced by address/size cells if np != dev->of_node */
    }
    ...
}

Could this lead to the next iteration incorrectly treating part of the DMA
address as the next phandle, resulting in out-of-bounds reads or corrupt
parsing?

[Severity: High]
This is also a pre-existing issue, but could parsing this property lead to a
NULL pointer dereference if of_translate_dma_region() fails?

If of_translate_dma_region() returns NULL (e.g. due to missing dma-ranges
or a malformed DT), the return value is assigned directly to maps without
a NULL check:

drivers/iommu/of_iommu.c:of_iommu_get_resv_regions() {
    ...
    maps = of_translate_dma_region(np, maps, &iova, &length);
    if (length == 0) {
    ...
}

Since length is evaluated without initialization if the translation fails,
and maps becomes NULL, could the subsequent loop iteration dereference the
NULL maps pointer when reading the next phandle?

drivers/iommu/of_iommu.c:of_iommu_get_resv_regions() {
    ...
    while (maps < end) {
        phandle = be32_to_cpup(maps++);
    ...
}

> +		};
>  	};

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260807-iris_iova_600mb_fix-v1-0-3996f67e33f9@oss.qualcomm.com?part=22

  reply	other threads:[~2026-08-07  9:08 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5BXSXMNl656WiJPJAMmHvb3I2NzYMshRZuGuub3CxEXvdCUlIDKYbnv5jUq-pa6P1NibBLkO3njnKGxi7Al3jQ==@protonmail.internalid>
2026-08-07  8:24 ` [PATCH 00/22] media: iris: Restrict lower IOVA range for Venus and Iris VPUs Vikash Garodia
2026-08-07  8:24   ` [PATCH 01/22] dt-bindings: media: qcom,venus-common: Allow IOVA reservation memory-region Vikash Garodia
2026-08-07  8:49     ` sashiko-bot
2026-08-07  8:51       ` Vikash Garodia
2026-08-07  8:24   ` [PATCH 02/22] dt-bindings: media: qcom,sm8550-iris: " Vikash Garodia
2026-08-07  8:40     ` sashiko-bot
2026-08-07  9:01     ` Dmitry Baryshkov
2026-08-07  8:24   ` [PATCH 03/22] dt-bindings: media: qcom,sc7180-venus: " Vikash Garodia
2026-08-07  8:24   ` [PATCH 04/22] arm64: dts: qcom: hamoa: Reserve low IOVA range for Iris Vikash Garodia
2026-08-07  8:45     ` sashiko-bot
2026-08-07  9:03     ` Dmitry Baryshkov
2026-08-07  9:26       ` Vikash Garodia
2026-08-07 10:00         ` Dmitry Baryshkov
2026-08-07 10:22           ` Vikash Garodia
2026-08-07 13:18             ` Bryan O'Donoghue
2026-08-08 15:48               ` Vikash Garodia
2026-08-10 12:10                 ` Dmitry Baryshkov
2026-08-10 16:57                   ` Vikash Garodia
2026-08-11  0:17                     ` Dmitry Baryshkov
2026-08-07 16:24       ` Rob Herring
2026-08-08  4:37         ` Vishnu Reddy
2026-08-08  9:55           ` Bryan O'Donoghue
2026-08-10 13:47             ` Rob Herring
2026-08-07  8:24   ` [PATCH 05/22] arm64: dts: qcom: lemans: " Vikash Garodia
2026-08-07  8:44     ` sashiko-bot
2026-08-07  8:24   ` [PATCH 06/22] arm64: dts: qcom: monaco: " Vikash Garodia
2026-08-07  8:47     ` sashiko-bot
2026-08-07  8:24   ` [PATCH 07/22] arm64: dts: qcom: sc8280xp: " Vikash Garodia
2026-08-07  8:44     ` sashiko-bot
2026-08-07  8:24   ` [PATCH 08/22] arm64: dts: qcom: sm8350: " Vikash Garodia
2026-08-07  8:50     ` sashiko-bot
2026-08-07  8:24   ` [PATCH 09/22] arm64: dts: qcom: sm8550: " Vikash Garodia
2026-08-07  8:46     ` sashiko-bot
2026-08-07  8:24   ` [PATCH 10/22] arm64: dts: qcom: sm8650: " Vikash Garodia
2026-08-07  8:42     ` sashiko-bot
2026-08-07  8:24   ` [PATCH 11/22] arm64: dts: qcom: sm8750: " Vikash Garodia
2026-08-07  8:54     ` sashiko-bot
2026-08-07  8:24   ` [PATCH 12/22] arm64: dts: qcom: agatti: Reserve low IOVA range for Venus Vikash Garodia
2026-08-07  8:57     ` sashiko-bot
2026-08-07  8:24   ` [PATCH 13/22] arm64: dts: qcom: kodiak: " Vikash Garodia
2026-08-07  8:54     ` sashiko-bot
2026-08-07  8:24   ` [PATCH 14/22] arm64: dts: qcom: msm8916: " Vikash Garodia
2026-08-07  8:58     ` sashiko-bot
2026-08-07  8:24   ` [PATCH 15/22] arm64: dts: qcom: msm8996: " Vikash Garodia
2026-08-07  8:25   ` [PATCH 16/22] arm64: dts: qcom: msm8998: " Vikash Garodia
2026-08-07  8:25   ` [PATCH 17/22] arm64: dts: qcom: sc7180: " Vikash Garodia
2026-08-07  8:59     ` sashiko-bot
2026-08-07  8:25   ` [PATCH 18/22] arm64: dts: qcom: sdm630: " Vikash Garodia
2026-08-07  9:00     ` sashiko-bot
2026-08-07  8:25   ` [PATCH 19/22] arm64: dts: qcom: sdm845: " Vikash Garodia
2026-08-07  8:25   ` [PATCH 20/22] arm64: dts: qcom: sm6115: " Vikash Garodia
2026-08-07  9:05     ` sashiko-bot
2026-08-07  8:25   ` [PATCH 21/22] arm64: dts: qcom: sm8250: " Vikash Garodia
2026-08-07  8:25   ` [PATCH 22/22] arm64: dts: qcom: talos: " Vikash Garodia
2026-08-07  9:08     ` sashiko-bot [this message]
2026-08-07  8:51   ` [PATCH 00/22] media: iris: Restrict lower IOVA range for Venus and Iris VPUs Bryan O'Donoghue
2026-08-07  8:59   ` Dmitry Baryshkov
2026-08-07  9:05     ` Vikash Garodia
2026-08-07 10:01       ` Dmitry Baryshkov

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=20260807090809.0ED401F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vikash.garodia@oss.qualcomm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.