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

Commit 1146a78b authored by Gleb Natapov's avatar Gleb Natapov
Browse files

KVM: emulator: Do not fail on emulation of undefined opcode



Emulation of undefined opcode should inject #UD instead of causing
emulation failure. Do that by moving Undefined flag check to emulation
stage and injection #UD there.

Signed-off-by: default avatarGleb Natapov <gleb@redhat.com>
parent 991eebf9
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -4383,7 +4383,7 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)
	ctxt->intercept = opcode.intercept;
	ctxt->intercept = opcode.intercept;


	/* Unrecognised? */
	/* Unrecognised? */
	if (ctxt->d == 0 || (ctxt->d & NotImpl) || (ctxt->d & Undefined))
	if (ctxt->d == 0 || (ctxt->d & NotImpl))
		return EMULATION_FAILED;
		return EMULATION_FAILED;


	if (!(ctxt->d & VendorSpecific) && ctxt->only_vendor_specific_insn)
	if (!(ctxt->d & VendorSpecific) && ctxt->only_vendor_specific_insn)
@@ -4521,7 +4521,8 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)


	ctxt->mem_read.pos = 0;
	ctxt->mem_read.pos = 0;


	if (ctxt->mode == X86EMUL_MODE_PROT64 && (ctxt->d & No64)) {
	if ((ctxt->mode == X86EMUL_MODE_PROT64 && (ctxt->d & No64)) ||
			(ctxt->d & Undefined)) {
		rc = emulate_ud(ctxt);
		rc = emulate_ud(ctxt);
		goto done;
		goto done;
	}
	}