[RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack

Ard Biesheuvel ardb at kernel.org
Thu Jan 6 11:26:45 PST 2022


The resume from suspend code switches to the ID map so it can enable the
MMU. On !LPAE configurations, the ID map carries its own copy of the
kernel VA range, but this is not kept in sync with swapper_pg_dir, and
so it may lack the mapping of the kernel mode stack if CONFIG_VMAP_STACK
is enabled.

So let's switch to swapper_pg_dir right after re-enabling the MMU on
such configurations. This avoids a crash on resume observed on various
platforms [0].

[0] https://lore.kernel.org/linux-arm-kernel/20211122092816.2865873-8-ardb@kernel.org/

Cc: Marek Szyprowski <m.szyprowski at samsung.com>
Cc: Geert Uytterhoeven <geert at linux-m68k.org>
Cc: Jon Hunter <jonathanh at nvidia.com>
Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
---
Please test with the Kconfig patch [9177/1] reverted.

 arch/arm/kernel/sleep.S | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/kernel/sleep.S b/arch/arm/kernel/sleep.S
index b062b3738bc6..6217ef90feb0 100644
--- a/arch/arm/kernel/sleep.S
+++ b/arch/arm/kernel/sleep.S
@@ -119,6 +119,13 @@ ENTRY(cpu_resume_mmu)
 ENDPROC(cpu_resume_mmu)
 	.popsection
 cpu_resume_after_mmu:
+#if defined(CONFIG_VMAP_STACK) && !defined(CONFIG_ARM_LPAE)
+	@ Before using the vmap'ed stack, we have to switch to swapper_pg_dir
+	@ as the ID map does not cover the vmalloc region.
+	mrc	p15, 0, ip, c2, c0, 1	@ read TTBR1
+	mcr	p15, 0, ip, c2, c0, 0	@ set TTBR0
+	isb
+#endif
 	bl	cpu_init		@ restore the und/abt/irq banked regs
 	mov	r0, #0			@ return zero on success
 	ldmfd	sp!, {r4 - r11, pc}
-- 
2.30.2




More information about the linux-arm-kernel mailing list