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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ard,

On Thu, Jan 6, 2022 at 8:27 PM Ard Biesheuvel <ardb@xxxxxxxxxx> 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://lore.kernel.org/linux-arm-kernel/20211122092816.2865873-8-ardb@xxxxxxxxxx/
>
> Cc: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> Cc: Jon Hunter <jonathanh@xxxxxxxxxx>
> Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>

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 <geert+renesas@xxxxxxxxx>

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

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux