Skip to content

Commit fca3d33

Browse files
committed
arm64: ssbs: Fix context-switch when SSBS is present on all CPUs
When all CPUs in the system implement the SSBS extension, the SSBS field in PSTATE is the definitive indication of the mitigation state. Further, when the CPUs implement the SSBS manipulation instructions (advertised to userspace via an HWCAP), EL0 can toggle the SSBS field directly and so we cannot rely on any shadow state such as TIF_SSBD at all. Avoid forcing the SSBS field in context-switch on such a system, and simply rely on the PSTATE register instead. Cc: <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Srinivas Ramana <[email protected]> Fixes: cbdf8a1 ("arm64: Force SSBS on context switch") Reviewed-by: Marc Zyngier <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 2c614c1 commit fca3d33

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/arm64/kernel/process.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,13 @@ static void ssbs_thread_switch(struct task_struct *next)
466466
if (unlikely(next->flags & PF_KTHREAD))
467467
return;
468468

469+
/*
470+
* If all CPUs implement the SSBS extension, then we just need to
471+
* context-switch the PSTATE field.
472+
*/
473+
if (cpu_have_feature(cpu_feature(SSBS)))
474+
return;
475+
469476
/* If the mitigation is enabled, then we leave SSBS clear. */
470477
if ((arm64_get_ssbd_state() == ARM64_SSBD_FORCE_ENABLE) ||
471478
test_tsk_thread_flag(next, TIF_SSBD))

0 commit comments

Comments
 (0)