From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org,
shawnguo@kernel.org, s.hauer@pengutronix.de,
shengjiu.wang@nxp.com
Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com,
linux-arm-kernel@lists.infradead.org, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero
Date: Wed, 23 Mar 2022 14:49:43 +0800 [thread overview]
Message-ID: <20220323064944.1351923-2-peng.fan@oss.nxp.com> (raw)
In-Reply-To: <20220323064944.1351923-1-peng.fan@oss.nxp.com>
From: Peng Fan <peng.fan@nxp.com>
Per elf specification,
p_filesz: This member gives the number of bytes in the file image of
the segment; it may be zero.
p_memsz: This member gives the number of bytes in the memory image
of the segment; it may be zero.
There is a case that i.MX DSP firmware has segment with PT_LOAD and
p_memsz/p_filesz set to zero. Such segment needs to be ignored,
otherwize rproc_da_to_va would report error.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/remoteproc/remoteproc_elf_loader.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c
index d635d19a5aa8..cb77f9e4dc70 100644
--- a/drivers/remoteproc/remoteproc_elf_loader.c
+++ b/drivers/remoteproc/remoteproc_elf_loader.c
@@ -181,7 +181,14 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)
bool is_iomem = false;
void *ptr;
- if (type != PT_LOAD)
+ /*
+ * There is a case that with PT_LOAD type, the
+ * filesz = memsz = 0. If memsz = 0, rproc_da_to_va
+ * should return NULL ptr, then error is returned.
+ * So this case should be skipped from the loop.
+ * Add !memsz checking here.
+ */
+ if (type != PT_LOAD || !memsz)
continue;
dev_dbg(dev, "phdr: type %d da 0x%llx memsz 0x%llx filesz 0x%llx\n",
--
2.25.1
next prev parent reply other threads:[~2022-03-23 6:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-23 6:49 [PATCH 0/2] remoteproc: elf: ignore PT_LOAD type segment with memsz as 0 Peng Fan (OSS)
2022-03-23 6:49 ` Peng Fan (OSS) [this message]
2022-04-12 17:47 ` [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero Mathieu Poirier
2022-03-23 6:49 ` [PATCH 2/2] remoteproc: imx_dsp_rproc: use common rproc_elf_load_segments Peng Fan (OSS)
2022-04-06 10:05 ` Daniel Baluta
2022-04-06 10:58 ` Peng Fan
2022-04-06 11:25 ` Daniel Baluta
2022-04-07 8:05 ` Daniel Baluta
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=20220323064944.1351923-2-peng.fan@oss.nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=bjorn.andersson@linaro.org \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=peng.fan@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=shengjiu.wang@nxp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®