* [PATCH] soc: qcom: mdt_loader: Support firmware without hash segment
@ 2019-12-13 5:15 Bjorn Andersson
0 siblings, 0 replies; only message in thread
From: Bjorn Andersson @ 2019-12-13 5:15 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Luca Weiss; +Cc: linux-arm-msm, linux-kernel
At least some of the firmware found on 8974 does not follow the typical
scheme of having a non-loadable hash segment directly following the ELF
header, in the modem mdt.
Rather than failing the read of metadata, fall back to passing back a
copy of the full first firmware file and let the metadata validator do
its job.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
drivers/soc/qcom/mdt_loader.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
index 24cd193dec55..dd8a27f866db 100644
--- a/drivers/soc/qcom/mdt_loader.c
+++ b/drivers/soc/qcom/mdt_loader.c
@@ -99,7 +99,7 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len)
return ERR_PTR(-EINVAL);
if (phdrs[0].p_type == PT_LOAD || phdrs[1].p_type == PT_LOAD)
- return ERR_PTR(-EINVAL);
+ goto return_fw_copy;
if ((phdrs[1].p_flags & QCOM_MDT_TYPE_MASK) != QCOM_MDT_TYPE_HASH)
return ERR_PTR(-EINVAL);
@@ -123,6 +123,18 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len)
*data_len = ehdr_size + hash_size;
return data;
+
+return_fw_copy:
+ /*
+ * Some older firmware (e.g. on 8974) doesn't have a hash segment
+ * following the ELF header, just return a verbatim copy of the
+ * fw->data and let the metadata authenticator consume what it needs.
+ */
+ data = kmemdup(fw->data, fw->size, GFP_KERNEL);
+ if (!data)
+ return ERR_PTR(-ENOMEM);
+ *data_len = fw->size;
+ return data;
}
EXPORT_SYMBOL_GPL(qcom_mdt_read_metadata);
--
2.23.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-13 5:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-13 5:15 [PATCH] soc: qcom: mdt_loader: Support firmware without hash segment Bjorn Andersson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).