KVM: PPC: Book3S HV P9: Fix guest TM support
authorNicholas Piggin <npiggin@gmail.com>
Mon, 12 Jul 2021 01:36:50 +0000 (11:36 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 15 Jul 2021 11:53:37 +0000 (21:53 +1000)
commite44fbdb68049539de9923ce4bad2d277aef54892
treeb5df1f342f7f20f3be8d893210ec49b6d2401b20
parente73f0f0ee7541171d89f2e2491130c7771ba58d3
KVM: PPC: Book3S HV P9: Fix guest TM support

The conversion to C introduced several bugs in TM handling that can
cause host crashes with TM bad thing interrupts. Mostly just simple
typos or missed logic in the conversion that got through due to my
not testing TM in the guest sufficiently.

- Early TM emulation for the softpatch interrupt should be done if fake
  suspend mode is _not_ active.

- Early TM emulation wants to return immediately to the guest so as to
  not doom transactions unnecessarily.

- And if exiting from the guest, the host MSR should include the TM[S]
  bit if the guest was T/S, before it is treclaimed.

After this fix, all the TM selftests pass when running on a P9 processor
that implements TM with softpatch interrupt.

Fixes: 89d35b2391015 ("KVM: PPC: Book3S HV P9: Implement the rest of the P9 path in C")
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210712013650.376325-1-npiggin@gmail.com
arch/powerpc/kvm/book3s_hv_p9_entry.c