public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] MIPS: KVM: role back pc in case of EMULATE_FAIL
@ 2015-05-07 12:51 Nicholas Mc Guire
  2015-05-08 14:42 ` James Hogan
  0 siblings, 1 reply; 3+ messages in thread
From: Nicholas Mc Guire @ 2015-05-07 12:51 UTC (permalink / raw)
  To: Gleb Natapov
  Cc: Paolo Bonzini, Ralf Baechle, kvm, linux-mips, linux-kernel,
	Nicholas Mc Guire

Currently if kvm_mips_complete_mmio_load() fails with EMULATE_FAIL it will
not role back the pc nor will the caller handle this failure.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
 arch/mips/kvm/emulate.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

kvm_mips_complete_mmio_load is called only in arch/mips/kvm/mips.c without
checking the return value to signal EMULATE_FAIL:
 383         if (vcpu->mmio_needed) {
 384                 if (!vcpu->mmio_is_write)
 385                         kvm_mips_complete_mmio_load(vcpu, run);
 386                 vcpu->mmio_needed = 0;
 387         }

so maybe kvm_mips_complete_mmio_load should role back in case of failure 
at arch/mips/kvm/emuilate.c:kvm_mips_complete_mmio_load()
2406         if (er == EMULATE_FAIL) {
2408                 return er;

something like the below patch - only based no looking at how EMULATE_FAIL
is handled at other locations - not sure if this is appropriate here.

Patch was only compile tested msp71xx_defconfig + CONFIG_KVM=m

Patch is against 4.1-rc2 (localversion-next is -next-20150506)

diff --git a/arch/mips/kvm/emulate.c b/arch/mips/kvm/emulate.c
index 2f0fc60..b58596b 100644
--- a/arch/mips/kvm/emulate.c
+++ b/arch/mips/kvm/emulate.c
@@ -2403,8 +2403,10 @@ enum emulation_result kvm_mips_complete_mmio_load(struct kvm_vcpu *vcpu,
 	 */
 	curr_pc = vcpu->arch.pc;
 	er = update_pc(vcpu, vcpu->arch.pending_load_cause);
-	if (er == EMULATE_FAIL)
+	if (er == EMULATE_FAIL) {
+		vcpu->arch.pc = curr_pc;
 		return er;
+	}
 
 	switch (run->mmio.len) {
 	case 4:
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-08 15:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-07 12:51 [PATCH RFC] MIPS: KVM: role back pc in case of EMULATE_FAIL Nicholas Mc Guire
2015-05-08 14:42 ` James Hogan
2015-05-08 15:39   ` Nicholas Mc Guire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox