Skip to content

Commit 0d25da8

Browse files
quic-bjorandeandersson
authored andcommitted
soc: qcom: mdt_loader: Fix split image detection
The enhanced detection introduced in commit '210d12c8197a ("soc: qcom: mdt_loader: Enhance split binary detection")' requires that all segments lies within the file on disk. But the Qualcomm firmware files consistently has a BSS-like segment at the end, with a p_offset aligned to the next 4k boundary. As the p_size is 0 and there's nothing to load, the image is not padded to cover this (empty) segment. Ignore zero-sized segments when determining if the image is split, to avoid this problem. Fixes: 210d12c ("soc: qcom: mdt_loader: Enhance split binary detection") Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Tested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> # qrb5165-rb5 Signed-off-by: Bjorn Andersson <andersson@kernel.org> Link: https://lore.kernel.org/r/20230612215804.1883458-1-quic_bjorande@quicinc.com
1 parent e81a16e commit 0d25da8

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/soc/qcom/mdt_loader.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,14 @@ static bool qcom_mdt_bins_are_split(const struct firmware *fw, const char *fw_na
275275
phdrs = (struct elf32_phdr *)(ehdr + 1);
276276

277277
for (i = 0; i < ehdr->e_phnum; i++) {
278+
/*
279+
* The size of the MDT file is not padded to include any
280+
* zero-sized segments at the end. Ignore these, as they should
281+
* not affect the decision about image being split or not.
282+
*/
283+
if (!phdrs[i].p_filesz)
284+
continue;
285+
278286
seg_start = phdrs[i].p_offset;
279287
seg_end = phdrs[i].p_offset + phdrs[i].p_filesz;
280288
if (seg_start > fw->size || seg_end > fw->size)

0 commit comments

Comments
 (0)