aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include/asm/kvm_book3s.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/include/asm/kvm_book3s.h')
-rw-r--r--arch/powerpc/include/asm/kvm_book3s.h98
1 files changed, 97 insertions, 1 deletions
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index 7670e2a1286..9517b8deafe 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -71,7 +71,7 @@ struct kvmppc_sid_map {
71 71
72struct kvmppc_vcpu_book3s { 72struct kvmppc_vcpu_book3s {
73 struct kvm_vcpu vcpu; 73 struct kvm_vcpu vcpu;
74 struct kvmppc_book3s_shadow_vcpu shadow_vcpu; 74 struct kvmppc_book3s_shadow_vcpu *shadow_vcpu;
75 struct kvmppc_sid_map sid_map[SID_MAP_NUM]; 75 struct kvmppc_sid_map sid_map[SID_MAP_NUM];
76 struct kvmppc_slb slb[64]; 76 struct kvmppc_slb slb[64];
77 struct { 77 struct {
@@ -147,6 +147,94 @@ static inline ulong dsisr(void)
147} 147}
148 148
149extern void kvm_return_point(void); 149extern void kvm_return_point(void);
150static inline struct kvmppc_book3s_shadow_vcpu *to_svcpu(struct kvm_vcpu *vcpu);
151
152static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
153{
154 if ( num < 14 ) {
155 to_svcpu(vcpu)->gpr[num] = val;
156 to_book3s(vcpu)->shadow_vcpu->gpr[num] = val;
157 } else
158 vcpu->arch.gpr[num] = val;
159}
160
161static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
162{
163 if ( num < 14 )
164 return to_svcpu(vcpu)->gpr[num];
165 else
166 return vcpu->arch.gpr[num];
167}
168
169static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
170{
171 to_svcpu(vcpu)->cr = val;
172 to_book3s(vcpu)->shadow_vcpu->cr = val;
173}
174
175static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
176{
177 return to_svcpu(vcpu)->cr;
178}
179
180static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
181{
182 to_svcpu(vcpu)->xer = val;
183 to_book3s(vcpu)->shadow_vcpu->xer = val;
184}
185
186static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
187{
188 return to_svcpu(vcpu)->xer;
189}
190
191static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
192{
193 to_svcpu(vcpu)->ctr = val;
194}
195
196static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
197{
198 return to_svcpu(vcpu)->ctr;
199}
200
201static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
202{
203 to_svcpu(vcpu)->lr = val;
204}
205
206static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
207{
208 return to_svcpu(vcpu)->lr;
209}
210
211static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
212{
213 to_svcpu(vcpu)->pc = val;
214}
215
216static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
217{
218 return to_svcpu(vcpu)->pc;
219}
220
221static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu)
222{
223 ulong pc = kvmppc_get_pc(vcpu);
224 struct kvmppc_book3s_shadow_vcpu *svcpu = to_svcpu(vcpu);
225
226 /* Load the instruction manually if it failed to do so in the
227 * exit path */
228 if (svcpu->last_inst == KVM_INST_FETCH_FAILED)
229 kvmppc_ld(vcpu, &pc, sizeof(u32), &svcpu->last_inst, false);
230
231 return svcpu->last_inst;
232}
233
234static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
235{
236 return to_svcpu(vcpu)->fault_dar;
237}
150 238
151/* Magic register values loaded into r3 and r4 before the 'sc' assembly 239/* Magic register values loaded into r3 and r4 before the 'sc' assembly
152 * instruction for the OSI hypercalls */ 240 * instruction for the OSI hypercalls */
@@ -155,4 +243,12 @@ extern void kvm_return_point(void);
155 243
156#define INS_DCBZ 0x7c0007ec 244#define INS_DCBZ 0x7c0007ec
157 245
246/* Also add subarch specific defines */
247
248#ifdef CONFIG_PPC_BOOK3S_32
249#include <asm/kvm_book3s_32.h>
250#else
251#include <asm/kvm_book3s_64.h>
252#endif
253
158#endif /* __ASM_KVM_BOOK3S_H__ */ 254#endif /* __ASM_KVM_BOOK3S_H__ */