aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2014-01-09 05:10:44 -0500
committerAlexander Graf <agraf@suse.de>2014-01-09 05:10:46 -0500
commit7a8ff56be68239bd36a2b639cb40bfbcfc58dad3 (patch)
tree07b1de550303217b8048b457008b05bd942cfc3e /arch/powerpc/include
parent47d45d9f53a7c478fc83dff7b421cb4bc3ad9f94 (diff)
KVM: PPC: Unify kvmppc_get_last_inst and sc
We had code duplication between the inline functions to get our last instruction on normal interrupts and system call interrupts. Unify both helper functions towards a single implementation. Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/include')
-rw-r--r--arch/powerpc/include/asm/kvm_book3s.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index 8bb870694616..f8b23201c105 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -264,10 +264,8 @@ static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
264 return vcpu->arch.pc; 264 return vcpu->arch.pc;
265} 265}
266 266
267static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu) 267static inline u32 kvmppc_get_last_inst_internal(struct kvm_vcpu *vcpu, ulong pc)
268{ 268{
269 ulong pc = kvmppc_get_pc(vcpu);
270
271 /* Load the instruction manually if it failed to do so in the 269 /* Load the instruction manually if it failed to do so in the
272 * exit path */ 270 * exit path */
273 if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED) 271 if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED)
@@ -276,6 +274,11 @@ static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu)
276 return vcpu->arch.last_inst; 274 return vcpu->arch.last_inst;
277} 275}
278 276
277static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu)
278{
279 return kvmppc_get_last_inst_internal(vcpu, kvmppc_get_pc(vcpu));
280}
281
279/* 282/*
280 * Like kvmppc_get_last_inst(), but for fetching a sc instruction. 283 * Like kvmppc_get_last_inst(), but for fetching a sc instruction.
281 * Because the sc instruction sets SRR0 to point to the following 284 * Because the sc instruction sets SRR0 to point to the following
@@ -283,14 +286,7 @@ static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu)
283 */ 286 */
284static inline u32 kvmppc_get_last_sc(struct kvm_vcpu *vcpu) 287static inline u32 kvmppc_get_last_sc(struct kvm_vcpu *vcpu)
285{ 288{
286 ulong pc = kvmppc_get_pc(vcpu) - 4; 289 return kvmppc_get_last_inst_internal(vcpu, kvmppc_get_pc(vcpu) - 4);
287
288 /* Load the instruction manually if it failed to do so in the
289 * exit path */
290 if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED)
291 kvmppc_ld(vcpu, &pc, sizeof(u32), &vcpu->arch.last_inst, false);
292
293 return vcpu->arch.last_inst;
294} 290}
295 291
296static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu) 292static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)