public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Mathieu Poirier <mathieu.poirier@linaro.org>
Subject: [PATCH 6.9 17/25] remoteproc: mediatek: Make sure IPI buffer fits in L2TCM
Date: Thu, 23 May 2024 15:13:02 +0200	[thread overview]
Message-ID: <20240523130331.035116956@linuxfoundation.org> (raw)
In-Reply-To: <20240523130330.386580714@linuxfoundation.org>

6.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

commit 331f91d86f71d0bb89a44217cc0b2a22810bbd42 upstream.

The IPI buffer location is read from the firmware that we load to the
System Companion Processor, and it's not granted that both the SRAM
(L2TCM) size that is defined in the devicetree node is large enough
for that, and while this is especially true for multi-core SCP, it's
still useful to check on single-core variants as well.

Failing to perform this check may make this driver perform R/W
operations out of the L2TCM boundary, resulting (at best) in a
kernel panic.

To fix that, check that the IPI buffer fits, otherwise return a
failure and refuse to boot the relevant SCP core (or the SCP at
all, if this is single core).

Fixes: 3efa0ea743b7 ("remoteproc/mediatek: read IPI buffer offset from FW")
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240321084614.45253-2-angelogioacchino.delregno@collabora.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/remoteproc/mtk_scp.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -132,7 +132,7 @@ static int scp_elf_read_ipi_buf_addr(str
 static int scp_ipi_init(struct mtk_scp *scp, const struct firmware *fw)
 {
 	int ret;
-	size_t offset;
+	size_t buf_sz, offset;
 
 	/* read the ipi buf addr from FW itself first */
 	ret = scp_elf_read_ipi_buf_addr(scp, fw, &offset);
@@ -144,6 +144,14 @@ static int scp_ipi_init(struct mtk_scp *
 	}
 	dev_info(scp->dev, "IPI buf addr %#010zx\n", offset);
 
+	/* Make sure IPI buffer fits in the L2TCM range assigned to this core */
+	buf_sz = sizeof(*scp->recv_buf) + sizeof(*scp->send_buf);
+
+	if (scp->sram_size < buf_sz + offset) {
+		dev_err(scp->dev, "IPI buffer does not fit in SRAM.\n");
+		return -EOVERFLOW;
+	}
+
 	scp->recv_buf = (struct mtk_share_obj __iomem *)
 			(scp->sram_base + offset);
 	scp->send_buf = (struct mtk_share_obj __iomem *)



  parent reply	other threads:[~2024-05-23 13:17 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-23 13:12 [PATCH 6.9 00/25] 6.9.2-rc1 review Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 01/25] Bluetooth: btusb: Fix the patch for MT7920 the affected to MT7921 Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 02/25] wifi: iwlwifi: Use request_module_nowait Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 03/25] cpufreq: amd-pstate: fix the highest frequency issue which limits performance Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 04/25] drm/amd/display: Fix division by zero in setup_dsc_config Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 05/25] net: ks8851: Fix another TX stall caused by wrong ISR flag handling Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 06/25] x86/percpu: Use __force to cast from __percpu address space Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 07/25] Bluetooth: L2CAP: Fix div-by-zero in l2cap_le_flowctl_init() Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 08/25] KEYS: trusted: Fix memory leak in tpm2_key_encode() Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 09/25] ASoC: Intel: sof_sdw: use generic rtd_init function for Realtek SDW DMICs Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 10/25] binder: fix max_thread type inconsistency Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 11/25] usb: dwc3: Wait unconditionally after issuing EndXfer command Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 12/25] net: usb: ax88179_178a: fix link status when link is set to down/up Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 13/25] usb: typec: ucsi: displayport: Fix potential deadlock Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 14/25] usb: typec: tipd: fix event checking for tps25750 Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 15/25] usb: typec: tipd: fix event checking for tps6598x Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 16/25] serial: kgdboc: Fix NMI-safety problems from keyboard reset code Greg Kroah-Hartman
2024-05-23 13:13 ` Greg Kroah-Hartman [this message]
2024-05-23 13:13 ` [PATCH 6.9 18/25] Revert "media: v4l2-ctrls: show all owned controls in log_status" Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 19/25] KEYS: trusted: Do not use WARN when encode fails Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 20/25] admin-guide/hw-vuln/core-scheduling: fix return type of PR_SCHED_CORE_GET Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 21/25] docs: kernel_include.py: Cope with docutils 0.21 Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 22/25] Docs/admin-guide/mm/damon/usage: fix wrong example of DAMOS filter matching sysfs file Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 23/25] Docs/admin-guide/mm/damon/usage: fix wrong schemes effective quota update command Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 24/25] block: add a disk_has_partscan helper Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 25/25] block: add a partscan sysfs attribute for disks Greg Kroah-Hartman
2024-05-23 16:22 ` [PATCH 6.9 00/25] 6.9.2-rc1 review Mark Brown
2024-05-23 17:05 ` SeongJae Park
2024-05-23 21:06 ` Florian Fainelli
2024-05-23 21:18 ` Florian Fainelli
2024-05-24  4:47 ` Bagas Sanjaya
2024-05-24  8:52 ` Ron Economos
2024-05-24  9:32 ` Anders Roxell
2024-05-24 14:34 ` Shuah Khan
2024-05-24 15:20 ` Jon Hunter
2024-05-24 18:47 ` Pavel Machek
2024-05-25  9:35 ` Pascal Ernster
2024-05-25  9:35 ` Pascal Ernster
2024-05-25  9:37 ` Pascal Ernster
2024-05-25 16:26 ` Allen

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=20240523130331.035116956@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.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