From: Ian Campbell Subject: Re: [PATCH RFC 6/9] xen: arm: handle variable p2m levels in p2m_lookup Date: Thu, 4 Sep 2014 15:54:09 +0100 Message-ID: <1409842449.10156.25.camel@kazak.uk.xensource.com> References: <3ef2b68c511f3e31de409b76757b95c78b99d750.1406728037.git.ian.campbell@citrix.com> <5a0397cc676556da56a3204c9e056052f5dcb9da.1406728037.git.ian.campbell@citrix.com> <53DA250A.7090307@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53DA250A.7090307@linaro.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: Julien Grall Cc: stefano.stabellini@eu.citrix.com, tim@xen.org, vijay.kilari@gmail.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, 2014-07-31 at 12:14 +0100, Julien Grall wrote: > > + if ( level == 3 && !p2m_table(pte) ) > > + /* Invalid, clobber the pte */ > > + pte.bits = 0; > > + if ( level == 3 || !p2m_table(pte) ) > > + /* Done */ > > + break; > > > > - BUILD_BUG_ON(THIRD_MASK != PAGE_MASK); > > + BUG_ON(level == 3); > > Rather than checking level == 3, I would add > BUG_ON(level < 4) at the end of loop. You mean outside/before the loop? That doesn't work if we hit a superpage mapping, since we will exit the loop with level < 4. I think it needs to stay where it is. > The only drawback to be there is we map one more page. > > And same remark as the previous BUG_ON(). I did make it an ASSERT(level < 3) though. Ian.