linux/arch/powerpc
Nicholas Piggin 5c895828f4 KVM: PPC: Book3S HV: Prevent POWER7/8 TLB flush flushing SLB
commit cf0b0e3712f7af90006f8317ff27278094c2c128 upstream.

The POWER9 ERAT flush instruction is a SLBIA with IH=7, which is a
reserved value on POWER7/8. On POWER8 this invalidates the SLB entries
above index 0, similarly to SLBIA IH=0.

If the SLB entries are invalidated, and then the guest is bypassed, the
host SLB does not get re-loaded, so the bolted entries above 0 will be
lost. This can result in kernel stack access causing a SLB fault.

Kernel stack access causing a SLB fault was responsible for the infamous
mega bug (search "Fix SLB reload bug"). Although since commit
48e7b76957 ("powerpc/64s/hash: Convert SLB miss handlers to C") that
starts using the kernel stack in the SLB miss handler, it might only
result in an infinite loop of SLB faults. In any case it's a bug.

Fix this by only executing the instruction on >= POWER9 where IH=7 is
defined not to invalidate the SLB. POWER7/8 don't require this ERAT
flush.

Fixes: 5008711259 ("KVM: PPC: Book3S HV: Invalidate ERAT when flushing guest TLB entries")
Cc: stable@vger.kernel.org # v5.2+
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20211119031627.577853-1-npiggin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-12-01 09:23:28 +01:00
..
boot powerpc/5200: dts: fix memory node unit name 2021-11-26 10:47:16 +01:00
configs powerpc/config: Renable MTD_PHYSMAP_OF 2021-09-22 12:26:24 +02:00
crypto treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
include powerpc/security: Add a helper to query stf_barrier type 2021-11-17 09:48:49 +01:00
kernel powerpc/security: Add a helper to query stf_barrier type 2021-11-17 09:48:49 +01:00
kvm KVM: PPC: Book3S HV: Prevent POWER7/8 TLB flush flushing SLB 2021-12-01 09:23:28 +01:00
lib powerpc/lib: Add helper to check if offset is within conditional branch range 2021-11-17 09:48:49 +01:00
math-emu treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
mm powerpc/mm: Fix lockup on kernel exec fault 2021-07-19 08:53:14 +02:00
net powerpc/bpf: Emit stf barrier instruction sequences for BPF_NOSPEC 2021-11-17 09:48:49 +01:00
oprofile treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
perf powerpc/perf/hv-gpci: Fix counter value parsing 2021-09-22 12:26:19 +02:00
platforms powerpc/powernv/prd: Unregister OPAL_MSG_PRD2 notifier during module unload 2021-11-17 09:48:50 +01:00
purgatory treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
sysdev powerpc/dcr: Use cmplwi instead of 3-argument cmpli 2021-11-26 10:47:16 +01:00
tools powerpc: Do not consider weak unresolved symbol relocations as bad 2020-02-24 08:37:00 +01:00
xmon powerpc/xmon: Change printk() to pr_cont() 2020-12-30 11:51:39 +01:00
Kbuild treewide: Add SPDX license identifier - Kbuild 2019-05-30 11:32:33 -07:00
Kconfig powerpc: Fix HAVE_HARDLOCKUP_DETECTOR_ARCH build configuration 2021-05-14 09:44:26 +02:00
Kconfig.debug powerpc: iommu: fix build when neither PCI or IBMVIO is set 2021-05-14 09:44:28 +02:00
Makefile powerpc: Drop -me200 addition to build flags 2020-12-16 10:56:55 +01:00
Makefile.postlink powerpc: Do not consider weak unresolved symbol relocations as bad 2020-02-24 08:37:00 +01:00