@@ -270,6 +270,12 @@ static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
return vcpu->arch.pc;
}
+static inline int kvmppc_ld32(struct kvm_vcpu *vcpu, ulong *eaddr,
+ u32 *ptr, bool data)
+{
+ return kvmppc_ld(vcpu, eaddr, sizeof(u32), ptr, data);
+}
+
static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu)
{
ulong pc = kvmppc_get_pc(vcpu);
@@ -277,7 +283,7 @@ static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu)
/* Load the instruction manually if it failed to do so in the
* exit path */
if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED)
- kvmppc_ld(vcpu, &pc, sizeof(u32), &vcpu->arch.last_inst, false);
+ kvmppc_ld32(vcpu, &pc, &vcpu->arch.last_inst, false);
return vcpu->arch.last_inst;
}
@@ -294,7 +300,7 @@ static inline u32 kvmppc_get_last_sc(struct kvm_vcpu *vcpu)
/* Load the instruction manually if it failed to do so in the
* exit path */
if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED)
- kvmppc_ld(vcpu, &pc, sizeof(u32), &vcpu->arch.last_inst, false);
+ kvmppc_ld32(vcpu, &pc, &vcpu->arch.last_inst, false);
return vcpu->arch.last_inst;
}
@@ -544,7 +544,7 @@ static int kvmppc_hv_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu,
* If we fail, we just return to the guest and try executing it again.
*/
if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED) {
- ret = kvmppc_ld(vcpu, &srr0, sizeof(u32), &last_inst, false);
+ ret = kvmppc_ld32(vcpu, &srr0, &last_inst, false);
if (ret != EMULATE_DONE || last_inst == KVM_INST_FETCH_FAILED)
return RESUME_GUEST;
vcpu->arch.last_inst = last_inst;
@@ -600,7 +600,7 @@ static int kvmppc_read_inst(struct kvm_vcpu *vcpu)
u32 last_inst = kvmppc_get_last_inst(vcpu);
int ret;
- ret = kvmppc_ld(vcpu, &srr0, sizeof(u32), &last_inst, false);
+ ret = kvmppc_ld32(vcpu, &srr0, &last_inst, false);
if (ret == -ENOENT) {
ulong msr = vcpu->arch.shared->msr;
This patch adds an helper routine kvmppc_ld32() to load an instruction form the guest. This routine will be modified in the next patch to take into account the endian order of the guest. Signed-off-by: Cédric Le Goater <clg@fr.ibm.com> --- Changes in v4: - got rid of useless helper routine kvmppc_ld_inst(). (Alexander Graf) arch/powerpc/include/asm/kvm_book3s.h | 10 ++++++++-- arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +- arch/powerpc/kvm/book3s_pr.c | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-)