linux/arch/powerpc/kvm
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
..
Kconfig
Makefile
book3s.c KVM: Pass MMU notifier range flags to kvm_unmap_hva_range() 2020-08-26 10:41:08 +02:00
book3s.h
book3s_32_mmu.c
book3s_32_mmu_host.c
book3s_32_sr.S
book3s_64_mmu.c
book3s_64_mmu_host.c
book3s_64_mmu_hv.c
book3s_64_mmu_radix.c KVM: PPC: Book3S HV: Close race with page faults around memslot flushes 2020-10-01 13:18:05 +02:00
book3s_64_slb.S
book3s_64_vio.c
book3s_64_vio_hv.c KVM: PPC: Fix clearing never mapped TCEs in realmode 2021-09-22 12:26:25 +02:00
book3s_emulate.c
book3s_exports.c
book3s_hv.c KVM: PPC: Book3S HV Nested: Reflect guest PMU in-use to L0 when guest SPRs are live 2021-09-22 12:26:25 +02:00
book3s_hv_builtin.c KVM: PPC: Book3S HV: Prevent POWER7/8 TLB flush flushing SLB 2021-12-01 09:23:28 +01:00
book3s_hv_hmi.c
book3s_hv_interrupts.S
book3s_hv_nested.c KVM: PPC: Book3S HV Nested: Sanitise H_ENTER_NESTED TM state 2021-07-28 13:30:59 +02:00
book3s_hv_ras.c
book3s_hv_rm_mmu.c KVM: PPC: Book3S HV: Fix TLB management on SMT8 POWER9 and POWER10 processors 2021-07-14 16:53:14 +02:00
book3s_hv_rm_xics.c
book3s_hv_rm_xive.c
book3s_hv_rmhandlers.S KVM: PPC: Book3S HV: Use GLOBAL_TOC for kvmppc_h_set_dabr/xdabr() 2021-11-26 10:47:20 +01:00
book3s_hv_tm.c KVM: PPC: Book3S HV: Treat TM-related invalid form instructions on P9 like the valid ones 2020-10-01 13:17:44 +02:00
book3s_hv_tm_builtin.c KVM: PPC: Book3S HV: Treat TM-related invalid form instructions on P9 like the valid ones 2020-10-01 13:17:44 +02:00
book3s_interrupts.S
book3s_mmu_hpte.c
book3s_paired_singles.c
book3s_pr.c
book3s_pr_papr.c
book3s_rmhandlers.S
book3s_rtas.c KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow 2021-07-28 13:30:59 +02:00
book3s_segment.S
book3s_xics.c
book3s_xics.h
book3s_xive.c
book3s_xive.h
book3s_xive_native.c KVM: PPC: Book3S HV: XIVE: Fix possible oops when accessing ESB page 2020-12-02 08:49:46 +01:00
book3s_xive_template.c
booke.c
booke.h
booke_emulate.c
booke_interrupts.S
bookehv_interrupts.S
e500.c
e500.h
e500_emulate.c
e500_mmu.c
e500_mmu_host.c KVM: Pass MMU notifier range flags to kvm_unmap_hva_range() 2020-08-26 10:41:08 +02:00
e500_mmu_host.h
e500mc.c
emulate.c
emulate_loadstore.c
fpu.S
irq.h
mpic.c
powerpc.c KVM: PPC: Fix kvm_arch_vcpu_ioctl vcpu_load leak 2021-07-28 13:30:56 +02:00
timing.c
timing.h
tm.S
trace.h
trace_book3s.h
trace_booke.h
trace_hv.h
trace_pr.h