summaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2018-11-09 10:07:10 -0500
committerMarc Zyngier <marc.zyngier@arm.com>2018-12-18 09:10:36 -0500
commit0d640732dbebed0f10f18526de21652931f0b2f2 (patch)
treeaa9c116f560d604190b904d0a0b966cdae8e6519 /virt
parent2e6e902d185027f8e3cb8b7305238f7e35d6a436 (diff)
arm64: KVM: Skip MMIO insn after emulation
When we emulate an MMIO instruction, we advance the CPU state within decode_hsr(), before emulating the instruction effects. Having this logic in decode_hsr() is opaque, and advancing the state before emulation is problematic. It gets in the way of applying consistent single-step logic, and it prevents us from being able to fail an MMIO instruction with a synchronous exception. Clean this up by only advancing the CPU state *after* the effects of the instruction are emulated. Cc: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/mmio.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/virt/kvm/arm/mmio.c b/virt/kvm/arm/mmio.c
index dac7ceb1a677..08443a15e6be 100644
--- a/virt/kvm/arm/mmio.c
+++ b/virt/kvm/arm/mmio.c
@@ -117,6 +117,12 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run)
117 vcpu_set_reg(vcpu, vcpu->arch.mmio_decode.rt, data); 117 vcpu_set_reg(vcpu, vcpu->arch.mmio_decode.rt, data);
118 } 118 }
119 119
120 /*
121 * The MMIO instruction is emulated and should not be re-executed
122 * in the guest.
123 */
124 kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
125
120 return 0; 126 return 0;
121} 127}
122 128
@@ -144,11 +150,6 @@ static int decode_hsr(struct kvm_vcpu *vcpu, bool *is_write, int *len)
144 vcpu->arch.mmio_decode.sign_extend = sign_extend; 150 vcpu->arch.mmio_decode.sign_extend = sign_extend;
145 vcpu->arch.mmio_decode.rt = rt; 151 vcpu->arch.mmio_decode.rt = rt;
146 152
147 /*
148 * The MMIO instruction is emulated and should not be re-executed
149 * in the guest.
150 */
151 kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
152 return 0; 153 return 0;
153} 154}
154 155