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)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 13 Sep 2021 12:34:12 +0000 (22:34 +1000)
commit267cdfa21385d78c794768233678756e32b39ead
tree69f3ccc214148e167cc070a8b60bf9f984ae1a2e
parentae7aaecc3f2f78b76ab3a8d6178610f55aadfa56
KVM: PPC: Book3S HV: Tolerate treclaim. in fake-suspend mode changing registers

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
arch/powerpc/kvm/book3s_hv_rmhandlers.S