]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
KVM: PPC: Book3S HV: Prevent POWER7/8 TLB flush flushing SLB
authorNicholas Piggin <npiggin@gmail.com>
Fri, 19 Nov 2021 03:16:27 +0000 (13:16 +1000)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:48:58 +0000 (09:48 +0100)
commitd0ec99b08d6d648aca531e5f6f4f7fcaa2ae149e
tree7846261c70ac5fb284a425e091ae70cbb067d0cf
parent44fa75e98742be61459d70a1ec1f616a7a4c9b5d
KVM: PPC: Book3S HV: Prevent POWER7/8 TLB flush flushing SLB

BugLink: https://bugs.launchpad.net/bugs/1953370
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
48e7b7695745 ("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: 500871125920 ("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>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
arch/powerpc/kvm/book3s_hv_builtin.c