All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] soc: qcom: mdt_loader: Drop PT_LOAD check on hash segment
@ 2021-08-28  7:02 Shawn Guo
  2021-08-28  9:00 ` Marijn Suijten
  0 siblings, 1 reply; 3+ messages in thread
From: Shawn Guo @ 2021-08-28  7:02 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Marijn Suijten, Siddharth Gupta, linux-arm-msm, linux-kernel, Shawn Guo

PT_LOAD type denotes that the segment should be loaded into the final
firmware memory region.  Hash segment is not one such, because it's only
needed for PAS init and shouldn't be in the final firmware memory region.
That's why mdt_phdr_valid() explicitly reject non PT_LOAD segment and
hash segment.  This actually makes the hash segment type check in
qcom_mdt_read_metadata() unnecessary and redundant.  For a hash segment,
it won't be loaded into firmware memory region anyway, due to the
QCOM_MDT_TYPE_HASH check in mdt_phdr_valid(), even if it has a PT_LOAD
type for some reason (misusing or abusing?).

Some firmware files on Sony phones are such examples, e.g WCNSS firmware
of Sony Xperia M4 Aqua phone.  The type of hash segment is just PT_LOAD.
Drop the unnecessary hash segment type check in qcom_mdt_read_metadata()
to fix firmware loading failure on these phones, while hash segment is
still kept away from the final firmware memory region.

Fixes: 498b98e93900 ("soc: qcom: mdt_loader: Support loading non-split images")
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
Changes for v2:
- Update commit log based on the great disscussion with Marijn and Bjorn.

 drivers/soc/qcom/mdt_loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
index eba7f76f9d61..6034cd8992b0 100644
--- a/drivers/soc/qcom/mdt_loader.c
+++ b/drivers/soc/qcom/mdt_loader.c
@@ -98,7 +98,7 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len)
 	if (ehdr->e_phnum < 2)
 		return ERR_PTR(-EINVAL);
 
-	if (phdrs[0].p_type == PT_LOAD || phdrs[1].p_type == PT_LOAD)
+	if (phdrs[0].p_type == PT_LOAD)
 		return ERR_PTR(-EINVAL);
 
 	if ((phdrs[1].p_flags & QCOM_MDT_TYPE_MASK) != QCOM_MDT_TYPE_HASH)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] soc: qcom: mdt_loader: Drop PT_LOAD check on hash segment
  2021-08-28  7:02 [PATCH v2] soc: qcom: mdt_loader: Drop PT_LOAD check on hash segment Shawn Guo
@ 2021-08-28  9:00 ` Marijn Suijten
  0 siblings, 0 replies; 3+ messages in thread
From: Marijn Suijten @ 2021-08-28  9:00 UTC (permalink / raw)
  To: Shawn Guo, Bjorn Andersson; +Cc: Siddharth Gupta, linux-arm-msm, linux-kernel

Hi Shawn,

On 8/28/21 9:02 AM, Shawn Guo wrote:
> PT_LOAD type denotes that the segment should be loaded into the final
> firmware memory region.  Hash segment is not one such, because it's only
> needed for PAS init and shouldn't be in the final firmware memory region.
> That's why mdt_phdr_valid() explicitly reject non PT_LOAD segment and
> hash segment.  This actually makes the hash segment type check in
> qcom_mdt_read_metadata() unnecessary and redundant.  For a hash segment,
> it won't be loaded into firmware memory region anyway, due to the
> QCOM_MDT_TYPE_HASH check in mdt_phdr_valid(), even if it has a PT_LOAD
> type for some reason (misusing or abusing?).
> 
> Some firmware files on Sony phones are such examples, e.g WCNSS firmware
> of Sony Xperia M4 Aqua phone.  The type of hash segment is just PT_LOAD.
> Drop the unnecessary hash segment type check in qcom_mdt_read_metadata()
> to fix firmware loading failure on these phones, while hash segment is
> still kept away from the final firmware memory region.
> 
> Fixes: 498b98e93900 ("soc: qcom: mdt_loader: Support loading non-split images")
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>


Reviewed-by: Marijn Suijten <marijn.suijten@somainline.org>

Thanks for sitting through that long discussion and coming to the 
conclusion that your patch was correct all along!

> ---
> Changes for v2:
> - Update commit log based on the great disscussion with Marijn and Bjorn.
> 
>   drivers/soc/qcom/mdt_loader.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c
> index eba7f76f9d61..6034cd8992b0 100644
> --- a/drivers/soc/qcom/mdt_loader.c
> +++ b/drivers/soc/qcom/mdt_loader.c
> @@ -98,7 +98,7 @@ void *qcom_mdt_read_metadata(const struct firmware *fw, size_t *data_len)
>   	if (ehdr->e_phnum < 2)
>   		return ERR_PTR(-EINVAL);
>   
> -	if (phdrs[0].p_type == PT_LOAD || phdrs[1].p_type == PT_LOAD)
> +	if (phdrs[0].p_type == PT_LOAD)
>   		return ERR_PTR(-EINVAL);
>   
>   	if ((phdrs[1].p_flags & QCOM_MDT_TYPE_MASK) != QCOM_MDT_TYPE_HASH)
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] soc: qcom: mdt_loader: Drop PT_LOAD check on hash segment
@ 2021-08-29  9:59 David Heidelberg
  0 siblings, 0 replies; 3+ messages in thread
From: David Heidelberg @ 2021-08-29  9:59 UTC (permalink / raw)
  To: Bjorn Andersson, Marijn Suijten, Siddharth Gupta, Shawn Guo
  Cc: linux-arm-msm, linux-kernel

Tested-by: David Heidelberg <david@ixit.cz>

On Nexus 7 2013 this patch fixes WiFi firmware loading regression.

Possible please Cc: <stable@vger.kernel.org> (at least from 5.10, where 
I tested)

Thank you
Best regards
David Heidelberg



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-29 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-28  7:02 [PATCH v2] soc: qcom: mdt_loader: Drop PT_LOAD check on hash segment Shawn Guo
2021-08-28  9:00 ` Marijn Suijten
2021-08-29  9:59 David Heidelberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.