From: Ian Campbell Subject: Re: [PATCH RESEND v9 01/14] arch/arm: add consistency check to REMOVE p2m changes Date: Thu, 17 Jul 2014 13:56:13 +0100 Message-ID: <1405601773.31127.17.camel@kazak.uk.xensource.com> References: <53BFEBFB.1090602@linaro.org> <1405299035-2988-1-git-send-email-avanzini.arianna@gmail.com> <1405299035-2988-2-git-send-email-avanzini.arianna@gmail.com> <53C3B7A3.8040405@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53C3B7A3.8040405@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: paolo.valente@unimore.it, keir@xen.org, stefano.stabellini@eu.citrix.com, tim@xen.org, dario.faggioli@citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, julien.grall@citrix.com, etrudeau@broadcom.com, andrew.cooper3@citrix.com, JBeulich@suse.com, Arianna Avanzini , viktor.kleinik@globallogic.com List-Id: xen-devel@lists.xenproject.org On Mon, 2014-07-14 at 11:57 +0100, Julien Grall wrote: > Hi Arianna, > > On 14/07/14 01:50, Arianna Avanzini wrote: > > xen/arch/arm/p2m.c | 21 ++++++++++++++++++++- > > 1 file changed, 20 insertions(+), 1 deletion(-) > > > > diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c > > index c0c011a..5a77189 100644 > > --- a/xen/arch/arm/p2m.c > > +++ b/xen/arch/arm/p2m.c > > @@ -596,12 +596,30 @@ static int apply_one_level(struct domain *d, > > > > break; > > > > - case RELINQUISH: > > case REMOVE: > > + if ( is_mapping_aligned(*addr, end_gpaddr, *maddr, level_size) ) > > + { > > + unsigned long mfn = orig_pte.p2m.base; > > I think the check is misplaced, it should go after: > > if ( level < 3 && p2m_table(orig_pte) ) > return P2M_ONE_DESCEND; Correct. Note that this also follows a check for non-present entries. so that part of the check can be dropped as well. > > It's because this code path can now be called with either a P2M Table or > a P2M entry. You will get wrong error message and may log many times the > same issue. > > Also I've reported an issue to Ian about this code path today. If the > guest balloning driver or your MMIO unmap a single 4K entry, it may fail > or remove a superpage by mistake. Right, see my patch "xen: arm: correctly handle removing a subset of a superpage mapping." from Monday. Ian.