Skip to contentSkip to conversation

ARM: zynq: smp improvements

PATCH Superseded Luis Araneda 4 participants 12 messages Aug 6, 2019 – Aug 8, 2019

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ARM: zynq: smp improvements

This series adds support for kernel compiled in Thumb mode and fixes a kernel panic on smp bring-up when FORTIFY_SOURCE is enabled.

The series started with the second patch as an RFC, and the first patch were suggested on the review to complement the fix.

The changes were run-tested on a Digilent Zybo Z7 board

Luis Araneda (2):
ARM: zynq: support smp in thumb mode
ARM: zynq: Use memcpy_toio instead of memcpy on smp bring-up

 arch/arm/mach-zynq/headsmp.S | 2 ++
 arch/arm/mach-zynq/platsmp.c | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.22.0
#1 lore raw

PATCH 1/2 ARM: zynq: support smp in thumb mode

Add .arm directive to headsmp.S to ensure that the CPU starts in 32-bit ARM mode and the correct code size is copied on smp bring-up

Additionally, start secondary CPUs on secondary_startup_arm to automatically switch from ARM to thumb on a thumb kernel

---
 arch/arm/mach-zynq/headsmp.S | 2 ++
 arch/arm/mach-zynq/platsmp.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-zynq/headsmp.S +2 -0
index ab85003cf9ad..3449e0d1f990 100644
@@ -7,6 +7,8 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 
+	.arm
+
 ENTRY(zynq_secondary_trampoline)
 ARM_BE8(setend	be)				@ ensure we are in BE8 mode
 	ldr	r0, zynq_secondary_trampoline_jump
arch/arm/mach-zynq/platsmp.c +1 -1
index a7cfe07156f4..38728badabd4 100644
@@ -81,7 +81,7 @@ EXPORT_SYMBOL(zynq_cpun_start);
 
 static int zynq_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
-	return zynq_cpun_start(__pa_symbol(secondary_startup), cpu);
+	return zynq_cpun_start(__pa_symbol(secondary_startup_arm), cpu);
 }
 
 /*
Signature · 1 line
2.22.0
#6 lore raw

PATCH 2/2 ARM: zynq: Use memcpy_toio instead of memcpy on smp bring-up

In reply to Luis Araneda

This fixes a kernel panic (read overflow) on memcpy when FORTIFY_SOURCE is enabled.

The computed size of memcpy args are:
- p_size (dst): 4294967295 = (size_t) -1
- q_size (src): 1
- size (len): 8

Additionally, the memory is marked as __iomem, so one of the memcpy_* functions should be used for read/write

---
 arch/arm/mach-zynq/platsmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-zynq/platsmp.c +1 -1
index 38728badabd4..a10085be9073 100644
@@ -57,7 +57,7 @@ int zynq_cpun_start(u32 address, int cpu)
 			* 0x4: Jump by mov instruction
 			* 0x8: Jumping address
 			*/
