1
0
Fork 0
alistair23-linux/arch/powerpc
Michael Ellerman 79f6bca3bc powerpc/book3s64: Fix link stack flush on context switch
commit 39e72bf96f upstream.

In commit ee13cb249f ("powerpc/64s: Add support for software count
cache flush"), I added support for software to flush the count
cache (indirect branch cache) on context switch if firmware told us
that was the required mitigation for Spectre v2.

As part of that code we also added a software flush of the link
stack (return address stack), which protects against Spectre-RSB
between user processes.

That is all correct for CPUs that activate that mitigation, which is
currently Power9 Nimbus DD2.3.

What I got wrong is that on older CPUs, where firmware has disabled
the count cache, we also need to flush the link stack on context
switch.

To fix it we create a new feature bit which is not set by firmware,
which tells us we need to flush the link stack. We set that when
firmware tells us that either of the existing Spectre v2 mitigations
are enabled.

Then we adjust the patching code so that if we see that feature bit we
enable the link stack flush. If we're also told to flush the count
cache in software then we fall through and do that also.

On the older CPUs we don't need to do do the software count cache
flush, firmware has disabled it, so in that case we patch in an early
return after the link stack flush.

The naming of some of the functions is awkward after this patch,
because they're called "count cache" but they also do link stack. But
we'll fix that up in a later commit to ease backporting.

This is the fix for CVE-2019-18660.

Reported-by: Anthony Steinhauser <asteinhauser@google.com>
Fixes: ee13cb249f ("powerpc/64s: Add support for software count cache flush")
Cc: stable@vger.kernel.org # v4.4+
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-11-29 10:10:31 +01:00
..
boot kbuild: remove ar-option and KBUILD_ARFLAGS 2019-10-01 09:20:33 +09:00
configs powerpc/configs: Enable secure guest support in pseries and ppc64 defconfigs 2019-08-30 09:56:30 +10:00
crypto treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
include powerpc/book3s64: Fix link stack flush on context switch 2019-11-29 10:10:31 +01:00
kernel powerpc/book3s64: Fix link stack flush on context switch 2019-11-29 10:10:31 +01:00
kvm KVM: PPC: Book3S HV: XIVE: Ensure VP isn't already in use 2019-10-15 16:09:11 +11:00
lib powerpc/memcpy: Fix stack corruption for smaller sizes 2019-09-12 09:27:00 +10:00
math-emu treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
mm libnvdimm fixes v5.4-rc1 2019-09-29 10:33:41 -07:00
net powerpc/bpf: Fix tail call implementation 2019-11-02 00:32:26 +01:00
oprofile treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
perf powerpc/perf: fix imc allocation failure handling 2019-08-20 21:22:20 +10:00
platforms powerpc/powernv: Fix CPU idle to be called with IRQs disabled 2019-10-29 21:47:01 +11:00
purgatory treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
sysdev KVM: PPC: Book3S HV: use smp_mb() when setting/clearing host_ipi flag 2019-09-24 12:46:26 +10:00
tools treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
xmon powerpc/xmon: Improve output of XIVE interrupts 2019-09-14 00:58:47 +10:00
Kbuild treewide: Add SPDX license identifier - Kbuild 2019-05-30 11:32:33 -07:00
Kconfig powerpc updates for 5.4 2019-09-20 11:48:06 -07:00
Kconfig.debug powerpc/xmon: add read-only mode 2019-05-03 02:54:57 +10:00
Makefile powerpc updates for 5.4 2019-09-20 11:48:06 -07:00
Makefile.postlink kbuild: add $(BASH) to run scripts with bash-extension 2019-09-04 22:54:13 +09:00