Skip to contentSkip to conversation

remoteproc: pru: Fix firmware loading crashes on K3 SoCs

PATCH Applied Suman Anna 3 participants 7 messages Mar 15, 2021 – Mar 25, 2021 Remote processor (remoteproc)

lore
Share & tools
lore

Suman Anna

author
#0 lore raw

PATCH 1/1 remoteproc: pru: Fix firmware loading crashes on K3 SoCs

The K3 PRUs are 32-bit processors and in general have some limitations in using the standard ARMv8 memcpy function for loading firmware segments, so the driver already uses a custom memcpy implementation. This added logic however is limited to only IRAMs at the moment, but the loading into Data RAMs is not completely ok either and does generate a kernel crash for unaligned accesses.

Fix these crashes by removing the existing IRAM logic limitation and extending the custom memcpy usage to Data RAMs as well for all K3 SoCs.

Fixes 1d39f4d19921 ("remoteproc: pru: Add support for various PRU cores on K3 AM65x SoCs")
---
 drivers/remoteproc/pru_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/pru_rproc.c +1 -1
index 2667919d76b3..16979c1cd2f4 100644
@@ -585,7 +585,7 @@ pru_rproc_load_elf_segments(struct rproc *rproc, const struct firmware *fw)
 			break;
 		}
 
-		if (pru->data->is_k3 && is_iram) {
+		if (pru->data->is_k3) {
 			ret = pru_rproc_memcpy(ptr, elf_data + phdr->p_offset,
 					       filesz);
 			if (ret) {
Signature · 1 line
2.30.1
#1 lore raw
This patch was applied to andersson/remoteproc.git (refs/heads/for-next):

Hello:

This patch was applied to andersson/remoteproc.git (refs/heads/for-next):

Quoted 8 lines · On Mon, 15 Mar 2021 15:58:59 -0500 you wrote:

The K3 PRUs are 32-bit processors and in general have some limitations in using the standard ARMv8 memcpy function for loading firmware segments, so the driver already uses a custom memcpy implementation. This added logic however is limited to only IRAMs at the moment, but the loading into Data RAMs is not completely ok either and does generate a kernel crash for unaligned accesses.

[...]

Here is the summary with links:
- remoteproc: pru: Fix firmware loading crashes on K3 SoCs
https://git.kernel.org/andersson/remoteproc/c/9afeefcf06fc

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Suman Anna
Quoted 7 lines · Suman Anna

The K3 PRUs are 32-bit processors and in general have some limitations in using the standard ARMv8 memcpy function for loading firmware segments, so the driver already uses a custom memcpy implementation. This added logic however is limited to only IRAMs at the moment, but the loading into Data RAMs is not completely ok either and does generate a kernel crash for unaligned accesses.

Quoted 5 lines

Fix these crashes by removing the existing IRAM logic limitation and extending the custom memcpy usage to Data RAMs as well for all K3 SoCs.

Fixes 1d39f4d19921 ("remoteproc: pru: Add support for various PRU cores on K3 AM65x SoCs")

Probably a good idea to CC stable as well...

Quoted 20 lines
---
 drivers/remoteproc/pru_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/pru_rproc.c +1 -1
index 2667919d76b3..16979c1cd2f4 100644
@@ -585,7 +585,7 @@ pru_rproc_load_elf_segments(struct rproc *rproc, const struct firmware *fw)
 			break;
 		}
 
-		if (pru->data->is_k3 && is_iram) {
+		if (pru->data->is_k3) {
 			ret = pru_rproc_memcpy(ptr, elf_data + phdr->p_offset,
 					       filesz);
 			if (ret) {
Signature · 1 line
2.30.1
author
#3 lore raw
Quoted 11 lines · Mathieu Poirier
Quoted 10 lines · Suman Anna

The K3 PRUs are 32-bit processors and in general have some limitations in using the standard ARMv8 memcpy function for loading firmware segments, so the driver already uses a custom memcpy implementation. This added logic however is limited to only IRAMs at the moment, but the loading into Data RAMs is not completely ok either and does generate a kernel crash for unaligned accesses.

Fix these crashes by removing the existing IRAM logic limitation and extending the custom memcpy usage to Data RAMs as well for all K3 SoCs.

Quoted 6 lines
Quoted 2 lines
Fixes 1d39f4d19921 ("remoteproc: pru: Add support for various PRU cores on K3 AM65x SoCs")

Probably a good idea to CC stable as well...

Thanks Mathieu. This patch is already staged on Bjorn's rproc-fixes branch though and part of linux-next since next-20210319. I have posted an additional 3-patch series for some more PRU fixes. Do you want me to post a v2 for those with stable Cc'd?

regards
Suman

Quoted 13 lines
Quoted 13 lines
---
 drivers/remoteproc/pru_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/pru_rproc.c +0 -0
index 2667919d76b3..16979c1cd2f4 100644
@@ -585,7 +585,7 @@ pru_rproc_load_elf_segments(struct rproc *rproc, const struct firmware *fw)
 			break;
 		}
 
Quoted 8 lines
Quoted 8 lines
drivers/remoteproc/pru_rproc.c +1 -1
-		if (pru->data->is_k3 && is_iram) {
+		if (pru->data->is_k3) {
 			ret = pru_rproc_memcpy(ptr, elf_data + phdr->p_offset,
 					       filesz);
 			if (ret) {
Signature · 1 line
2.30.1

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

maintainer
#4 lore raw
Quoted 16 lines · Suman Anna
Quoted 14 lines · Mathieu Poirier
Quoted 12 lines · Suman Anna

The K3 PRUs are 32-bit processors and in general have some limitations in using the standard ARMv8 memcpy function for loading firmware segments, so the driver already uses a custom memcpy implementation. This added logic however is limited to only IRAMs at the moment, but the loading into Data RAMs is not completely ok either and does generate a kernel crash for unaligned accesses.

Fix these crashes by removing the existing IRAM logic limitation and extending the custom memcpy usage to Data RAMs as well for all K3 SoCs.

Fixes 1d39f4d19921 ("remoteproc: pru: Add support for various PRU cores on K3 AM65x SoCs")
Quoted 8 lines
Quoted 3 lines

Probably a good idea to CC stable as well...

Thanks Mathieu. This patch is already staged on Bjorn's rproc-fixes branch though and part of linux-next since next-20210319. I have posted an additional 3-patch series for some more PRU fixes. Do you want me to post a v2 for those with stable Cc'd?

I didn't notice Bjorn had already picked it up. Since the object is now public there is no need to send a V2 for this one. I haven't looked at your other 3-patch series but if you think it is stable material then yes, please send a new revision that CC stable.

Mathieu

Quoted 26 lines

regards
Suman

Quoted 21 lines
Quoted 21 lines
---
 drivers/remoteproc/pru_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/pru_rproc.c +1 -2
index 2667919d76b3..16979c1cd2f4 100644
@@ -585,7 +585,7 @@ pru_rproc_load_elf_segments(struct rproc *rproc, const struct firmware *fw)
                     break;
             }
 
-            if (pru->data->is_k3 && is_iram) {
+            if (pru->data->is_k3) {
                     ret = pru_rproc_memcpy(ptr, elf_data + phdr->p_offset,
                                            filesz);
                     if (ret) {
--

2.30.1

author
#5 lore raw
Quoted 26 lines · Mathieu Poirier
Quoted 16 lines · Suman Anna
Quoted 14 lines · Mathieu Poirier
Quoted 12 lines · Suman Anna

The K3 PRUs are 32-bit processors and in general have some limitations in using the standard ARMv8 memcpy function for loading firmware segments, so the driver already uses a custom memcpy implementation. This added logic however is limited to only IRAMs at the moment, but the loading into Data RAMs is not completely ok either and does generate a kernel crash for unaligned accesses.

Fix these crashes by removing the existing IRAM logic limitation and extending the custom memcpy usage to Data RAMs as well for all K3 SoCs.

Fixes 1d39f4d19921 ("remoteproc: pru: Add support for various PRU cores on K3 AM65x SoCs")
Quoted 8 lines
Quoted 3 lines

Probably a good idea to CC stable as well...

Thanks Mathieu. This patch is already staged on Bjorn's rproc-fixes branch though and part of linux-next since next-20210319. I have posted an additional 3-patch series for some more PRU fixes. Do you want me to post a v2 for those with stable Cc'd?

Quoted 4 lines

I didn't notice Bjorn had already picked it up. Since the object is now public there is no need to send a V2 for this one. I haven't looked at your other 3-patch series but if you think it is stable material then yes, please send a new revision that CC stable.

Alright, will do.

regards
Suman

Quoted 29 lines

Mathieu

Quoted 26 lines

regards
Suman

Quoted 21 lines
Quoted 21 lines
---
 drivers/remoteproc/pru_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/pru_rproc.c +1 -2
index 2667919d76b3..16979c1cd2f4 100644
@@ -585,7 +585,7 @@ pru_rproc_load_elf_segments(struct rproc *rproc, const struct firmware *fw)
                     break;
             }
 
-            if (pru->data->is_k3 && is_iram) {
+            if (pru->data->is_k3) {
                     ret = pru_rproc_memcpy(ptr, elf_data + phdr->p_offset,
                                            filesz);
                     if (ret) {
--

2.30.1

author
#6 lore raw
Quoted 27 lines · Suman Anna
Quoted 26 lines · Mathieu Poirier
Quoted 24 lines · Suman Anna
Quoted 11 lines · Mathieu Poirier
Quoted 10 lines · Suman Anna

The K3 PRUs are 32-bit processors and in general have some limitations in using the standard ARMv8 memcpy function for loading firmware segments, so the driver already uses a custom memcpy implementation. This added logic however is limited to only IRAMs at the moment, but the loading into Data RAMs is not completely ok either and does generate a kernel crash for unaligned accesses.

Fix these crashes by removing the existing IRAM logic limitation and extending the custom memcpy usage to Data RAMs as well for all K3 SoCs.

Quoted 6 lines
Quoted 2 lines
Fixes 1d39f4d19921 ("remoteproc: pru: Add support for various PRU cores on K3 AM65x SoCs")

Probably a good idea to CC stable as well...

Thanks Mathieu. This patch is already staged on Bjorn's rproc-fixes branch though and part of linux-next since next-20210319. I have posted an additional 3-patch series for some more PRU fixes. Do you want me to post a v2 for those with stable Cc'd?

Quoted 6 lines
Quoted 4 lines

I didn't notice Bjorn had already picked it up. Since the object is now public there is no need to send a V2 for this one. I haven't looked at your other 3-patch series but if you think it is stable material then yes, please send a new revision that CC stable.

Alright, will do.

On a second thought, we don't have any dts nodes in-kernel yet (5.13-rc1 would be the first kernel with PRU nodes), so those are not critical for v5.11 kernel. As long as they get fixed in either the current v5.12-rc's or by v5.13-rc1, we will be fine.

regards
Suman

Quoted 34 lines

regards
Suman

Quoted 29 lines

Mathieu

Quoted 26 lines

regards
Suman

Quoted 21 lines
Quoted 21 lines
---
 drivers/remoteproc/pru_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/pru_rproc.c +1 -2
index 2667919d76b3..16979c1cd2f4 100644
@@ -585,7 +585,7 @@ pru_rproc_load_elf_segments(struct rproc *rproc, const struct firmware *fw)
                     break;
             }
 
-            if (pru->data->is_k3 && is_iram) {
+            if (pru->data->is_k3) {
                     ret = pru_rproc_memcpy(ptr, elf_data + phdr->p_offset,
                                            filesz);
                     if (ret) {
--

2.30.1