KVM: PPC: Book3S HV: Tolerate treclaim. in fake-suspend mode changing registers
authorNicholas Piggin <npiggin@gmail.com>
Wed, 8 Sep 2021 10:17:18 +0000 (20:17 +1000)
committerDom Cobley <popcornmix@gmail.com>
Thu, 14 Oct 2021 11:32:56 +0000 (12:32 +0100)
commitab994364df0a01f1fa67f6976508bcef118bdbb1
tree496968668ad11db5b658ffbd6dc58e3ca24d7047
parent2c61bc42441aba9bd749c6f3fe62912bc34d6921
KVM: PPC: Book3S HV: Tolerate treclaim. in fake-suspend mode changing registers

commit 267cdfa21385d78c794768233678756e32b39ead upstream.

POWER9 DD2.2 and 2.3 hardware implements a "fake-suspend" mode where
certain TM instructions executed in HV=0 mode cause softpatch interrupts
so the hypervisor can emulate them and prevent problematic processor
conditions. In this fake-suspend mode, the treclaim. instruction does
not modify registers.

Unfortunately the rfscv instruction executed by the guest do not
generate softpatch interrupts, which can cause the hypervisor to lose
track of the fake-suspend mode, and it can execute this treclaim. while
not in fake-suspend mode. This modifies GPRs and crashes the hypervisor.

It's not trivial to disable scv in the guest with HFSCR now, because
they assume a POWER9 has scv available. So this fix saves and restores
checkpointed registers across the treclaim.

Fixes: 7854f7545bff ("KVM: PPC: Book3S: Rework TM save/restore code and make it C-callable")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210908101718.118522-2-npiggin@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/kvm/book3s_hv_rmhandlers.S