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: Tue, 16 Mar 2010 11:43:49 +0200 Message-ID: <20100316094349.GB1365@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> <20100315181024.GD5406@redhat.com> <4B9F515F.2050406@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Andre Przywara , mtosatti@redhat.com, kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:4989 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757743Ab0CPJny (ORCPT ); Tue, 16 Mar 2010 05:43:54 -0400 Content-Disposition: inline In-Reply-To: <4B9F515F.2050406@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Mar 16, 2010 at 11:37:35AM +0200, Avi Kivity wrote: > On 03/15/2010 08:10 PM, Gleb Natapov wrote: > >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. > > > > A portable program can check for this instruction in cpuid and only > issue it if it is supported. > Yes, indeed there is cpuid for that. It looks like our decoder needs one more layer of transformation to distinguish between regular prefixes and prefixes that modifies opcode meaning. -- Gleb.