Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Anvesh Jain P" <anvesh.p@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v4 2/4] remoteproc: qcom: pas: Support secondary images
Date: Thu, 26 Nov 2026 07:29:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-234956@kernel.org> (raw)
In-Reply-To: <20261126-oob-support-glymur-v4-2-ad4ec5dd4b0a@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] remoteproc: qcom: pas: masked secondary shutdown errors in
  qcom_pas_stop()
- [Medium] remoteproc: qcom: pas: firmware leak on boot failure after
  qcom_pas_load()
--

commit dc23d946a37b9cfe0d13e4638daa0d99a7b84a72
Author: Anvesh Jain P <anvesh.p@oss.qualcomm.com>

remoteproc: qcom: pas: Support secondary images

This commit adds PAS remoteproc support for loading, authenticating,
mapping, shutting down, and releasing a secondary image and its DTB
alongside the primary image.

> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> index e7dfad27e5263..1e51371e445f3 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c

[ ... ]

> @@ -252,6 +288,10 @@ static int qcom_pas_unprepare(struct rproc *rproc)
>  	qcom_pas_metadata_release(pas->pas_ctx);
>  	if (pas->dtb_pas_id)
>  		qcom_pas_metadata_release(pas->dtb_pas_ctx);
> +	if (pas->secondary_pas_id)
> +		qcom_pas_metadata_release(pas->secondary_pas_ctx);
> +	if (pas->secondary_dtb_pas_id)
> +		qcom_pas_metadata_release(pas->secondary_dtb_pas_ctx);
>  
>  	return 0;
>  }
> @@ -269,19 +309,29 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw)
>  	if (pas->lite_dtb_pas_id)
>  		qcom_pas_shutdown(pas->lite_dtb_pas_id);
>  
> -	if (pas->dtb_pas_id) {
> -		ret = request_firmware(&pas->dtb_firmware, pas->dtb_firmware_name, pas->dev);
> +	if (pas->secondary_dtb_pas_id) {
> +		ret = request_firmware(&pas->secondary_dtb_firmware,
> +				       pas->secondary_dtb_firmware_name, pas->dev);
> +		if (ret) {
> +			qcom_pas_release_firmware(pas);
> +			return ret;
> +		}
> +	}
> +
> +	if (pas->secondary_pas_id) {
> +		ret = request_firmware(&pas->secondary_firmware,
> +				       pas->secondary_firmware_name, pas->dev);
>  		if (ret) {
> -			dev_err(pas->dev, "request_firmware failed for %s: %d\n",
> -				pas->dtb_firmware_name, ret);
> +			qcom_pas_release_firmware(pas);
>  			return ret;
>  		}
> +	}
>  
> -		ret = qcom_mdt_pas_load(pas->dtb_pas_ctx, pas->dtb_firmware,
> -					pas->dtb_firmware_name, &pas->dtb_mem_reloc);
> +	if (pas->dtb_pas_id) {
> +		ret = request_firmware(&pas->dtb_firmware, pas->dtb_firmware_name,
> +				       pas->dev);
>  		if (ret) {
> -			qcom_pas_metadata_release(pas->dtb_pas_ctx);
> -			release_firmware(pas->dtb_firmware);
> +			qcom_pas_release_firmware(pas);
>  			return ret;
>  		}
>  	}

[Severity: Medium]
Does this leak pas->secondary_dtb_firmware, pas->secondary_firmware, and
pas->dtb_firmware if boot fails after qcom_pas_load() succeeds?

qcom_pas_release_firmware() is only called in qcom_pas_start() on success
or under the disable_irqs error label.  If rproc_prepare_subdevices()
fails in rproc_start() before qcom_pas_start() is called, or if
qcom_q6v5_prepare() fails at the top of qcom_pas_start() and returns
early, qcom_pas_release_firmware() is skipped and qcom_pas_unprepare()
does not release the firmware or clear pas->firmware.  A later boot or
recovery attempt then overwrites the pointers in qcom_pas_load().

[ ... ]

> @@ -440,9 +557,30 @@ static int qcom_pas_stop(struct rproc *rproc)
>  	if (ret == -ETIMEDOUT)
>  		dev_err(pas->dev, "timed out on wait\n");
>  
> +	if (pas->secondary_pas_id) {
> +		ret = qcom_pas_shutdown(pas->secondary_pas_id);
> +		if (ret && pas->decrypt_shutdown)
> +			ret = qcom_pas_shutdown_poll_decrypt(pas->secondary_pas_id);
> +		if (ret)
> +			dev_err(pas->dev, "failed to shutdown secondary: %d\n", ret);
> +
> +		qcom_pas_unmap_carveout(rproc, pas->secondary_mem_phys,
> +					pas->secondary_mem_size);
> +	}
> +
> +	if (pas->secondary_dtb_pas_id) {
> +		ret = qcom_pas_shutdown(pas->secondary_dtb_pas_id);
> +		if (ret)
> +			dev_err(pas->dev,
> +				"failed to shutdown secondary dtb: %d\n", ret);
> +
> +		qcom_pas_unmap_carveout(rproc, pas->secondary_dtb_mem_phys,
> +					pas->secondary_dtb_mem_size);
> +	}
> +
>  	ret = qcom_pas_shutdown(pas->pas_id);
>  	if (ret && pas->decrypt_shutdown)
> -		ret = qcom_pas_shutdown_poll_decrypt(pas);
> +		ret = qcom_pas_shutdown_poll_decrypt(pas->pas_id);
>  
>  	if (ret)
>  		dev_err(pas->dev, "failed to shutdown: %d\n", ret);

[Severity: Medium]
Does overwriting ret with qcom_pas_shutdown(pas->pas_id) mask shutdown
failures for pas->secondary_pas_id and pas->secondary_dtb_pas_id?

If secondary shutdown fails while primary shutdown succeeds,
qcom_pas_stop() returns 0 to rproc_stop() instead of preserving the error
the way the pas->dtb_pas_id block below does with dtb_ret, allowing crash
recovery or shutdown to proceed while the secondary PAS carveout remains
locked by TrustZone.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-oob-support-glymur-v4-0-ad4ec5dd4b0a@oss.qualcomm.com?part=2

  reply	other threads:[~2026-11-26  7:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  7:13 [PATCH v4 0/4] Add Glymur OOBMSS support Anvesh Jain P
2026-11-26  7:13 ` [PATCH v4 1/4] dt-bindings: remoteproc: qcom: Add Glymur OOBMSS PAS Anvesh Jain P
2026-11-26  7:20   ` sashiko-bot
2026-11-26  7:13 ` [PATCH v4 2/4] remoteproc: qcom: pas: Support secondary images Anvesh Jain P
2026-11-26  7:29   ` sashiko-bot [this message]
2026-11-26  7:13 ` [PATCH v4 3/4] remoteproc: qcom: pas: Add coredump support for secondary processors Anvesh Jain P
2026-11-26  7:37   ` sashiko-bot
2026-11-26  7:13 ` [PATCH v4 4/4] remoteproc: qcom: pas: Add Glymur OOBMSS PAS parameters Anvesh Jain P
2026-11-26  7:28   ` sashiko-bot

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-234956@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=anvesh.p@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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