[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v3 03/16] xen/arm: p2m: Redefine mfn_to_page and page_to_mfn to use typesafe
On Fri, 30 Jun 2017, Julien Grall wrote: > The file xen/arch/arm/p2m.c is using typesafe MFN in most of the place. > This requires caller to mfn_to_page and page_to_mfn to use _mfn/mfn_x. > > To avoid extra _mfn/mfn_x, re-define mfn_to_page and page_to_mfn within > xen/arch/arm/p2m.c to handle typesafe MFN. > > Signed-off-by: Julien Grall <julien.grall@xxxxxxx> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> > --- > The idea behind redefining locally mfn_to_page and page_to_mfn is > splitting the introduction of typesafe MFN in smaller series and > between multiple people. We know the file is typesafe ready and if > we decide to make the main helper typesafe, we would just need to > drop the definition at the top of the file. > > Changes in v3: > - Use __page_to_mfn(...) rather than mfn_x(page_to_mfn(...)) > --- > xen/arch/arm/p2m.c | 20 +++++++++++++------- > 1 file changed, 13 insertions(+), 7 deletions(-) > > diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c > index 05eb584e89..3e20a1ec82 100644 > --- a/xen/arch/arm/p2m.c > +++ b/xen/arch/arm/p2m.c > @@ -38,6 +38,12 @@ static unsigned int __read_mostly max_vmid = > MAX_VMID_8_BIT; > > #define P2M_ROOT_PAGES (1<<P2M_ROOT_ORDER) > > +/* Override macros from asm/mm.h to make them work with mfn_t */ > +#undef mfn_to_page > +#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) > +#undef page_to_mfn > +#define page_to_mfn(pg) _mfn(__page_to_mfn(pg)) > + > unsigned int __read_mostly p2m_ipa_bits; > > /* Helpers to lookup the properties of each level */ > @@ -115,7 +121,7 @@ void dump_p2m_lookup(struct domain *d, paddr_t addr) > printk("dom%d IPA 0x%"PRIpaddr"\n", d->domain_id, addr); > > printk("P2M @ %p mfn:0x%lx\n", > - p2m->root, page_to_mfn(p2m->root)); > + p2m->root, __page_to_mfn(p2m->root)); > > dump_pt_walk(page_to_maddr(p2m->root), addr, > P2M_ROOT_LEVEL, P2M_ROOT_PAGES); > @@ -591,7 +597,7 @@ static int p2m_create_table(struct p2m_domain *p2m, > lpae_t *entry) > * The access value does not matter because the hardware will ignore > * the permission fields for table entry. > */ > - pte = mfn_to_p2m_entry(_mfn(page_to_mfn(page)), p2m_invalid, > + pte = mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, > p2m->default_access); > > p2m_write_pte(entry, pte, p2m->clean_pte); > @@ -650,9 +656,9 @@ static void p2m_put_l3_page(const lpae_t pte) > */ > if ( p2m_is_foreign(pte.p2m.type) ) > { > - unsigned long mfn = pte.p2m.base; > + mfn_t mfn = _mfn(pte.p2m.base); > > - ASSERT(mfn_valid(_mfn(mfn))); > + ASSERT(mfn_valid(mfn)); > put_page(mfn_to_page(mfn)); > } > } > @@ -702,7 +708,7 @@ static void p2m_free_entry(struct p2m_domain *p2m, > mfn = _mfn(entry.p2m.base); > ASSERT(mfn_valid(mfn)); > > - pg = mfn_to_page(mfn_x(mfn)); > + pg = mfn_to_page(mfn); > > page_list_del(pg, &p2m->pages); > free_domheap_page(pg); > @@ -780,7 +786,7 @@ static bool p2m_split_superpage(struct p2m_domain *p2m, > lpae_t *entry, > > unmap_domain_page(table); > > - pte = mfn_to_p2m_entry(_mfn(page_to_mfn(page)), p2m_invalid, > + pte = mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, > p2m->default_access); > > /* > @@ -1442,7 +1448,7 @@ struct page_info *get_page_from_gva(struct vcpu *v, > vaddr_t va, > if ( !mfn_valid(maddr_to_mfn(maddr)) ) > goto err; > > - page = mfn_to_page(mfn_x(maddr_to_mfn(maddr))); > + page = mfn_to_page(maddr_to_mfn(maddr)); > ASSERT(page); > > if ( unlikely(!get_page(page, d)) ) > -- > 2.11.0 > _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |