diff options
author | Laurent Vivier <Laurent.Vivier@bull.net> | 2007-09-24 11:00:58 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:52:49 -0500 |
commit | a22436b7b8ec9b14a0451d9ac0fdc9d370bd7800 (patch) | |
tree | b96486abefb623cde2c0af4b82c459b9d811865f /drivers/kvm/kvm_main.c | |
parent | e4f8e03956de4b1a1dc4bbbdefa9c973d01ee91f (diff) |
KVM: Purify x86_decode_insn() error case management
The only valid case is on protected page access, other cases are errors.
Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r-- | drivers/kvm/kvm_main.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 2d55bab41634..888b0924c17b 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -1251,7 +1251,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu, | |||
1251 | u16 error_code, | 1251 | u16 error_code, |
1252 | int no_decode) | 1252 | int no_decode) |
1253 | { | 1253 | { |
1254 | int r = 0; | 1254 | int r; |
1255 | 1255 | ||
1256 | vcpu->mmio_fault_cr2 = cr2; | 1256 | vcpu->mmio_fault_cr2 = cr2; |
1257 | kvm_x86_ops->cache_regs(vcpu); | 1257 | kvm_x86_ops->cache_regs(vcpu); |
@@ -1294,10 +1294,14 @@ int emulate_instruction(struct kvm_vcpu *vcpu, | |||
1294 | get_segment_base(vcpu, VCPU_SREG_FS); | 1294 | get_segment_base(vcpu, VCPU_SREG_FS); |
1295 | 1295 | ||
1296 | r = x86_decode_insn(&vcpu->emulate_ctxt, &emulate_ops); | 1296 | r = x86_decode_insn(&vcpu->emulate_ctxt, &emulate_ops); |
1297 | if (r) { | ||
1298 | if (kvm_mmu_unprotect_page_virt(vcpu, cr2)) | ||
1299 | return EMULATE_DONE; | ||
1300 | return EMULATE_FAIL; | ||
1301 | } | ||
1297 | } | 1302 | } |
1298 | 1303 | ||
1299 | if (r == 0) | 1304 | r = x86_emulate_insn(&vcpu->emulate_ctxt, &emulate_ops); |
1300 | r = x86_emulate_insn(&vcpu->emulate_ctxt, &emulate_ops); | ||
1301 | 1305 | ||
1302 | if (vcpu->pio.string) | 1306 | if (vcpu->pio.string) |
1303 | return EMULATE_DO_MMIO; | 1307 | return EMULATE_DO_MMIO; |