Commit a22436b7 authored by Laurent Vivier's avatar Laurent Vivier Committed by Avi Kivity

KVM: Purify x86_decode_insn() error case management

The only valid case is on protected page access, other cases are errors.
Signed-off-by: default avatarLaurent Vivier <Laurent.Vivier@bull.net>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent e4f8e039
...@@ -1251,7 +1251,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu, ...@@ -1251,7 +1251,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
u16 error_code, u16 error_code,
int no_decode) int no_decode)
{ {
int r = 0; int r;
vcpu->mmio_fault_cr2 = cr2; vcpu->mmio_fault_cr2 = cr2;
kvm_x86_ops->cache_regs(vcpu); kvm_x86_ops->cache_regs(vcpu);
...@@ -1294,9 +1294,13 @@ int emulate_instruction(struct kvm_vcpu *vcpu, ...@@ -1294,9 +1294,13 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
get_segment_base(vcpu, VCPU_SREG_FS); get_segment_base(vcpu, VCPU_SREG_FS);
r = x86_decode_insn(&vcpu->emulate_ctxt, &emulate_ops); r = x86_decode_insn(&vcpu->emulate_ctxt, &emulate_ops);
if (r) {
if (kvm_mmu_unprotect_page_virt(vcpu, cr2))
return EMULATE_DONE;
return EMULATE_FAIL;
}
} }
if (r == 0)
r = x86_emulate_insn(&vcpu->emulate_ctxt, &emulate_ops); r = x86_emulate_insn(&vcpu->emulate_ctxt, &emulate_ops);
if (vcpu->pio.string) if (vcpu->pio.string)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment