Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 954cd36f authored by Guillaume Thouvenin's avatar Guillaume Thouvenin Committed by Avi Kivity
Browse files

KVM: x86 emulator: add support for jmp far 0xea



Add support for jmp far (opcode 0xea) instruction.

Signed-off-by: default avatarGuillaume Thouvenin <guillaume.thouvenin@ext.bull.net>
Signed-off-by: default avatarLaurent Vivier <laurent.vivier@bull.net>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 89c69638
Loading
Loading
Loading
Loading
+29 −2
Original line number Original line Diff line number Diff line
@@ -168,7 +168,8 @@ static u16 opcode_table[256] = {
	/* 0xE0 - 0xE7 */
	/* 0xE0 - 0xE7 */
	0, 0, 0, 0, 0, 0, 0, 0,
	0, 0, 0, 0, 0, 0, 0, 0,
	/* 0xE8 - 0xEF */
	/* 0xE8 - 0xEF */
	ImplicitOps | Stack, SrcImm|ImplicitOps, 0, SrcImmByte|ImplicitOps,
	ImplicitOps | Stack, SrcImm | ImplicitOps,
	ImplicitOps, SrcImmByte | ImplicitOps,
	0, 0, 0, 0,
	0, 0, 0, 0,
	/* 0xF0 - 0xF7 */
	/* 0xF0 - 0xF7 */
	0, 0, 0, 0,
	0, 0, 0, 0,
@@ -1661,7 +1662,33 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
		break;
		break;
	}
	}
	case 0xe9: /* jmp rel */
	case 0xe9: /* jmp rel */
	case 0xeb: /* jmp rel short */
		goto jmp;
	case 0xea: /* jmp far */ {
		uint32_t eip;
		uint16_t sel;

		switch (c->op_bytes) {
		case 2:
			eip = insn_fetch(u16, 2, c->eip);
			break;
		case 4:
			eip = insn_fetch(u32, 4, c->eip);
			break;
		default:
			DPRINTF("jmp far: Invalid op_bytes\n");
			goto cannot_emulate;
		}
		sel = insn_fetch(u16, 2, c->eip);
		if (kvm_load_segment_descriptor(ctxt->vcpu, sel, 9, VCPU_SREG_CS) < 0) {
			DPRINTF("jmp far: Failed to load CS descriptor\n");
			goto cannot_emulate;
		}

		c->eip = eip;
		break;
	}
	case 0xeb:
	      jmp:		/* jmp rel short */
		jmp_rel(c, c->src.val);
		jmp_rel(c, c->src.val);
		c->dst.type = OP_NONE; /* Disable writeback. */
		c->dst.type = OP_NONE; /* Disable writeback. */
		break;
		break;