From: Ard Biesheuvel <ardb@kernel.org>
To: linux@armlinux.org.uk
Cc: linux-arm-kernel@lists.infradead.org, arnd@arndb.de,
linus.walleij@linaro.org, keescook@chromium.org,
Ard Biesheuvel <ardb@kernel.org>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Jon Hunter <jonathanh@nvidia.com>
Subject: [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack
Date: Thu, 6 Jan 2022 20:26:45 +0100 [thread overview]
Message-ID: <20220106192645.3913934-1-ardb@kernel.org> (raw)
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
next reply other threads:[~2022-01-06 19:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20220106192701eucas1p23a3cfa225cef560be6b85a101263d26f@eucas1p2.samsung.com>
2022-01-06 19:26 ` Ard Biesheuvel [this message]
2022-01-07 9:14 ` [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack Geert Uytterhoeven
2022-01-07 10:00 ` Ard Biesheuvel
2022-01-10 9:36 ` Marek Szyprowski
2022-01-10 10:55 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220106192645.3913934-1-ardb@kernel.org \
--to=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=geert@linux-m68k.org \
--cc=jonathanh@nvidia.com \
--cc=keescook@chromium.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=m.szyprowski@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).