1
0
Fork 0
alistair23-linux/arch/powerpc
Michael Ellerman aa8a5e0062 powerpc/64s: Add support for RFI flush of L1-D cache
On some CPUs we can prevent the Meltdown vulnerability by flushing the
L1-D cache on exit from kernel to user mode, and from hypervisor to
guest.

This is known to be the case on at least Power7, Power8 and Power9. At
this time we do not know the status of the vulnerability on other CPUs
such as the 970 (Apple G5), pasemi CPUs (AmigaOne X1000) or Freescale
CPUs. As more information comes to light we can enable this, or other
mechanisms on those CPUs.

The vulnerability occurs when the load of an architecturally
inaccessible memory region (eg. userspace load of kernel memory) is
speculatively executed to the point where its result can influence the
address of a subsequent speculatively executed load.

In order for that to happen, the first load must hit in the L1,
because before the load is sent to the L2 the permission check is
performed. Therefore if no kernel addresses hit in the L1 the
vulnerability can not occur. We can ensure that is the case by
flushing the L1 whenever we return to userspace. Similarly for
hypervisor vs guest.

In order to flush the L1-D cache on exit, we add a section of nops at
each (h)rfi location that returns to a lower privileged context, and
patch that with some sequence. Newer firmwares are able to advertise
to us that there is a special nop instruction that flushes the L1-D.
If we do not see that advertised, we fall back to doing a displacement
flush in software.

For guest kernels we support migration between some CPU versions, and
different CPUs may use different flush instructions. So that we are
prepared to migrate to a machine with a different flush instruction
activated, we may have to patch more than one flush instruction at
boot if the hypervisor tells us to.

In the end this patch is mostly the work of Nicholas Piggin and
Michael Ellerman. However a cast of thousands contributed to analysis
of the issue, earlier versions of the patch, back ports testing etc.
Many thanks to all of them.

Tested-by: Jon Masters <jcm@redhat.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-01-10 21:27:06 +11:00
..
boot powerpc updates for 4.15 2017-11-16 12:47:46 -08:00
configs powerpc/configs: Enable I2C_CHARDEV for pseries and powernv 2017-10-22 12:08:31 +02:00
crypto License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
include powerpc/64s: Add support for RFI flush of L1-D cache 2018-01-10 21:27:06 +11:00
kernel powerpc/64s: Add support for RFI flush of L1-D cache 2018-01-10 21:27:06 +11:00
kvm powerpc/64s: Simple RFI macro conversions 2018-01-10 03:07:30 +11:00
lib powerpc/64s: Add support for RFI flush of L1-D cache 2018-01-10 21:27:06 +11:00
math-emu License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mm powerpc/mm: Fix SEGV on mapped region to return SEGV_ACCERR 2018-01-02 21:12:33 +11:00
net powerpc updates for 4.15 2017-11-16 12:47:46 -08:00
oprofile treewide: setup_timer() -> timer_setup() 2017-11-21 15:57:07 -08:00
perf powerpc/perf: Fix kfree memory allocated for nest pmus 2017-12-13 20:51:22 +11:00
platforms powerpc/pseries: Make RAS IRQ explicitly dependent on DLPAR WQ 2018-01-08 14:54:32 +11:00
purgatory License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sysdev powerpc updates for 4.15 2017-11-16 12:47:46 -08:00
tools License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xmon powerpc/xmon: Don't print hashed pointers in xmon 2017-12-07 00:27:01 +11:00
Kconfig powerpc updates for 4.15 2017-11-16 12:47:46 -08:00
Kconfig.debug powerpc updates for 4.15 2017-11-16 12:47:46 -08:00
Makefile Merge branch 'fixes' into next 2017-08-23 22:20:10 +10:00
Makefile.postlink License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00