From: Ian Campbell Subject: Re: [PATCH] xen/arm: p2m: flush tlb when a domain is destroyed Date: Thu, 24 Oct 2013 15:28:35 +0100 Message-ID: <1382624915.22417.107.camel@hastur.hellion.org.uk> References: <1382624683-27093-1-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 1VZLu1-00060I-6V for xen-devel@lists.xenproject.org; Thu, 24 Oct 2013 14:28:45 +0000 In-Reply-To: <1382624683-27093-1-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, stefano.stabellini@citrix.com, time@xen.org, patches@linaro.org List-Id: xen-devel@lists.xenproject.org On Thu, 2013-10-24 at 15:24 +0100, Julien Grall wrote: > Once the VMID is marked unused, a new domain can reuse the VMID for its > own. If the TLB is not flushed, entries can contain wrong translation. > Arm assembly doesn't provide instruction to flush TLB by VMID, except > for current VMID but the domain is already unscheduled from every physical > CPUs. So flush TLB for all VMIDs on every CPU (inner shareable). Did you consider temporarily switching to the VMID in order to flush it? Or flushing on allocate rather than free or flushing when the p2m is first loaded (via a hook in p2m_load_vttbr)? > > Signed-off-by: Julien Grall > --- > xen/arch/arm/p2m.c | 3 +++ > xen/include/asm-arm/arm32/flushtlb.h | 11 +++++++++++ > 2 files changed, 14 insertions(+) > > diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c > index 2d09fef..d4497f9 100644 > --- a/xen/arch/arm/p2m.c > +++ b/xen/arch/arm/p2m.c > @@ -357,6 +357,9 @@ static void p2m_free_vmid(struct domain *d) > spin_lock(&vmid_alloc_lock); > if ( p2m->vmid != INVALID_VMID ) > clear_bit(p2m->vmid, vmid_mask); > + > + flush_tlb_all(); > + > spin_unlock(&vmid_alloc_lock); > } > > diff --git a/xen/include/asm-arm/arm32/flushtlb.h b/xen/include/asm-arm/arm32/flushtlb.h > index a258f58..7b4a73e 100644 > --- a/xen/include/asm-arm/arm32/flushtlb.h > +++ b/xen/include/asm-arm/arm32/flushtlb.h This needs an arm64 version too. > @@ -23,6 +23,17 @@ static inline void flush_tlb_all_local(void) > isb(); > } > > +/* Flush inner shareable TLBs, all VMIDs, non-hypervisor mode */ > +static inline void flush_tlb_all(void) > +{ > + dsb(); > + > + WRITE_CP32((uint32_t) 0, TLBIALLNSNHIS); Is the cast really necessary? I'd have thought that at the very most 0U would be all that was needed. > + > + dsb(); > + isb(); > +} > + > #endif /* __ASM_ARM_ARM32_FLUSHTLB_H__ */ > /* > * Local variables: