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

Marek Szyprowski m.szyprowski at samsung.com
Mon Jan 10 01:36:13 PST 2022


Hi Ard,

On 06.01.2022 20:26, Ard Biesheuvel wrote:
> 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://protect2.fireeye.com/v1/url?k=efa2c314-b039fa16-efa3485b-0cc47a31381a-5dcf992b5d854429&q=1&e=1dac5900-a7aa-40ed-a2f0-9af17ae05bfe&u=https%3A%2F%2Flore.kernel.org%2Flinux-arm-kernel%2F20211122092816.2865873-8-ardb%40kernel.org%2F
>
> 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>

This fixes the suspend/resume issue observed on ARM 32bit Exynos based 
boards. Thanks!

Reported-by: Marek Szyprowski <m.szyprowski at samsung.com>

Tested-by: Marek Szyprowski <m.szyprowski at samsung.com>

> ---
> 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}

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland




More information about the linux-arm-kernel mailing list