]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: PPC: Book3S HV: Preserve userspace HTM state properly
authorPaul Mackerras <paulus@ozlabs.org>
Thu, 15 Jun 2017 06:10:27 +0000 (16:10 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Jun 2017 11:02:47 +0000 (13:02 +0200)
commit4d9c6828d004dec97fe7b757e13d309e6d566a90
tree2cbaafd7bdfaf135c6b3e75d06e10a235054e34f
parent1e0d799688df53ceaecb1f09716466d0368b4a2a
KVM: PPC: Book3S HV: Preserve userspace HTM state properly

commit 46a704f8409f79fd66567ad3f8a7304830a84293 upstream.

If userspace attempts to call the KVM_RUN ioctl when it has hardware
transactional memory (HTM) enabled, the values that it has put in the
HTM-related SPRs TFHAR, TFIAR and TEXASR will get overwritten by
guest values.  To fix this, we detect this condition and save those
SPR values in the thread struct, and disable HTM for the task.  If
userspace goes to access those SPRs or the HTM facility in future,
a TM-unavailable interrupt will occur and the handler will reload
those SPRs and re-enable HTM.

If userspace has started a transaction and suspended it, we would
currently lose the transactional state in the guest entry path and
would almost certainly get a "TM Bad Thing" interrupt, which would
cause the host to crash.  To avoid this, we detect this case and
return from the KVM_RUN ioctl with an EINVAL error, with the KVM
exit reason set to KVM_EXIT_FAIL_ENTRY.

Fixes: b005255e12a3 ("KVM: PPC: Book3S HV: Context-switch new POWER8 SPRs", 2014-01-08)
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/kvm/book3s_hv.c