Commit Message

From: Simon Guo <wei.guo.simon@gmail.com>
Currently guest kernel doesn't handle TAR fac unavailable and it always
runs with TAR bit on. PR KVM will lazily enable TAR. TAR is not a
frequent-use reg and it is not included in SVCPU struct.
To make it work for transaction memory at PR KVM:
1). Flush/giveup TAR at kvmppc_save_tm_pr().
2) If we are receiving a TAR fac unavail exception inside a transaction,
the checkpointed TAR might be a TAR value from another process. So we need
treclaim the transaction, then load the desired TAR value into reg, and
perform trecheckpoint.
3) Load TAR facility at kvmppc_restore_tm_pr() when TM active.
The reason we always loads TAR when restoring TM is that:
If we don't do this way, when there is a TAR fac unavailable exception
during TM active:
case 1: it is the 1st TAR fac unavail exception after tbegin.
vcpu->arch.tar should be reloaded as checkpoint tar val.
case 2: it is the 2nd or later TAR fac unavail exception after tbegin.
vcpu->arch.tar_tm should be reloaded as checkpoint tar val.
There will be unnecessary difficulty to handle the above 2 cases.
at the end of emulating treclaim., the correct TAR val need to be loaded
into reg if FSCR_TAR bit is on.
at the beginning of emulating trechkpt., TAR needs to be flushed so that
the right tar val can be copy into tar_tm.
Tested with:
tools/testing/selftests/powerpc/tm/tm-tar
tools/testing/selftests/powerpc/ptrace/ptrace-tm-tar (remove DSCR/PPR
related testing).
Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
---
arch/powerpc/include/asm/kvm_book3s.h | 1 +
arch/powerpc/kvm/book3s_emulate.c | 4 ++++
arch/powerpc/kvm/book3s_pr.c | 31 +++++++++++++++++++++++++++++--
arch/powerpc/kvm/tm.S | 16 ++++++++++++++--
4 files changed, 48 insertions(+), 4 deletions(-)

Comments

On Thu, Jan 11, 2018 at 06:11:38PM +0800, wei.guo.simon@gmail.com wrote:
> From: Simon Guo <wei.guo.simon@gmail.com>> > Currently guest kernel doesn't handle TAR fac unavailable and it always> runs with TAR bit on. PR KVM will lazily enable TAR. TAR is not a> frequent-use reg and it is not included in SVCPU struct.> > To make it work for transaction memory at PR KVM:> 1). Flush/giveup TAR at kvmppc_save_tm_pr().> 2) If we are receiving a TAR fac unavail exception inside a transaction,> the checkpointed TAR might be a TAR value from another process. So we need> treclaim the transaction, then load the desired TAR value into reg, and> perform trecheckpoint.> 3) Load TAR facility at kvmppc_restore_tm_pr() when TM active.> The reason we always loads TAR when restoring TM is that:> If we don't do this way, when there is a TAR fac unavailable exception> during TM active:> case 1: it is the 1st TAR fac unavail exception after tbegin.> vcpu->arch.tar should be reloaded as checkpoint tar val.> case 2: it is the 2nd or later TAR fac unavail exception after tbegin.> vcpu->arch.tar_tm should be reloaded as checkpoint tar val.> There will be unnecessary difficulty to handle the above 2 cases.> > at the end of emulating treclaim., the correct TAR val need to be loaded> into reg if FSCR_TAR bit is on.> at the beginning of emulating trechkpt., TAR needs to be flushed so that> the right tar val can be copy into tar_tm.
Would it be simpler always to load up TAR when guest_MSR[TM] is 1?
Paul.
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hi Paul,
On Wed, Jan 24, 2018 at 03:02:58PM +1100, Paul Mackerras wrote:
> On Thu, Jan 11, 2018 at 06:11:38PM +0800, wei.guo.simon@gmail.com wrote:> > From: Simon Guo <wei.guo.simon@gmail.com>> > > > Currently guest kernel doesn't handle TAR fac unavailable and it always> > runs with TAR bit on. PR KVM will lazily enable TAR. TAR is not a> > frequent-use reg and it is not included in SVCPU struct.> > > > To make it work for transaction memory at PR KVM:> > 1). Flush/giveup TAR at kvmppc_save_tm_pr().> > 2) If we are receiving a TAR fac unavail exception inside a transaction,> > the checkpointed TAR might be a TAR value from another process. So we need> > treclaim the transaction, then load the desired TAR value into reg, and> > perform trecheckpoint.> > 3) Load TAR facility at kvmppc_restore_tm_pr() when TM active.> > The reason we always loads TAR when restoring TM is that:> > If we don't do this way, when there is a TAR fac unavailable exception> > during TM active:> > case 1: it is the 1st TAR fac unavail exception after tbegin.> > vcpu->arch.tar should be reloaded as checkpoint tar val.> > case 2: it is the 2nd or later TAR fac unavail exception after tbegin.> > vcpu->arch.tar_tm should be reloaded as checkpoint tar val.> > There will be unnecessary difficulty to handle the above 2 cases.> > > > at the end of emulating treclaim., the correct TAR val need to be loaded> > into reg if FSCR_TAR bit is on.> > at the beginning of emulating trechkpt., TAR needs to be flushed so that> > the right tar val can be copy into tar_tm.> > Would it be simpler always to load up TAR when guest_MSR[TM] is 1?> > Paul.
Sure. it will have a similar solution with math regs.
Thanks for the suggestion,
BR
- Simon
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html