From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH v3 16/30] KVM: x86 emulator: If LOCK prefix is used dest arg should be memory. Date: Mon, 15 Mar 2010 20:10:24 +0200 Message-ID: <20100315181024.GD5406@redhat.com> References: <1268663937-27784-1-git-send-email-gleb@redhat.com> <1268663937-27784-17-git-send-email-gleb@redhat.com> <4B9E564C.4060306@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org To: Andre Przywara Return-path: Received: from mx1.redhat.com ([209.132.183.28]:17616 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965510Ab0COSKd (ORCPT ); Mon, 15 Mar 2010 14:10:33 -0400 Content-Disposition: inline In-Reply-To: <4B9E564C.4060306@amd.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Mar 15, 2010 at 04:46:20PM +0100, Andre Przywara wrote: > Gleb Natapov wrote: > >If LOCK prefix is used dest arg should be memory, otherwise instruction > >should generate #UD. > Well, there is one exception: > There is an AMD specific "lock mov cr0 = mov cr8" equivalence, where > there is no memory involved (and we intercept this). I am not sure > if anyone actually uses this code sequence, but it is definitely > legal. > Even without this patch "lock mov cr0" will cause #UD to be injected by emulator since mov does not have Lock in opcode table. Also it look like Intel does not support this extension so no portable program can use it. > Regards, > Andre. > > > > >Signed-off-by: Gleb Natapov > >--- > > arch/x86/kvm/emulate.c | 2 +- > > 1 files changed, 1 insertions(+), 1 deletions(-) > > > >diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c > >index b89a8f2..46a7ee3 100644 > >--- a/arch/x86/kvm/emulate.c > >+++ b/arch/x86/kvm/emulate.c > >@@ -1842,7 +1842,7 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) > > } > > /* LOCK prefix is allowed only with some instructions */ > >- if (c->lock_prefix && !(c->d & Lock)) { > >+ if (c->lock_prefix && (!(c->d & Lock) || c->dst.type != OP_MEM)) { > > kvm_queue_exception(ctxt->vcpu, UD_VECTOR); > > goto done; > > } > > > -- > Andre Przywara > AMD-OSRC (Dresden) > Tel: x29712 -- Gleb.