Skip to contentSkip to conversation

powerpc/64: Fix booting large kernels with STRICT_KERNEL_RWX

PATCH Applied Russell Currey 2 participants 2 messages Mar 27, 2019 – Apr 21, 2019 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/64: Fix booting large kernels with STRICT_KERNEL_RWX

With STRICT_KERNEL_RWX enabled anything marked __init is placed at a 16M boundary. This is necessary so that it can be repurposed later with different permissions. However, in kernels with text larger than 16M, this pushes early_setup past 32M, incapable of being reached by the branch instruction.

Fix this by setting the CTR and branching there instead.

Fixes 1e0fc9d1eb2b ("powerpc/Kconfig: Enable STRICT_KERNEL_RWX for some configs")
---
 arch/powerpc/kernel/head_64.S | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kernel/head_64.S +3 -1
index 3fad8d499767..c2b53febadd9 100644
@@ -968,7 +968,9 @@ start_here_multiplatform:
 
 	/* Restore parameters passed from prom_init/kexec */
 	mr	r3,r31
-	bl	early_setup		/* also sets r13 and SPRG_PACA */
+	LOAD_REG_ADDR(r12, early_setup)
+	mtctr	r12
+	bctrl		/* also sets r13 and SPRG_PACA */
 
 	LOAD_REG_ADDR(r3, start_here_common)
 	ld	r4,PACAKMSR(r13)
Signature · 1 line
2.21.0
#1 lore raw
Quoted 10 lines · Russell Currey

With STRICT_KERNEL_RWX enabled anything marked __init is placed at a 16M boundary. This is necessary so that it can be repurposed later with different permissions. However, in kernels with text larger than 16M, this pushes early_setup past 32M, incapable of being reached by the branch instruction.

Fix this by setting the CTR and branching there instead.

Fixes 1e0fc9d1eb2b ("powerpc/Kconfig: Enable STRICT_KERNEL_RWX for some configs")

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/56c46bba9bbfe229b4472a5be313c44c

cheers