From: Ian Campbell Subject: Re: [PATCH v4 04/21] xen/arm: p2m: apply_p2m_changes: Only load domain P2M when we flush TLBs Date: Mon, 28 Apr 2014 14:54:27 +0100 Message-ID: <1398693267.29700.115.camel@kazak.uk.xensource.com> References: <1398172475-27873-1-git-send-email-julien.grall@linaro.org> <1398172475-27873-5-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wem0u-0008J7-Og for xen-devel@lists.xenproject.org; Mon, 28 Apr 2014 13:54:32 +0000 In-Reply-To: <1398172475-27873-5-git-send-email-julien.grall@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: xen-devel@lists.xenproject.org, tim@xen.org, stefano.stabellini@citrix.com List-Id: xen-devel@lists.xenproject.org On Tue, 2014-04-22 at 14:14 +0100, Julien Grall wrote: > apply_p2m_changes needs to switch to another VTTBR temporarily to avoid > flush every TLBs. > > As it's only needed there, we can restrict the scope where the VTTBR of this > domain is loaded. > > Signed-off-by: Julien Grall Acked-by: Ian Campbell Athough a flush_tlb_domain(d) type thing might be a nice addition. > > --- > Changes in v4: > - Patch added > --- > xen/arch/arm/p2m.c | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) > > diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c > index 0730da4..603c097 100644 > --- a/xen/arch/arm/p2m.c > +++ b/xen/arch/arm/p2m.c > @@ -296,9 +296,6 @@ static int apply_p2m_changes(struct domain *d, > > spin_lock(&p2m->lock); > > - if ( d != current->domain ) > - p2m_load_VTTBR(d); > - > addr = start_gpaddr; > while ( addr < end_gpaddr ) > { > @@ -454,12 +451,17 @@ static int apply_p2m_changes(struct domain *d, > > if ( flush ) > { > - /* At the beginning of the function, Xen is updating VTTBR > - * with the domain where the mappings are created. In this > - * case it's only necessary to flush TLBs on every CPUs with > - * the current VMID (our domain). > + /* Update the VTTBR if necessary with the domain where mappings > + * are created. In this case it's only necessary to flush TLBs > + * on every CPUs with the current VMID (our domain). > */ > + if ( d != current->domain ) > + p2m_load_VTTBR(d); > + > flush_tlb(); > + > + if ( d != current->domain ) > + p2m_load_VTTBR(current->domain); > } > > if ( op == ALLOCATE || op == INSERT ) > @@ -478,9 +480,6 @@ out: > if (second) unmap_domain_page(second); > if (first) unmap_domain_page(first); > > - if ( d != current->domain ) > - p2m_load_VTTBR(current->domain); > - > spin_unlock(&p2m->lock); > > return rc;