]> git.baikalelectronics.ru Git - kernel.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)
committerPaul Mackerras <paulus@ozlabs.org>
Thu, 15 Jun 2017 06:18:17 +0000 (16:18 +1000)
commit8feb0164c03675cfa6f52b7bd0135d170c7e87e3
tree0d7f8f7e605bd085148176980e9b22ae9698433e
parente32f1459c8a2031fd15d92407a031e80a9f6882d
KVM: PPC: Book3S HV: Preserve userspace HTM state properly

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: b92cb2bde0df ("KVM: PPC: Book3S HV: Context-switch new POWER8 SPRs", 2014-01-08)
Cc: stable@vger.kernel.org # v3.14+
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/kvm/book3s_hv.c