]> Git Repo - linux.git/commitdiff
arm64: tls: Fix context-switching of tpidrro_el0 when kpti is enabled
authorWill Deacon <[email protected]>
Thu, 14 Nov 2024 09:53:32 +0000 (09:53 +0000)
committerCatalin Marinas <[email protected]>
Thu, 14 Nov 2024 12:04:13 +0000 (12:04 +0000)
Commit 18011eac28c7 ("arm64: tls: Avoid unconditional zeroing of
tpidrro_el0 for native tasks") tried to optimise the context switching
of tpidrro_el0 by eliding the clearing of the register when switching
to a native task with kpti enabled, on the erroneous assumption that
the kpti trampoline entry code would already have taken care of the
write.

Although the kpti trampoline does zero the register on entry from a
native task, the check in tls_thread_switch() is on the *next* task and
so we can end up leaving a stale, non-zero value in the register if the
previous task was 32-bit.

Drop the broken optimisation and zero tpidrro_el0 unconditionally when
switching to a native 64-bit task.

Cc: Mark Rutland <[email protected]>
Cc: [email protected]
Fixes: 18011eac28c7 ("arm64: tls: Avoid unconditional zeroing of tpidrro_el0 for native tasks")
Signed-off-by: Will Deacon <[email protected]>
Acked-by: Mark Rutland <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Catalin Marinas <[email protected]>
arch/arm64/kernel/process.c

index 0540653fbf382bf8a0984a7e9f97cafbedc3251b..3d78798c4a0a7e9e99747ff91c8c3275d7af690e 100644 (file)
@@ -439,7 +439,7 @@ static void tls_thread_switch(struct task_struct *next)
 
        if (is_compat_thread(task_thread_info(next)))
                write_sysreg(next->thread.uw.tp_value, tpidrro_el0);
-       else if (!arm64_kernel_unmapped_at_el0())
+       else
                write_sysreg(0, tpidrro_el0);
 
        write_sysreg(*task_user_tls(next), tpidr_el0);
This page took 0.059839 seconds and 4 git commands to generate.