* [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack
@ 2022-01-06 19:26 ` Ard Biesheuvel
2022-01-07 9:14 ` Geert Uytterhoeven
2022-01-10 9:36 ` Marek Szyprowski
0 siblings, 2 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2022-01-06 19:26 UTC (permalink / raw)
To: linux
Cc: linux-arm-kernel, arnd, linus.walleij, keescook, Ard Biesheuvel,
Marek Szyprowski, Geert Uytterhoeven, Jon Hunter
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@samsung.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Ard Biesheuvel <ardb@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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack
2022-01-06 19:26 ` [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack Ard Biesheuvel
@ 2022-01-07 9:14 ` Geert Uytterhoeven
2022-01-10 9:36 ` Marek Szyprowski
1 sibling, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2022-01-07 9:14 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Russell King, Linux ARM, Arnd Bergmann, Linus Walleij, Kees Cook,
Marek Szyprowski, Jon Hunter, Linux-Renesas
Hi Ard,
On Thu, Jan 6, 2022 at 8:27 PM Ard Biesheuvel <ardb@kernel.org> 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@kernel.org/
>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Jon Hunter <jonathanh@nvidia.com>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
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@glider.be>
> ---
> 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@linux-m68k.org
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack
@ 2022-01-07 9:14 ` Geert Uytterhoeven
0 siblings, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2022-01-07 9:14 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Russell King, Linux ARM, Arnd Bergmann, Linus Walleij, Kees Cook,
Marek Szyprowski, Jon Hunter, Linux-Renesas
Hi Ard,
On Thu, Jan 6, 2022 at 8:27 PM Ard Biesheuvel <ardb@kernel.org> 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@kernel.org/
>
> Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Jon Hunter <jonathanh@nvidia.com>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
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@glider.be>
> ---
> 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@linux-m68k.org
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack
2022-01-07 9:14 ` Geert Uytterhoeven
@ 2022-01-07 10:00 ` Ard Biesheuvel
-1 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2022-01-07 10:00 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Russell King, Linux ARM, Arnd Bergmann, Linus Walleij, Kees Cook,
Marek Szyprowski, Jon Hunter, Linux-Renesas
On Fri, 7 Jan 2022 at 10:15, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Ard,
>
> On Thu, Jan 6, 2022 at 8:27 PM Ard Biesheuvel <ardb@kernel.org> 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@kernel.org/
> >
> > Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> > Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> > Cc: Jon Hunter <jonathanh@nvidia.com>
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>
> 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@glider.be>
>
Thanks Geert.
> > ---
> > 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@linux-m68k.org
>
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack
@ 2022-01-07 10:00 ` Ard Biesheuvel
0 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2022-01-07 10:00 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Russell King, Linux ARM, Arnd Bergmann, Linus Walleij, Kees Cook,
Marek Szyprowski, Jon Hunter, Linux-Renesas
On Fri, 7 Jan 2022 at 10:15, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Ard,
>
> On Thu, Jan 6, 2022 at 8:27 PM Ard Biesheuvel <ardb@kernel.org> 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@kernel.org/
> >
> > Cc: Marek Szyprowski <m.szyprowski@samsung.com>
> > Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> > Cc: Jon Hunter <jonathanh@nvidia.com>
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>
> 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@glider.be>
>
Thanks Geert.
> > ---
> > 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@linux-m68k.org
>
> 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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack
2022-01-06 19:26 ` [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack Ard Biesheuvel
2022-01-07 9:14 ` Geert Uytterhoeven
@ 2022-01-10 9:36 ` Marek Szyprowski
2022-01-10 10:55 ` Ard Biesheuvel
1 sibling, 1 reply; 7+ messages in thread
From: Marek Szyprowski @ 2022-01-10 9:36 UTC (permalink / raw)
To: Ard Biesheuvel, linux
Cc: linux-arm-kernel, arnd, linus.walleij, keescook,
Geert Uytterhoeven, Jon Hunter
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@samsung.com>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Jon Hunter <jonathanh@nvidia.com>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This fixes the suspend/resume issue observed on ARM 32bit Exynos based
boards. Thanks!
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack
2022-01-10 9:36 ` Marek Szyprowski
@ 2022-01-10 10:55 ` Ard Biesheuvel
0 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2022-01-10 10:55 UTC (permalink / raw)
To: Marek Szyprowski
Cc: linux, linux-arm-kernel, arnd, linus.walleij, keescook,
Geert Uytterhoeven, Jon Hunter
On Mon, 10 Jan 2022 at 10:36, Marek Szyprowski <m.szyprowski@samsung.com> wrote:
>
> 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@samsung.com>
> > Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> > Cc: Jon Hunter <jonathanh@nvidia.com>
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>
> This fixes the suspend/resume issue observed on ARM 32bit Exynos based
> boards. Thanks!
>
> Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
>
> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
>
Thanks Marek.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-01-10 10:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20220106192701eucas1p23a3cfa225cef560be6b85a101263d26f@eucas1p2.samsung.com>
2022-01-06 19:26 ` [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack Ard Biesheuvel
2022-01-07 9:14 ` Geert Uytterhoeven
2022-01-07 9:14 ` Geert Uytterhoeven
2022-01-07 10:00 ` Ard Biesheuvel
2022-01-07 10:00 ` Ard Biesheuvel
2022-01-10 9:36 ` Marek Szyprowski
2022-01-10 10:55 ` Ard Biesheuvel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.