-			memcpy((__force void *)zero, &zynq_secondary_trampoline,
+			memcpy_toio(zero, &zynq_secondary_trampoline,
 							trampoline_size);
 			writel(address, zero + trampoline_size);
 
Signature · 1 line
2.22.0
maintainer
#11 lore raw
In reply to Luis Araneda
Quoted 10 lines · Luis Araneda

This series adds support for kernel compiled in Thumb mode and fixes a kernel panic on smp bring-up when FORTIFY_SOURCE is enabled.

The series started with the second patch as an RFC, and the first patch were suggested on the review to complement the fix.

The changes were run-tested on a Digilent Zybo Z7 board

Quoted 11 lines

Luis Araneda (2):
ARM: zynq: support smp in thumb mode
ARM: zynq: Use memcpy_toio instead of memcpy on smp bring-up

 arch/arm/mach-zynq/headsmp.S | 2 ++
 arch/arm/mach-zynq/platsmp.c | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.22.0

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

maintainer
#7 lore raw

Re: [PATCH 2/2] ARM: zynq: Use memcpy_toio instead of memcpy on smp bring-up

In reply to Luis Araneda
Quoted 8 lines · Luis Araneda

This fixes a kernel panic (read overflow) on memcpy when FORTIFY_SOURCE is enabled.

The computed size of memcpy args are:
- p_size (dst): 4294967295 = (size_t) -1
- q_size (src): 1
- size (len): 8

Quoted 7 lines

Additionally, the memory is marked as __iomem, so one of the memcpy_* functions should be used for read/write

---
 arch/arm/mach-zynq/platsmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

maintainer
#2 lore raw

Re: [PATCH 1/2] ARM: zynq: support smp in thumb mode

In reply to Luis Araneda
Quoted 7 lines · Luis Araneda

Add .arm directive to headsmp.S to ensure that the CPU starts in 32-bit ARM mode and the correct code size is copied on smp bring-up

Additionally, start secondary CPUs on secondary_startup_arm to automatically switch from ARM to thumb on a thumb kernel

Quoted 6 lines
---
 arch/arm/mach-zynq/headsmp.S | 2 ++
 arch/arm/mach-zynq/platsmp.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

<formletter>

This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

#3 lore raw

Re: [PATCH 1/2] ARM: zynq: support smp in thumb mode

In reply to Luis Araneda
Quoted 33 lines · Luis Araneda

Add .arm directive to headsmp.S to ensure that the CPU starts in 32-bit ARM mode and the correct code size is copied on smp bring-up

Additionally, start secondary CPUs on secondary_startup_arm to automatically switch from ARM to thumb on a thumb kernel

---
 arch/arm/mach-zynq/headsmp.S | 2 ++
 arch/arm/mach-zynq/platsmp.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-zynq/headsmp.S +2 -0
index ab85003cf9ad..3449e0d1f990 100644
@@ -7,6 +7,8 @@
 #include <linux/init.h>
 #include <asm/assembler.h>
 
+	.arm
+
 ENTRY(zynq_secondary_trampoline)
 ARM_BE8(setend	be)				@ ensure we are in BE8 mode
 	ldr	r0, zynq_secondary_trampoline_jump
arch/arm/mach-zynq/platsmp.c +0 -0
index a7cfe07156f4..38728badabd4 100644

arch/arm/mach-zynq/platsmp.c EXPORT_SYMBOL(zynq_cpun_start); · line 87

Quoted 8 lines
arch/arm/mach-zynq/platsmp.c +1 -1
@@ -81,7 +81,7 @@ EXPORT_SYMBOL(zynq_cpun_start);
 
 static int zynq_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
-	return zynq_cpun_start(__pa_symbol(secondary_startup), cpu);
+	return zynq_cpun_start(__pa_symbol(secondary_startup_arm), cpu);
 }
 
 /*

It is really a question if this should go to stable tree. It is pretty much new feature.
Will be good to also add link to similar patch for example this one 5616f36713ea77f57ae908bf2fef641364403c9f.

M

#8 lore raw

Re: [PATCH 2/2] ARM: zynq: Use memcpy_toio instead of memcpy on smp bring-up

In reply to Luis Araneda
Quoted 21 lines · Luis Araneda

This fixes a kernel panic (read overflow) on memcpy when FORTIFY_SOURCE is enabled.

The computed size of memcpy args are:
- p_size (dst): 4294967295 = (size_t) -1
- q_size (src): 1
- size (len): 8

Additionally, the memory is marked as __iomem, so one of the memcpy_* functions should be used for read/write

---
 arch/arm/mach-zynq/platsmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-zynq/platsmp.c +0 -0
index 38728badabd4..a10085be9073 100644

arch/arm/mach-zynq/platsmp.c int zynq_cpun_start(u32 address, int cpu) · line 63

Quoted 8 lines
arch/arm/mach-zynq/platsmp.c +1 -1
@@ -57,7 +57,7 @@ int zynq_cpun_start(u32 address, int cpu)
 			* 0x4: Jump by mov instruction
 			* 0x8: Jumping address
 			*/
