From: Tim Deegan Subject: Re: [PATCH 1/2] fix locking in offline_page() Date: Wed, 27 Nov 2013 11:53:05 +0100 Message-ID: <20131127105305.GE51509@deinos.phlegethon.org> References: <5295B64E0200007800107636@nat28.tlf.novell.com> <5295BAA5020000780010765A@nat28.tlf.novell.com> <5295C2F5.8010207@citrix.com> <5295D2120200007800107709@nat28.tlf.novell.com> <20131127103404.GB51509@deinos.phlegethon.org> <5295DAD7020000780010777C@nat28.tlf.novell.com> <20131127104839.GD51509@deinos.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Vlck3-0006ei-I8 for xen-devel@lists.xenproject.org; Wed, 27 Nov 2013 10:53:11 +0000 Content-Disposition: inline In-Reply-To: <20131127104839.GD51509@deinos.phlegethon.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: George Dunlap , Andrew Cooper , Keir Fraser , xen-devel List-Id: xen-devel@lists.xenproject.org At 11:48 +0100 on 27 Nov (1385549319), Tim Deegan wrote: > At 10:43 +0000 on 27 Nov (1385545399), Jan Beulich wrote: > > >>> On 27.11.13 at 11:34, Tim Deegan wrote: > > > At 10:05 +0000 on 27 Nov (1385543154), Jan Beulich wrote: > > >> >>> On 27.11.13 at 11:01, Andrew Cooper wrote: > > >> > On 27/11/13 08:25, Jan Beulich wrote: > > >> >> else > > >> >> { > > >> >> *status = PG_OFFLINE_OWNED | PG_OFFLINE_PENDING | > > >> >> - (owner->domain_id << PG_OFFLINE_OWNER_SHIFT); > > >> >> + (owner->domain_id << PG_OFFLINE_OWNER_SHIFT); > > >> > > > >> > domain_id will be promoted from a uint16_t to an int32_t, then shifted > > >> > left by 16 bits which is undefined if the top of domain_id bit was set. > > >> > > >> That promotion is done by zero extension, so I don't figure what > > >> you think is undefined here. > > > > > > If the domid has bit 15 set, it will be shifted into the sign bit of > > > the promoted integer; it should be explicitly cast to an unsigned type > > > before the shift. > > > > Again - I don't see this. Promotion happens before the shift, > > i.e. 0x8000 -> 0x00008000 -> 0x80000000. > > AIUI the default promotion is to a signed integer if the value will > fit, i.e.: > (unsigned short) 0x8000 > promoted (signed int) 0x00008000 > shifted left (signed int) 0x80000000 (undefined behaviour) > > (but I don't have my copy of the standard here to check). (and AFAICT there's no way for a real domain's domain_id to hva the top bit set so it's a moot point). Tim.