From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH -v2] kvm: Emulate MOVBE Date: Mon, 22 Apr 2013 10:53:42 +0200 Message-ID: <5174FA96.1040807@redhat.com> References: <20130409234602.GI5077@pd.tnic> <20130410112942.07dfc167@slackpad> <20130410100845.GB17919@redhat.com> <20130410123901.46b65169@slackpad> <20130410121639.GE17919@redhat.com> <20130411001815.GA17544@pd.tnic> <20130414084303.GE17919@redhat.com> <20130414210218.GF20547@pd.tnic> <516D37A0.2070706@redhat.com> <20130421114649.GC4594@pd.tnic> <20130421122321.GD4594@pd.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Gleb Natapov , Andre Przywara , kvm@vger.kernel.org, =?UTF-8?B?SsO2cmcgUsO2ZGVs?= , "H. Peter Anvin" , x86-ml To: Borislav Petkov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:51096 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753099Ab3DVIyM (ORCPT ); Mon, 22 Apr 2013 04:54:12 -0400 In-Reply-To: <20130421122321.GD4594@pd.tnic> Sender: kvm-owner@vger.kernel.org List-ID: Il 21/04/2013 14:23, Borislav Petkov ha scritto: > On Sun, Apr 21, 2013 at 01:46:50PM +0200, Borislav Petkov wrote: >> We probably need something with copying values to a temp variable or so. > > Basically something like that: > > case 2: > /* > * From MOVBE definition: "...When the operand size is 16 bits, > * the upper word of the destination register remains unchanged > * ..." > * > * Both casting ->valptr and ->val to u16 breaks strict aliasing > * rules so we have to do the operation almost per hand. > */ > tmp = (u16)ctxt->src.val; > ctxt->dst.val &= ~0xffffUL; > ctxt->dst.val |= (unsigned long)swab16(tmp); > break; > > This passes all gcc checks, even the stricter ones when building with W=3. I thought the valptr one was ok. I find this one more readable, too. How does the generated code look like? Paolo