mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
To: Bjorn Andersson <quic_bjorande@quicinc.com>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Melody Olvera <quic_molvera@quicinc.com>,
	Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] soc: qcom: mdt_loader: Fix split image detection
Date: Tue, 13 Jun 2023 15:57:22 +0300	[thread overview]
Message-ID: <a838693e-e441-2ea2-937a-5cad9a5cd512@linaro.org> (raw)
In-Reply-To: <20230612215804.1883458-1-quic_bjorande@quicinc.com>

On 13/06/2023 00:58, Bjorn Andersson wrote:
> 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: 210d12c8197a ("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

W/o this patch loading mbn files is broken.

> ---
>   drivers/soc/qcom/mdt_loader.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
> index 9418993a3a92..6f177e46fa0f 100644
> --- a/drivers/soc/qcom/mdt_loader.c
> +++ b/drivers/soc/qcom/mdt_loader.c
> @@ -275,6 +275,14 @@ static bool qcom_mdt_bins_are_split(const struct firmware *fw, const char *fw_na
>   	phdrs = (struct elf32_phdr *)(ehdr + 1);
>   
>   	for (i = 0; i < ehdr->e_phnum; i++) {
> +		/*
> +		 * The size of the MDT file is not padded to include any
> +		 * zero-sized segments at the end. Ignore these, as they should
> +		 * not affect the decision about image being split or not.
> +		 */
> +		if (!phdrs[i].p_filesz)
> +			continue;
> +
>   		seg_start = phdrs[i].p_offset;
>   		seg_end = phdrs[i].p_offset + phdrs[i].p_filesz;
>   		if (seg_start > fw->size || seg_end > fw->size)

-- 
With best wishes
Dmitry


  reply	other threads:[~2023-06-13 12:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 21:58 Bjorn Andersson
2023-06-13 12:57 ` Dmitry Baryshkov [this message]
2023-06-13 22:30 ` Bjorn Andersson

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=a838693e-e441-2ea2-937a-5cad9a5cd512@linaro.org \
    --to=dmitry.baryshkov@linaro.org \
    --cc=andersson@kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_bjorande@quicinc.com \
    --cc=quic_gokukris@quicinc.com \
    --cc=quic_molvera@quicinc.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®