From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v4 2/2] x86/hvm: clean up segment validation Date: Fri, 22 Nov 2013 14:27:19 +0000 Message-ID: <528F69C7.7010902@citrix.com> References: <528DF45E.7050905@citrix.com> <20131121150355.GC89770@deinos.phlegethon.org> <528E219B.6060801@citrix.com> <20131121151308.GD89770@deinos.phlegethon.org> <20131121153231.GE89770@deinos.phlegethon.org> <528E5753.5020104@citrix.com> <528F53250200007800105C7C@nat28.tlf.novell.com> <20131122115453.GB86420@deinos.phlegethon.org> <528F766E0200007800105E45@nat28.tlf.novell.com> 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 1Vjrhb-0006bX-E4 for xen-devel@lists.xenproject.org; Fri, 22 Nov 2013 14:27:23 +0000 In-Reply-To: <528F766E0200007800105E45@nat28.tlf.novell.com> 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: "xen-devel@lists.xenproject.org" , keir@xen.org, David Binderman , Tim Deegan List-Id: xen-devel@lists.xenproject.org On 22/11/13 14:21, Jan Beulich wrote: > Use _SEGMENT_* instead of plain numbers where feasible. > > Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper > > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -2259,7 +2259,7 @@ static int hvm_load_segment_selector( > desc = *pdesc; > > /* Segment present in memory? */ > - if ( !(desc.b & (1u<<15)) ) > + if ( !(desc.b & _SEGMENT_P) ) > { > fault_type = TRAP_no_segment; > goto unmap_and_fail; > @@ -2277,7 +2277,7 @@ static int hvm_load_segment_selector( > { > case x86_seg_cs: > /* Code segment? */ > - if ( !(desc.b & (1u<<11)) ) > + if ( !(desc.b & _SEGMENT_CODE) ) > goto unmap_and_fail; > /* Non-conforming segment: check DPL against RPL. */ > if ( !(desc.b & _SEGMENT_EC) && (dpl != rpl) ) > @@ -2285,19 +2285,19 @@ static int hvm_load_segment_selector( > break; > case x86_seg_ss: > /* Writable data segment? */ > - if ( (desc.b & (5u<<9)) != (1u<<9) ) > + if ( (desc.b & (_SEGMENT_CODE|_SEGMENT_WR)) != _SEGMENT_WR ) > goto unmap_and_fail; > if ( (dpl != cpl) || (dpl != rpl) ) > goto unmap_and_fail; > break; > case x86_seg_ldtr: > /* LDT system segment? */ > - if ( (desc.b & (15u<<8)) != (2u<<8) ) > + if ( (desc.b & _SEGMENT_TYPE) != (2u<<8) ) > goto unmap_and_fail; > goto skip_accessed_flag; > default: > /* Readable code or data segment? */ > - if ( (desc.b & (5u<<9)) == (4u<<9) ) > + if ( (desc.b & (_SEGMENT_CODE|_SEGMENT_WR)) == _SEGMENT_CODE ) > goto unmap_and_fail; > /* > * Data or non-conforming code segment: > > >