OSDN Git Service

KVM: PPC: Book3S PR: Always fail transactions in guest privileged state
authorSimon Guo <wei.guo.simon@gmail.com>
Wed, 23 May 2018 07:02:01 +0000 (15:02 +0800)
committerPaul Mackerras <paulus@ozlabs.org>
Fri, 1 Jun 2018 00:30:10 +0000 (10:30 +1000)
commit5706340a339283fe60d55ddc72ee7728a571a834
tree2f5c12185399ad0671cdb3baa0ca4360712aa0ab
parent533082ae86e2f1ff6cb9eca7a25202a81fc0567e
KVM: PPC: Book3S PR: Always fail transactions in guest privileged state

Currently the kernel doesn't use transaction memory.
And there is an issue for privileged state in the guest that:
tbegin/tsuspend/tresume/tabort TM instructions can impact MSR TM bits
without trapping into the PR host. So following code will lead to a
false mfmsr result:
tbegin <- MSR bits update to Transaction active.
beq  <- failover handler branch
mfmsr <- still read MSR bits from magic page with
transaction inactive.

It is not an issue for non-privileged guest state since its mfmsr is
not patched with magic page and will always trap into the PR host.

This patch will always fail tbegin attempt for privileged state in the
guest, so that the above issue is prevented. It is benign since
currently (guest) kernel doesn't initiate a transaction.

Test case:
https://github.com/justdoitqd/publicFiles/blob/master/test_tbegin_pr.c

Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/include/asm/kvm_book3s.h
arch/powerpc/kvm/book3s_emulate.c
arch/powerpc/kvm/book3s_pr.c