From: Ian Campbell Subject: Re: [PATCH 06/10] xen: arm: Add a pte_of_xenaddr helper Date: Tue, 25 Jun 2013 11:50:34 +0100 Message-ID: <1372157434.22783.225.camel@zakaz.uk.xensource.com> References: <1371562002.22783.25.camel@zakaz.uk.xensource.com> <1371562017-5379-6-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: julien.grall@citrix.com, tim@xen.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, 2013-06-20 at 17:32 +0100, Stefano Stabellini wrote: > On Tue, 18 Jun 2013, Ian Campbell wrote: > > The open coded version is pretty ugly, not helped by rigid enforcement of an > > 80 character line length. > > > > Signed-off-by: Ian Campbell > > Makes sense. Too bad we can't have pte_of_xenaddr in mm.h because > phys_offset is static in mm.c. Can change that if we think there is a user, or better when the user arrives. Or do you think there is existing code which could use this? > In any case > > Acked-by: Stefano Stabellini > > > > xen/arch/arm/mm.c | 13 +++++++++---- > > 1 files changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c > > index 773fbf6..5ad687f 100644 > > --- a/xen/arch/arm/mm.c > > +++ b/xen/arch/arm/mm.c > > @@ -331,6 +331,13 @@ void __cpuinit setup_virt_paging(void) > > * write to TTBR0 has completed. */ \ > > flush_xen_text_tlb() > > > > +static inline lpae_t pte_of_xenaddr(vaddr_t va) > > +{ > > + paddr_t ma = va + phys_offset; > > + unsigned long mfn = ma >> PAGE_SHIFT; > > + return mfn_to_xen_entry(mfn); > > +} > > + > > /* Boot-time pagetable setup. > > * Changes here may need matching changes in head.S */ > > void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) > > @@ -387,8 +394,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) > > flush_xen_text_tlb(); > > > > /* Link in the fixmap pagetable */ > > - pte = mfn_to_xen_entry((((unsigned long) xen_fixmap) + phys_offset) > > - >> PAGE_SHIFT); > > + pte = pte_of_xenaddr((vaddr_t)xen_fixmap); > > pte.pt.table = 1; > > write_pte(xen_second + second_table_offset(FIXMAP_ADDR(0)), pte); > > /* > > @@ -415,8 +421,7 @@ void __init setup_pagetables(unsigned long boot_phys_offset, paddr_t xen_paddr) > > write_pte(xen_xenmap + i, pte); > > /* No flush required here as page table is not hooked in yet. */ > > } > > - pte = mfn_to_xen_entry((((unsigned long) xen_xenmap) + phys_offset) > > - >> PAGE_SHIFT); > > + pte = pte_of_xenaddr((vaddr_t)xen_xenmap); > > pte.pt.table = 1; > > write_pte(xen_second + second_linear_offset(XEN_VIRT_START), pte); > > /* TLBFLUSH and ISB would be needed here, but wait until we set WXN */ > > -- > > 1.7.2.5 > >