Skip to contentSkip to conversation

ARM: zynq: smp improvements

PATCH In review Luis Araneda 2 participants 4 messages Aug 8, 2019 – Aug 14, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 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
---
Changes:
v1 -> v2:
- Reword commit messages to include related commits
- Add Fixes tag to relevant commits
- Add Cc to stable to relevant commits

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 v2 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.
This is related to the fix applied to SoCFPGA by commit 5616f36713ea
("ARM: SoCFPGA: Fix secondary CPU startup in thumb2 kernel")

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

---
Changes:
v1 -> v2:
- Reword commit message to include related commits

---
 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
#2 lore raw

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

In reply to Luis Araneda

This fixes a kernel panic on memcpy when
FORTIFY_SOURCE is enabled.

The initial smp implementation on commit aa7eb2bb4e4a ("arm: zynq: Add smp support")
used memcpy, which worked fine until commit ee333554fed5 ("ARM: 8749/1: Kconfig: Add ARCH_HAS_FORTIFY_SOURCE") enabled overflow checks at runtime, producing a read overflow panic.

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.

Fixes aa7eb2bb4e4a ("arm: zynq: Add smp support")

---
Changes:
v1 -> v2:
- Reword commit message to include related commits
- Add Fixes tag
- Add Cc to stable

---
 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
#3 lore raw
In reply to Luis Araneda
Quoted 17 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
---
Changes:
v1 -> v2:
- Reword commit messages to include related commits
- Add Fixes tag to relevant commits
- Add Cc to stable to relevant commits

Quoted 8 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(-)

Applied both.
M