-			memcpy((__force void *)zero, &zynq_secondary_trampoline,
+			memcpy_toio(zero, &zynq_secondary_trampoline,
 							trampoline_size);
 			writel(address, zero + trampoline_size);
 

I would consider this one as stable material. Please also add there link to the patch which this patch fixes.

M

#4 lore raw

Re: [PATCH 1/2] ARM: zynq: support smp in thumb mode

In reply to Michal Simek

Hi,

Quoted 8 lines · Michal Simek
Quoted 6 lines · Luis Araneda

Add .arm directive to headsmp.S to ensure that the CPU starts in 32-bit ARM mode and the correct code size is copied on smp bring-up

Additionally, start secondary CPUs on secondary_startup_arm to automatically switch from ARM to thumb on a thumb kernel

[...]

Quoted 5 lines

It is really a question if this should go to stable tree. It is pretty much new feature.
Will be good to also add link to similar patch for example this one 5616f36713ea77f57ae908bf2fef641364403c9f.

Ok, I'm dropping stable from CC. From the previous comments, I thought that the two patches were part of the same fix, but now I realized this is a feature rather than a fix.

Michal, do you want a new version with the link to the similar patch or would you take it in its current form?

Thanks,
Luis Araneda.

#9 lore raw

Re: [PATCH 2/2] ARM: zynq: Use memcpy_toio instead of memcpy on smp bring-up

In reply to Michal Simek

Hi Michal,

Quoted 13 lines · Michal Simek
Quoted 12 lines · Luis Araneda

This fixes a kernel panic (read overflow) on memcpy when FORTIFY_SOURCE is enabled.

The computed size of memcpy args are:
- p_size (dst): 4294967295 = (size_t) -1
- q_size (src): 1
- size (len): 8

Additionally, the memory is marked as __iomem, so one of the memcpy_* functions should be used for read/write

[...]

Quoted 2 lines

I would consider this one as stable material. Please also add there link to the patch which this patch fixes.

I'm dropping stable CC (for now), as I'm not sure I completely understood the process for inclusion in stable trees.
Do I have to wait for the patch to be on Linus' tree before CCing stable?

As for the link which this patch fixes, you mean aa7eb2bb4e4a22e41bbe4612ff46e5885b13c33e (arm: zynq: Add smp support)? where you added SMP support for zynq.

Thanks,
Luis Araneda.

#5 lore raw

Re: [PATCH 1/2] ARM: zynq: support smp in thumb mode

In reply to Luis Araneda
Quoted 18 lines · Luis Araneda

Hi,

Quoted 8 lines · Michal Simek
Quoted 6 lines · Luis Araneda

Add .arm directive to headsmp.S to ensure that the CPU starts in 32-bit ARM mode and the correct code size is copied on smp bring-up

Additionally, start secondary CPUs on secondary_startup_arm to automatically switch from ARM to thumb on a thumb kernel

[...]

Quoted 5 lines

It is really a question if this should go to stable tree. It is pretty much new feature.
Will be good to also add link to similar patch for example this one 5616f36713ea77f57ae908bf2fef641364403c9f.

Quoted 6 lines

Ok, I'm dropping stable from CC. From the previous comments, I thought that the two patches were part of the same fix, but now I realized this is a feature rather than a fix.

Michal, do you want a new version with the link to the similar patch or would you take it in its current form?

new version please.
M

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
#10 lore raw

Re: [PATCH 2/2] ARM: zynq: Use memcpy_toio instead of memcpy on smp bring-up

In reply to Luis Araneda
Quoted 15 lines · Luis Araneda

Hi Michal,

Quoted 12 lines · Michal Simek
Quoted 11 lines · Luis Araneda

This fixes a kernel panic (read overflow) on memcpy when FORTIFY_SOURCE is enabled.

The computed size of memcpy args are:
- p_size (dst): 4294967295 = (size_t) -1
- q_size (src): 1
- size (len): 8

Additionally, the memory is marked as __iomem, so one of the memcpy_* functions should be used for read/write

Quoted 8 lines
Quoted 1 line
Quoted 1 line

[...]

Quoted 2 lines

I would consider this one as stable material. Please also add there link to the patch which this patch fixes.

I'm dropping stable CC (for now), as I'm not sure I completely understood the process for inclusion in stable trees.
Do I have to wait for the patch to be on Linus' tree before CCing stable?

just put Cc: to commit message and they will pick it up.

Quoted 4 lines

As for the link which this patch fixes, you mean aa7eb2bb4e4a22e41bbe4612ff46e5885b13c33e (arm: zynq: Add smp support)? where you added SMP support for zynq.

yes but make sha1 only 12char long.

M

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs

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