diff options
author | Simon Guo <wei.guo.simon@gmail.com> | 2018-05-23 03:01:56 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@ozlabs.org> | 2018-05-31 20:29:47 -0400 |
commit | de7ad932190c6af17bc9075ddd40a084990c5eb3 (patch) | |
tree | 0d3e6bec72dfb8d0db81413ff6a05eb5fc6765fc | |
parent | 36383a0862b68fc14b63dd6c93c64f1f82b6e8a9 (diff) |
KVM: PPC: Book3S PR: Add new kvmppc_copyto/from_vcpu_tm APIs
This patch adds 2 new APIs: kvmppc_copyto_vcpu_tm() and
kvmppc_copyfrom_vcpu_tm(). These 2 APIs will be used to copy from/to TM
data between VCPU_TM/VCPU area.
PR KVM will use these APIs for treclaim. or trechkpt. emulation.
Signed-off-by: Simon Guo <wei.guo.simon@gmail.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
-rw-r--r-- | arch/powerpc/kvm/book3s_emulate.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c index 2eb457bc7b6e..f81a921e0865 100644 --- a/arch/powerpc/kvm/book3s_emulate.c +++ b/arch/powerpc/kvm/book3s_emulate.c | |||
@@ -87,6 +87,47 @@ static bool spr_allowed(struct kvm_vcpu *vcpu, enum priv_level level) | |||
87 | return true; | 87 | return true; |
88 | } | 88 | } |
89 | 89 | ||
90 | #ifdef CONFIG_PPC_TRANSACTIONAL_MEM | ||
91 | static inline void kvmppc_copyto_vcpu_tm(struct kvm_vcpu *vcpu) | ||
92 | { | ||
93 | memcpy(&vcpu->arch.gpr_tm[0], &vcpu->arch.regs.gpr[0], | ||
94 | sizeof(vcpu->arch.gpr_tm)); | ||
95 | memcpy(&vcpu->arch.fp_tm, &vcpu->arch.fp, | ||
96 | sizeof(struct thread_fp_state)); | ||
97 | memcpy(&vcpu->arch.vr_tm, &vcpu->arch.vr, | ||
98 | sizeof(struct thread_vr_state)); | ||
99 | vcpu->arch.ppr_tm = vcpu->arch.ppr; | ||
100 | vcpu->arch.dscr_tm = vcpu->arch.dscr; | ||
101 | vcpu->arch.amr_tm = vcpu->arch.amr; | ||
102 | vcpu->arch.ctr_tm = vcpu->arch.regs.ctr; | ||
103 | vcpu->arch.tar_tm = vcpu->arch.tar; | ||
104 | vcpu->arch.lr_tm = vcpu->arch.regs.link; | ||
105 | vcpu->arch.cr_tm = vcpu->arch.cr; | ||
106 | vcpu->arch.xer_tm = vcpu->arch.regs.xer; | ||
107 | vcpu->arch.vrsave_tm = vcpu->arch.vrsave; | ||
108 | } | ||
109 | |||
110 | static inline void kvmppc_copyfrom_vcpu_tm(struct kvm_vcpu *vcpu) | ||
111 | { | ||
112 | memcpy(&vcpu->arch.regs.gpr[0], &vcpu->arch.gpr_tm[0], | ||
113 | sizeof(vcpu->arch.regs.gpr)); | ||
114 | memcpy(&vcpu->arch.fp, &vcpu->arch.fp_tm, | ||
115 | sizeof(struct thread_fp_state)); | ||
116 | memcpy(&vcpu->arch.vr, &vcpu->arch.vr_tm, | ||
117 | sizeof(struct thread_vr_state)); | ||
118 | vcpu->arch.ppr = vcpu->arch.ppr_tm; | ||
119 | vcpu->arch.dscr = vcpu->arch.dscr_tm; | ||
120 | vcpu->arch.amr = vcpu->arch.amr_tm; | ||
121 | vcpu->arch.regs.ctr = vcpu->arch.ctr_tm; | ||
122 | vcpu->arch.tar = vcpu->arch.tar_tm; | ||
123 | vcpu->arch.regs.link = vcpu->arch.lr_tm; | ||
124 | vcpu->arch.cr = vcpu->arch.cr_tm; | ||
125 | vcpu->arch.regs.xer = vcpu->arch.xer_tm; | ||
126 | vcpu->arch.vrsave = vcpu->arch.vrsave_tm; | ||
127 | } | ||
128 | |||
129 | #endif | ||
130 | |||
90 | int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu, | 131 | int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu, |
91 | unsigned int inst, int *advance) | 132 | unsigned int inst, int *advance) |
92 | { | 133 | { |