[PATCH 05/11] KVM: PPC: add GPR RA update skeleton for MMIO emulation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Simon Guo <wei.guo.simon@xxxxxxxxx>

To optimize kvm emulation code with analyse_instr, adds new
mmio_update_ra flag to aid with GPR RA update.

This patch arms RA update at load/store emulation path for both
qemu mmio emulation or coalesced mmio emulation.

Signed-off-by: Simon Guo <wei.guo.simon@xxxxxxxxx>
---
 arch/powerpc/include/asm/kvm_host.h  |  2 ++
 arch/powerpc/kvm/emulate_loadstore.c |  1 +
 arch/powerpc/kvm/powerpc.c           | 17 +++++++++++++++++
 3 files changed, 20 insertions(+)

diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index 2d87768..1c7da00 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -673,6 +673,8 @@ struct kvm_vcpu_arch {
 	u8 mmio_sign_extend;
 	/* conversion between single and double precision */
 	u8 mmio_sp64_extend;
+	u8 mmio_ra; /* GPR as ra to be updated with EA */
+	u8 mmio_update_ra;
 	/*
 	 * Number of simulations for vsx.
 	 * If we use 2*8bytes to simulate 1*16bytes,
diff --git a/arch/powerpc/kvm/emulate_loadstore.c b/arch/powerpc/kvm/emulate_loadstore.c
index b8a3aef..90b9692 100644
--- a/arch/powerpc/kvm/emulate_loadstore.c
+++ b/arch/powerpc/kvm/emulate_loadstore.c
@@ -111,6 +111,7 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
 	vcpu->arch.mmio_sp64_extend = 0;
 	vcpu->arch.mmio_sign_extend = 0;
 	vcpu->arch.mmio_vmx_copy_nums = 0;
+	vcpu->arch.mmio_update_ra = 0;
 	vcpu->arch.mmio_host_swabbed = 0;
 
 	switch (get_op(inst)) {
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index bef27b1..f7fd68f 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -1111,6 +1111,12 @@ static int __kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
 
 	if (!ret) {
 		kvmppc_complete_mmio_load(vcpu, run);
+		if (vcpu->arch.mmio_update_ra) {
+			kvmppc_set_gpr(vcpu, vcpu->arch.mmio_ra,
+					vcpu->arch.vaddr_accessed);
+			vcpu->arch.mmio_update_ra = 0;
+		}
+
 		vcpu->mmio_needed = 0;
 		return EMULATE_DONE;
 	}
@@ -1215,6 +1221,12 @@ int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
 
 	if (!ret) {
 		vcpu->mmio_needed = 0;
+		if (vcpu->arch.mmio_update_ra) {
+			kvmppc_set_gpr(vcpu, vcpu->arch.mmio_ra,
+					vcpu->arch.vaddr_accessed);
+			vcpu->arch.mmio_update_ra = 0;
+		}
+
 		return EMULATE_DONE;
 	}
 
@@ -1581,6 +1593,11 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
 			}
 		}
 #endif
+		if (vcpu->arch.mmio_update_ra) {
+			kvmppc_set_gpr(vcpu, vcpu->arch.mmio_ra,
+					vcpu->arch.vaddr_accessed);
+			vcpu->arch.mmio_update_ra = 0;
+		}
 	} else if (vcpu->arch.osi_needed) {
 		u64 *gprs = run->osi.gprs;
 		int i;
-- 
1.8.3.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux