Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+7 -11
+7 -11
arch/powerpc/include/asm/kvm_book3s.h
··· 264 264 return vcpu->arch.pc; 265 265 } 266 266 267 - static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu) 267 + static inline u32 kvmppc_get_last_inst_internal(struct kvm_vcpu *vcpu, ulong pc) 268 268 { 269 - ulong pc = kvmppc_get_pc(vcpu); 270 - 271 269 /* Load the instruction manually if it failed to do so in the 272 270 * exit path */ 273 271 if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED) 274 272 kvmppc_ld(vcpu, &pc, sizeof(u32), &vcpu->arch.last_inst, false); 275 273 276 274 return vcpu->arch.last_inst; 275 + } 276 + 277 + static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu) 278 + { 279 + return kvmppc_get_last_inst_internal(vcpu, kvmppc_get_pc(vcpu)); 277 280 } 278 281 279 282 /* ··· 286 283 */ 287 284 static inline u32 kvmppc_get_last_sc(struct kvm_vcpu *vcpu) 288 285 { 289 - ulong pc = kvmppc_get_pc(vcpu) - 4; 290 - 291 - /* Load the instruction manually if it failed to do so in the 292 - * exit path */ 293 - if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED) 294 - kvmppc_ld(vcpu, &pc, sizeof(u32), &vcpu->arch.last_inst, false); 295 - 296 - return vcpu->arch.last_inst; 286 + return kvmppc_get_last_inst_internal(vcpu, kvmppc_get_pc(vcpu) - 4); 297 287 } 298 288 299 289 static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)