]> git.baikalelectronics.ru Git - kernel.git/commitdiff
arm64: ssbs: Fix context-switch when SSBS is present on all CPUs
authorWill Deacon <will@kernel.org>
Thu, 6 Feb 2020 10:42:58 +0000 (10:42 +0000)
committerWill Deacon <will@kernel.org>
Mon, 10 Feb 2020 11:29:02 +0000 (11:29 +0000)
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: <stable@vger.kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Srinivas Ramana <sramana@codeaurora.org>
Fixes: 78535d2a936e ("arm64: Force SSBS on context switch")
Reviewed-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/process.c

index a480b676080842b30c4102d5de50b455dcf5b4e4..00626057a384a5c38330f20d0c5d11148c4f3fd2 100644 (file)
@@ -466,6 +466,13 @@ static void ssbs_thread_switch(struct task_struct *next)
        if (unlikely(next->flags & PF_KTHREAD))
                return;
 
+       /*
+        * If all CPUs implement the SSBS extension, then we just need to
+        * context-switch the PSTATE field.
+        */
+       if (cpu_have_feature(cpu_feature(SSBS)))
+               return;
+
        /* If the mitigation is enabled, then we leave SSBS clear. */
        if ((arm64_get_ssbd_state() == ARM64_SSBD_FORCE_ENABLE) ||
            test_tsk_thread_flag(next, TIF_SSBD))