diff mbox

[v2,3/8] Fix x86_emulate_insn() to handle faults propagated from kvm_load_segment_descriptor()

Message ID 20100210105632.8fa7205c.yoshikawa.takuya@oss.ntt.co.jp (mailing list archive)
State New, archived
Headers show

Commit Message

Takuya Yoshikawa Feb. 10, 2010, 1:56 a.m. UTC
None
diff mbox

Patch

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 645b245..4527940 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1980,7 +1980,6 @@  special_insn:
 	case 0x8e: { /* mov seg, r/m16 */
 		uint16_t sel;
 		int type_bits;
-		int err;
 
 		sel = c->src.val;
 		if (c->modrm_reg == VCPU_SREG_SS)
@@ -1988,16 +1987,16 @@  special_insn:
 
 		if (c->modrm_reg <= 5) {
 			type_bits = (c->modrm_reg == 1) ? 9 : 1;
-			err = kvm_load_segment_descriptor(ctxt->vcpu, sel,
-							  type_bits, c->modrm_reg);
+			rc = kvm_load_segment_descriptor(ctxt->vcpu, sel,
+							 type_bits, c->modrm_reg);
 		} else {
 			printk(KERN_INFO "Invalid segreg in modrm byte 0x%02x\n",
 					c->modrm);
 			goto cannot_emulate;
 		}
 
-		if (err < 0)
-			goto cannot_emulate;
+		if (rc != X86EMUL_CONTINUE)
+			goto done;
 
 		c->dst.type = OP_NONE;  /* Disable writeback. */
 		break;
@@ -2168,11 +2167,10 @@  special_insn:
 	case 0xe9: /* jmp rel */
 		goto jmp;
 	case 0xea: /* jmp far */
-		if (kvm_load_segment_descriptor(ctxt->vcpu, c->src2.val, 9,
-					VCPU_SREG_CS) < 0) {
-			DPRINTF("jmp far: Failed to load CS descriptor\n");
-			goto cannot_emulate;
-		}
+		rc = kvm_load_segment_descriptor(ctxt->vcpu, c->src2.val, 9,
+						 VCPU_SREG_CS);
+		if (rc != X86EMUL_CONTINUE)
+			goto done;
 
 		c->eip = c->src.val;
 		break;