From: Ian Campbell Subject: Re: [PATCH 14/45] xen: arm64: TLB flushes. Date: Thu, 7 Feb 2013 16:43:25 +0000 Message-ID: <1360255405.32479.95.camel@zakaz.uk.xensource.com> References: <1358956576.17440.60.camel@zakaz.uk.xensource.com> <1358956611-8432-14-git-send-email-ian.campbell@citrix.com> <20130207163434.GP77133@ocelot.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130207163434.GP77133@ocelot.phlegethon.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: Tim Deegan Cc: Stefano Stabellini , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Thu, 2013-02-07 at 16:34 +0000, Tim Deegan wrote: > At 15:56 +0000 on 23 Jan (1358956580), Ian Campbell wrote: > > --- a/xen/include/asm-arm/arm64/page.h > > +++ b/xen/include/asm-arm/arm64/page.h > > @@ -20,6 +20,58 @@ static inline void write_pte(lpae_t *p, lpae_t pte) > > > > #define __flush_xen_dcache_one(va) asm volatile ("dc cvac, %0;" : : "r" (va)) > > > > +/* > > + * Flush all hypervisor mappings from the TLB > > + * This is needed after changing Xen code mappings. > > + * > > + * The caller needs to issue the necessary DSB and D-cache flushes > > + * before calling flush_xen_text_tlb. > > + */ > > +static inline void flush_xen_text_tlb(void) > > +{ > > + asm volatile ( > > + "isb;" /* Ensure synchronization with previous changes to text */ > > + "tlbi alle2;" /* Flush hypervisor TLB */ > > + "ic iallu;" /* Flush I-cache */ > > + "dsb sy;" /* Ensure completion of TLB+BP flush */ > > No BP flush operation on arm64? Correct. > If so, I think this comment needs updating. Yup, I think I got most of them but missed this one. > > > + "isb;" > > + : : : "memory"); > > +} > > + > > +/* > > + * Flush all hypervisor mappings from the data TLB. This is not > > + * sufficient when changing code mappings or for self modifying code. > > + */ > > +static inline void flush_xen_data_tlb(void) > > +{ > > + asm volatile ( > > + "dsb sy;" /* Ensure visibility of PTE writes */ > > + "tlbi alle2;" /* Flush hypervisor TLB */ > > + "dsb sy;" /* Ensure completion of TLB flush */ > > + "isb;" > > + : : : "memory"); > > +} > > + > > +/* > > + * Flush one VA's hypervisor mappings from the data TLB. This is not > > + * sufficient when changing code mappings or for self modifying code. > > + */ > > +static inline void flush_xen_data_tlb_va(vaddr_t va) > > +{ > > + asm volatile( > > + "dsb sy;" /* Ensure preceding are visible */ > > + "tlbi vae2, %0;" > > + "dsb sy;" /* Ensure completion of the TLB flush */ > > + "isb;" > > + : : "r" (va>>PAGE_SHIFT) : "memory"); > > +} > > + > > +/* Flush all non-hypervisor mappings from the TLB */ > > +static inline void flush_guest_tlb(void) > > +{ > > + asm volatile("tlbi alle1,ns" : : : "memory"); > > +} > > What does the ',ns' do here? Er, I can't remember and I can't find it anywhere in the docs. It might be a typo of "is" which somehow makes it past gas. Or maybe something to do with non-secure e1? > And is the memory clobber required? (And if so, don't we need a DSB or two as well?) The 32-bit stuff doesn't have one either. But then it appears that this function is never called anyway... Ian.