Skip to contentSkip to conversation

KVM: inject #UD in 64bit mode from instruction that are not valid there

PATCH Applied Gleb Natapov 2 participants 2 messages Feb 11, 2010 – Feb 17, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: inject #UD in 64bit mode from instruction that are not valid there

Some instruction are obsolete in a long mode. Inject #UD.

---
Resend with SOB. Sorry.

arch/x86/kvm/emulate.c +5 -5
index 595c989..20e10a7 100644
@@ -1015,11 +1015,6 @@ done_prefixes:
 		}
 	}
 
-	if (mode == X86EMUL_MODE_PROT64 && (c->d & No64)) {
-		kvm_report_emulation_failure(ctxt->vcpu, "invalid x86/64 instruction");
-		return -1;
-	}
-
 	if (c->d & Group) {
 		group = c->d & GroupMask;
 		c->modrm = insn_fetch(u8, 1, c->eip);
@@ -1828,6 +1823,11 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops)
 	memcpy(c->regs, ctxt->vcpu->arch.regs, sizeof c->regs);
 	saved_eip = c->eip;
 
+	if (ctxt->mode == X86EMUL_MODE_PROT64 && (c->d & No64)) {
+		kvm_queue_exception(ctxt->vcpu, UD_VECTOR);
+		goto done;
+	}
+
 	/* LOCK prefix is allowed only with some instructions */
 	if (c->lock_prefix && !(c->d & Lock)) {
 		kvm_queue_exception(ctxt->vcpu, UD_VECTOR);

--
Gleb.

Applied
#1 lore raw
Quoted 3 lines · Gleb Natapov

Some instruction are obsolete in a long mode. Inject #UD.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function