Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mukesh Ojha" <mukesh.ojha@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v3 04/18] firmware: qcom: scm: Add minidump SRAM support
Date: Fri, 22 May 2026 20:21:45 +0000	[thread overview]
Message-ID: <20260522202145.9AC631F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260522195009.2961022-5-mukesh.ojha@oss.qualcomm.com>

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

Pre-existing issues:
- [High] Missing smp_load_acquire() when reading the global __scm pointer in set_download_mode() risks a race condition and stale reads.
--

commit de197846d8ecb70e3382c65171f1e37949d3d114
Author: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>

firmware: qcom: scm: Add minidump SRAM support

On most Qualcomm SoCs where minidump is supported, a word in always-on
SRAM is shared between the kernel and boot firmware. This commit adds
minidump SRAM support and exposes a minidump_dest module parameter so
the user can select the destination.

> diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
> --- a/drivers/firmware/qcom/qcom_scm.c
> +++ b/drivers/firmware/qcom/qcom_scm.c
[ ... ]
> @@ -568,6 +583,14 @@ static void qcom_scm_set_download_mode(u32 dload_mode)
>  
>  	if (ret)
>  		dev_err(__scm->dev, "failed to set download mode: %d\n", ret);
> +
> +	/*
> +	 * Write the destination into the always-on SRAM so boot firmware
> +	 * can read it before DDR is initialised on the next warm reset.
> +	 * Only written when minidump is active;
> +	 */
> +	if (__scm->minidump_sram && (dload_mode & QCOM_DLOAD_MINIDUMP))
> +		writel_relaxed(minidump_dest, __scm->minidump_sram);
>  }

[Severity: High]
This is a pre-existing issue, but is it safe to read the global __scm
pointer here without using smp_load_acquire()?

The driver publishes the global __scm pointer at the end of qcom_scm_probe()
using smp_store_release(&__scm, scm). Module parameters are exposed via
sysfs before probe completes, allowing userspace to concurrently trigger the
set_download_mode() callback.

This callback reads __scm using a plain, lockless memory access. Without a
matching smp_load_acquire(), the CPU can observe a non-NULL __scm pointer
while still seeing stale or uninitialized values for its members, including
the newly added __scm->minidump_sram.

Could this lead to an unaligned access or page fault if writel_relaxed()
is passed an uninitialized pointer? 

Note that the newly added set_minidump_dest() correctly uses
smp_load_acquire() to prevent this exact issue, but
qcom_scm_set_download_mode() remains unprotected.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260522195009.2961022-1-mukesh.ojha@oss.qualcomm.com?part=4

  reply	other threads:[~2026-05-22 20:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22 19:49 [PATCH v3 00/18] firmware: qcom: scm: Add minidump SRAM destination support Mukesh Ojha
2026-05-22 19:49 ` [PATCH v3 01/18] dt-bindings: firmware: qcom,scm: Add minidump SRAM property Mukesh Ojha
2026-05-22 19:49 ` [PATCH v3 02/18] dt-bindings: sram: qcom,imem: Add minidump-sram pattern property Mukesh Ojha
2026-05-22 19:49 ` [PATCH v3 03/18] firmware: qcom: scm: use dev_err_probe() for dload address failure Mukesh Ojha
2026-05-22 19:49 ` [PATCH v3 04/18] firmware: qcom: scm: Add minidump SRAM support Mukesh Ojha
2026-05-22 20:21   ` sashiko-bot [this message]
2026-05-22 19:49 ` [PATCH v3 05/18] arm64: dts: qcom: kaanapali: Add minidump SRAM config to SCM node Mukesh Ojha
2026-05-22 19:49 ` [PATCH v3 06/18] arm64: dts: qcom: sm8450: " Mukesh Ojha
2026-05-22 19:49 ` [PATCH v3 07/18] arm64: dts: qcom: sa8775p: " Mukesh Ojha
2026-05-22 19:49 ` [PATCH v3 08/18] arm64: dts: qcom: qcs8300: " Mukesh Ojha
2026-05-22 19:50 ` [PATCH v3 09/18] arm64: dts: qcom: qdu1000: " Mukesh Ojha
2026-05-22 19:50 ` [PATCH v3 10/18] arm64: dts: qcom: sm8550: " Mukesh Ojha
2026-05-22 19:50 ` [PATCH v3 11/18] arm64: dts: qcom: sm8650: " Mukesh Ojha
2026-05-22 19:50 ` [PATCH v3 12/18] arm64: dts: qcom: sc7280: " Mukesh Ojha
2026-05-22 19:50 ` [PATCH v3 13/18] arm64: dts: qcom: sm8350: " Mukesh Ojha
2026-05-22 19:50 ` [PATCH v3 14/18] arm64: dts: qcom: sc7180: " Mukesh Ojha
2026-05-22 19:50 ` [PATCH v3 15/18] arm64: dts: qcom: sm6350: " Mukesh Ojha
2026-05-22 19:50 ` [PATCH v3 16/18] arm64: dts: qcom: sm6375: " Mukesh Ojha
2026-05-22 19:50 ` [PATCH v3 17/18] arm64: dts: qcom: qcs615: " Mukesh Ojha
2026-05-22 19:50 ` [PATCH v3 18/18] arm64: dts: qcom: sdm845: " Mukesh Ojha

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=20260522202145.9AC631F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=mukesh.ojha@oss.qualcomm.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