aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include/asm/kvm_ppc.h
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2010-04-15 18:11:40 -0400
committerAvi Kivity <avi@redhat.com>2010-05-17 05:18:26 -0400
commitc7f38f46f2a98d232147e47284cb4e7363296a3e (patch)
treeba1de6a9d8398d31807756789d015983c4610b21 /arch/powerpc/include/asm/kvm_ppc.h
parent66bb170655799a0149df0844fb8232f27e54323c (diff)
KVM: PPC: Improve indirect svcpu accessors
We already have some inline fuctions we use to access vcpu or svcpu structs, depending on whether we're on booke or book3s. Since we just put a few more registers into the svcpu, we also need to make sure the respective callbacks are available and get used. So this patch moves direct use of the now in the svcpu struct fields to inline function calls. While at it, it also moves the definition of those inline function calls to respective header files for booke and book3s, greatly improving readability. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/include/asm/kvm_ppc.h')
-rw-r--r--arch/powerpc/include/asm/kvm_ppc.h79
1 files changed, 2 insertions, 77 deletions
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index 6a2464e4d6b..edade847b8f 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -30,6 +30,8 @@
30#include <linux/kvm_host.h> 30#include <linux/kvm_host.h>
31#ifdef CONFIG_PPC_BOOK3S 31#ifdef CONFIG_PPC_BOOK3S
32#include <asm/kvm_book3s.h> 32#include <asm/kvm_book3s.h>
33#else
34#include <asm/kvm_booke.h>
33#endif 35#endif
34 36
35enum emulation_result { 37enum emulation_result {
@@ -138,81 +140,4 @@ static inline u32 kvmppc_set_field(u64 inst, int msb, int lsb, int value)
138 return r; 140 return r;
139} 141}
140 142
141#ifdef CONFIG_PPC_BOOK3S
142
143/* We assume we're always acting on the current vcpu */
144
145static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
146{
147 if ( num < 14 ) {
148 get_paca()->shadow_vcpu.gpr[num] = val;
149 to_book3s(vcpu)->shadow_vcpu.gpr[num] = val;
150 } else
151 vcpu->arch.gpr[num] = val;
152}
153
154static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
155{
156 if ( num < 14 )
157 return get_paca()->shadow_vcpu.gpr[num];
158 else
159 return vcpu->arch.gpr[num];
160}
161
162static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
163{
164 get_paca()->shadow_vcpu.cr = val;
165 to_book3s(vcpu)->shadow_vcpu.cr = val;
166}
167
168static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
169{
170 return get_paca()->shadow_vcpu.cr;
171}
172
173static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
174{
175 get_paca()->shadow_vcpu.xer = val;
176 to_book3s(vcpu)->shadow_vcpu.xer = val;
177}
178
179static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
180{
181 return get_paca()->shadow_vcpu.xer;
182}
183
184#else
185
186static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
187{
188 vcpu->arch.gpr[num] = val;
189}
190
191static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
192{
193 return vcpu->arch.gpr[num];
194}
195
196static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
197{
198 vcpu->arch.cr = val;
199}
200
201static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
202{
203 return vcpu->arch.cr;
204}
205
206static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
207{
208 vcpu->arch.xer = val;
209}
210
211static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
212{
213 return vcpu->arch.xer;
214}
215
216#endif
217
218#endif /* __POWERPC_KVM_PPC_H__ */ 143#endif /* __POWERPC_KVM_PPC_H__ */