ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack
PATCH 1/1 ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack
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/[email protected]/
---
Please test with the Kconfig patch [9177/1] reverted.
arch/arm/kernel/sleep.S | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/kernel/sleep.S +7 -0
@@ -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}
Signature · 7 lines
2.30.2 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Ard,
Quoted 10 lines · Ard Biesheuvel
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 ifCONFIG_VMAP_STACKis enabled.So let's switch to
swapper_pg_dirright after re-enabling the MMU on such configurations. This avoids a crash on resume observed on various platforms [0].
Quoted 6 lines
[0] https://lore.kernel.org/linux-arm-kernel/[email protected]/
Cc Marek Szyprowski <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc Jon Hunter <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>
Thanks for your patch!
This fixes s2ram on r8a7791/koelsch (dual Cortex-A15) with shmobile_defconfig.
S2ram on sh73a0/kzm9g (dual Cortex-A9) works as before.
Quoted 14 lines
---
Please test with theKconfigpatch [9177/1] reverted.arch/arm/kernel/sleep.S | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm/kernel/sleep.S +0
-0@@ -119,6 +119,13 @@ ENTRY(cpu_resume_mmu) ENDPROC(cpu_resume_mmu) .popsection cpu_resume_after_mmu:
arch/arm/kernel/sleep.S ENTRY(cpu_resume_mmu) · line 131
Quoted 10 lines
arch/arm/kernel/sleep.S +7
-0+#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}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 21 lines · Geert Uytterhoeven
Hi Ard,
Quoted 10 lines · Ard Biesheuvel
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 ifCONFIG_VMAP_STACKis enabled.So let's switch to
swapper_pg_dirright after re-enabling the MMU on such configurations. This avoids a crash on resume observed on various platforms [0].Quoted 6 lines
[0] https://lore.kernel.org/linux-arm-kernel/[email protected]/
Cc Marek Szyprowski <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc Jon Hunter <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>
Quoted 8 lines
Thanks for your patch!
This fixes s2ram on r8a7791/koelsch (dual Cortex-A15) with
shmobile_defconfig.
S2ram on sh73a0/kzm9g (dual Cortex-A9) works as before.Tested-by Geert Uytterhoeven <[email protected]>
Thanks Geert.
Quoted 35 lines
Quoted 14 lines
---
Please test with theKconfigpatch [9177/1] reverted.arch/arm/kernel/sleep.S | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm/kernel/sleep.S +0
-0@@ -119,6 +119,13 @@ ENTRY(cpu_resume_mmu) ENDPROC(cpu_resume_mmu) .popsection cpu_resume_after_mmu:arch/arm/kernel/sleep.S ENTRY(cpu_resume_mmu) · line 131
Quoted 10 lines
arch/arm/kernel/sleep.S +7
-0+#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}Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Ard,
Quoted 10 lines · Ard Biesheuvel
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 ifCONFIG_VMAP_STACKis enabled.So let's switch to
swapper_pg_dirright after re-enabling the MMU on such configurations. This avoids a crash on resume observed on various platforms [0].
Quoted 6 lines
Cc Marek Szyprowski <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc Jon Hunter <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>
This fixes the suspend/resume issue observed on ARM 32bit Exynos based boards. Thanks!
Quoted 14 lines
---
Please test with theKconfigpatch [9177/1] reverted.arch/arm/kernel/sleep.S | 7 +++++++ 1 file changed, 7 insertions(+)arch/arm/kernel/sleep.S +0
-0@@ -119,6 +119,13 @@ ENTRY(cpu_resume_mmu) ENDPROC(cpu_resume_mmu) .popsection cpu_resume_after_mmu:
arch/arm/kernel/sleep.S ENTRY(cpu_resume_mmu) · line 131
Quoted 10 lines
arch/arm/kernel/sleep.S +7
-0+#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}
Best regards
Signature · 8 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 21 lines · Marek Szyprowski
Hi Ard,
Quoted 10 lines · Ard Biesheuvel
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 ifCONFIG_VMAP_STACKis enabled.So let's switch to
swapper_pg_dirright after re-enabling the MMU on such configurations. This avoids a crash on resume observed on various platforms [0].Quoted 6 lines
Cc Marek Szyprowski <[email protected]>Cc Geert Uytterhoeven <[email protected]>Cc Jon Hunter <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>
Quoted 7 lines
This fixes the suspend/resume issue observed on ARM 32bit Exynos based boards. Thanks!
Reported-by Marek Szyprowski <[email protected]>Tested-by Marek Szyprowski <[email protected]>
Thanks Marek.
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel