* [PATCH v2] ARM: entry: expand comment in __switch_to
@ 2025-12-16 14:27 Linus Walleij
2025-12-16 15:21 ` Mark Rutland
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2025-12-16 14:27 UTC (permalink / raw)
To: Russell King, Ard Biesheuvel
Cc: linux-arm-kernel, Linus Walleij, Mark Rutland
From: Linus Walleij <linus.walleij@linaro.org>
As per discussion between the developers in the mail thread
linked, expand the comment in __switch_to so that readers
of the code understand what is going on.
Link: https://lore.kernel.org/linux-arm-kernel/ZxDh9biUbf9W8gNN@J2N7QTR9R3/
Suggested-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Changes in v2:
- Rebased on v6.19-rc1
- Link to v1: https://lore.kernel.org/r/20241028-comments-in-switch-to-v1-0-7280d09671a8@linaro.org
---
| 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
--git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index ef6a657c8d13..5c016c68b5a3 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -557,9 +557,16 @@ ENTRY(__switch_to)
ldmia r4, {r4 - sl, fp, ip, lr} @ Load all regs saved previously
#ifdef CONFIG_VMAP_STACK
@
- @ Do a dummy read from the new stack while running from the old one so
- @ that we can rely on do_translation_fault() to fix up any stale PMD
- @ entries covering the vmalloc region.
+ @ For a non-lazy mm switch, check_vmalloc_seq() has ensured that
+ @ that the active mm's page tables have mappings for the prev
+ @ task's stack and the next task's stack.
+ @
+ @ For a lazy mm switch the active mm's page tables have mappings
+ @ for the prev task's stack but might not have mappings for the
+ @ new taks stack. Do a dummy read from the new stack while
+ @ running from the old stack so that we can rely on
+ @ do_translation_fault() to fix up any stale PMD entries
+ @ covering the vmalloc region.
@
ldr r2, [ip]
#ifdef CONFIG_KASAN_VMALLOC
---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20241028-comments-in-switch-to-0e24480e8495
Best regards,
--
Linus Walleij <linusw@kernel.org>
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] ARM: entry: expand comment in __switch_to
2025-12-16 14:27 [PATCH v2] ARM: entry: expand comment in __switch_to Linus Walleij
@ 2025-12-16 15:21 ` Mark Rutland
0 siblings, 0 replies; 2+ messages in thread
From: Mark Rutland @ 2025-12-16 15:21 UTC (permalink / raw)
To: Linus Walleij
Cc: Russell King, Ard Biesheuvel, linux-arm-kernel, Linus Walleij
Hi Linus,
On Tue, Dec 16, 2025 at 03:27:37PM +0100, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
>
> As per discussion between the developers in the mail thread
> linked, expand the comment in __switch_to so that readers
> of the code understand what is going on.
>
> Link: https://lore.kernel.org/linux-arm-kernel/ZxDh9biUbf9W8gNN@J2N7QTR9R3/
> Suggested-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This looks fine to me, with two minor nits noted below. With those
fixed, feel free to add:
Acked-by: Mark Rutland <mark.rutland@arm.com>
... and I'd recommend dropping this into the patch system.
> ---
> Changes in v2:
> - Rebased on v6.19-rc1
> - Link to v1: https://lore.kernel.org/r/20241028-comments-in-switch-to-v1-0-7280d09671a8@linaro.org
> ---
> arch/arm/kernel/entry-armv.S | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
> index ef6a657c8d13..5c016c68b5a3 100644
> --- a/arch/arm/kernel/entry-armv.S
> +++ b/arch/arm/kernel/entry-armv.S
> @@ -557,9 +557,16 @@ ENTRY(__switch_to)
> ldmia r4, {r4 - sl, fp, ip, lr} @ Load all regs saved previously
> #ifdef CONFIG_VMAP_STACK
> @
> - @ Do a dummy read from the new stack while running from the old one so
> - @ that we can rely on do_translation_fault() to fix up any stale PMD
> - @ entries covering the vmalloc region.
> + @ For a non-lazy mm switch, check_vmalloc_seq() has ensured that
> + @ that the active mm's page tables have mappings for the prev
> + @ task's stack and the next task's stack.
> + @
> + @ For a lazy mm switch the active mm's page tables have mappings
> + @ for the prev task's stack but might not have mappings for the
> + @ new taks stack. Do a dummy read from the new stack while
Typo: s/task/task's/
> + @ running from the old stack so that we can rely on
> + @ do_translation_fault() to fix up any stale PMD entries
> + @ covering the vmalloc region.
Ard requested in:
https://lore.kernel.org/linux-arm-kernel/CAMj1kXFn=pfJqTrMrnqT+OLi3UqAq0PieROQhbC2M3B2uAzyEQ@mail.gmail.com/
That we change this last part from:
to fix up any stale PMD entries covering the vmalloc region.
... to:
to populate missing PMD entries covering the new task's stack in the
old task's page tables.
... and I think that'd be worthwhile.
Mark.
> @
> ldr r2, [ip]
> #ifdef CONFIG_KASAN_VMALLOC
>
> ---
> base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
> change-id: 20241028-comments-in-switch-to-0e24480e8495
>
> Best regards,
> --
> Linus Walleij <linusw@kernel.org>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-16 15:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-16 14:27 [PATCH v2] ARM: entry: expand comment in __switch_to Linus Walleij
2025-12-16 15:21 ` Mark Rutland
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox