All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: inject #UD in 64bit mode from instruction that are not valid there
@ 2010-02-11 12:39 Gleb Natapov
  0 siblings, 0 replies; 3+ messages in thread
From: Gleb Natapov @ 2010-02-11 12:39 UTC (permalink / raw)
  To: avi, mtosatti; +Cc: kvm

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

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 595c989..20e10a7 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -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.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: inject #UD in 64bit mode from instruction that are not valid there
  2010-02-11 12:43 Gleb Natapov
@ 2010-02-17 13:03 ` Avi Kivity
  0 siblings, 0 replies; 3+ messages in thread
From: Avi Kivity @ 2010-02-17 13:03 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: mtosatti, kvm

On 02/11/2010 02:43 PM, Gleb Natapov wrote:
> Some instruction are obsolete in a long mode. Inject #UD.
>
>    

Applied, thanks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] KVM: inject #UD in 64bit mode from instruction that are not valid there
@ 2010-02-11 12:43 Gleb Natapov
  2010-02-17 13:03 ` Avi Kivity
  0 siblings, 1 reply; 3+ messages in thread
From: Gleb Natapov @ 2010-02-11 12:43 UTC (permalink / raw)
  To: avi, mtosatti; +Cc: kvm

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

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
Resend with SOB. Sorry.

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 595c989..20e10a7 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -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.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-17 13:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-11 12:39 [PATCH] KVM: inject #UD in 64bit mode from instruction that are not valid there Gleb Natapov
2010-02-11 12:43 Gleb Natapov
2010-02-17 13:03 ` Avi Kivity

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.