[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86/p2m: make p2m_alloc_ptp() return an MFN
commit daae9d6712685506904b03dc36260de356085629 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Mon Sep 4 16:30:47 2017 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Sep 4 16:30:47 2017 +0200 x86/p2m: make p2m_alloc_ptp() return an MFN None of the callers really needs the struct page_info pointer. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: George Dunlap <george.dunlap@xxxxxxxxxx> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx> --- xen/arch/x86/mm/p2m-ept.c | 10 +++++----- xen/arch/x86/mm/p2m-pt.c | 17 ++++++++--------- xen/arch/x86/mm/p2m.c | 16 ++++++++-------- xen/include/asm-x86/p2m.h | 2 +- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 8d9da92..23c0518 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -225,16 +225,16 @@ static void ept_p2m_type_to_flags(struct p2m_domain *p2m, ept_entry_t *entry, /* Fill in middle levels of ept table */ static int ept_set_middle_entry(struct p2m_domain *p2m, ept_entry_t *ept_entry) { - struct page_info *pg; + mfn_t mfn; ept_entry_t *table; unsigned int i; - pg = p2m_alloc_ptp(p2m, 0); - if ( pg == NULL ) + mfn = p2m_alloc_ptp(p2m, 0); + if ( mfn_eq(mfn, INVALID_MFN) ) return 0; ept_entry->epte = 0; - ept_entry->mfn = page_to_mfn(pg); + ept_entry->mfn = mfn_x(mfn); ept_entry->access = p2m->default_access; ept_entry->r = ept_entry->w = ept_entry->x = 1; @@ -243,7 +243,7 @@ static int ept_set_middle_entry(struct p2m_domain *p2m, ept_entry_t *ept_entry) ept_entry->suppress_ve = 1; - table = __map_domain_page(pg); + table = map_domain_page(mfn); for ( i = 0; i < EPT_PAGETABLE_ENTRIES; i++ ) table[i].suppress_ve = 1; diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index c192e4d..f386925 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -205,13 +205,12 @@ p2m_next_level(struct p2m_domain *p2m, void **table, /* PoD/paging: Not present doesn't imply empty. */ if ( !flags ) { - struct page_info *pg; + mfn_t mfn = p2m_alloc_ptp(p2m, type); - pg = p2m_alloc_ptp(p2m, type); - if ( pg == NULL ) + if ( mfn_eq(mfn, INVALID_MFN) ) return -ENOMEM; - new_entry = l1e_from_page(pg, P2M_BASE_FLAGS | _PAGE_RW); + new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW); switch ( type ) { case PGT_l3_page_table: @@ -235,7 +234,7 @@ p2m_next_level(struct p2m_domain *p2m, void **table, { /* Split superpages pages into smaller ones. */ unsigned long pfn = l1e_get_pfn(*p2m_entry); - struct page_info *pg; + mfn_t mfn; l1_pgentry_t *l1_entry; unsigned int i, level; @@ -263,11 +262,11 @@ p2m_next_level(struct p2m_domain *p2m, void **table, return -EINVAL; } - pg = p2m_alloc_ptp(p2m, type); - if ( pg == NULL ) + mfn = p2m_alloc_ptp(p2m, type); + if ( mfn_eq(mfn, INVALID_MFN) ) return -ENOMEM; - l1_entry = __map_domain_page(pg); + l1_entry = map_domain_page(mfn); /* Inherit original IOMMU permissions, but update Next Level. */ if ( iommu_hap_pt_share ) @@ -285,7 +284,7 @@ p2m_next_level(struct p2m_domain *p2m, void **table, unmap_domain_page(l1_entry); - new_entry = l1e_from_page(pg, P2M_BASE_FLAGS | _PAGE_RW); + new_entry = l1e_from_mfn(mfn, P2M_BASE_FLAGS | _PAGE_RW); p2m_add_iommu_flags(&new_entry, level, IOMMUF_readable|IOMMUF_writable); p2m->write_p2m_entry(p2m, gfn, p2m_entry, new_entry, level + 1); } diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index e8a57d1..45ed3c1 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -569,7 +569,7 @@ int p2m_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, return rc; } -struct page_info *p2m_alloc_ptp(struct p2m_domain *p2m, unsigned long type) +mfn_t p2m_alloc_ptp(struct p2m_domain *p2m, unsigned long type) { struct page_info *pg; @@ -577,13 +577,13 @@ struct page_info *p2m_alloc_ptp(struct p2m_domain *p2m, unsigned long type) ASSERT(p2m->domain); ASSERT(p2m->domain->arch.paging.alloc_page); pg = p2m->domain->arch.paging.alloc_page(p2m->domain); - if (pg == NULL) - return NULL; + if ( !pg ) + return INVALID_MFN; page_list_add_tail(pg, &p2m->pages); pg->u.inuse.type_info = type | 1 | PGT_validated; - return pg; + return page_to_mfn(pg); } void p2m_free_ptp(struct p2m_domain *p2m, struct page_info *pg) @@ -609,7 +609,7 @@ void p2m_free_ptp(struct p2m_domain *p2m, struct page_info *pg) */ int p2m_alloc_table(struct p2m_domain *p2m) { - struct page_info *p2m_top; + mfn_t top_mfn; struct domain *d = p2m->domain; int rc = 0; @@ -632,14 +632,14 @@ int p2m_alloc_table(struct p2m_domain *p2m) P2M_PRINTK("allocating p2m table\n"); - p2m_top = p2m_alloc_ptp(p2m, PGT_l4_page_table); - if ( p2m_top == NULL ) + top_mfn = p2m_alloc_ptp(p2m, PGT_l4_page_table); + if ( mfn_eq(top_mfn, INVALID_MFN) ) { p2m_unlock(p2m); return -ENOMEM; } - p2m->phys_table = pagetable_from_mfn(page_to_mfn(p2m_top)); + p2m->phys_table = pagetable_from_mfn(top_mfn); if ( hap_enabled(d) ) iommu_share_p2m_table(d); diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 6395e8f..ea55cb1 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -684,7 +684,7 @@ void p2m_mem_paging_resume(struct domain *d, vm_event_response_t *rsp); * Internal functions, only called by other p2m code */ -struct page_info *p2m_alloc_ptp(struct p2m_domain *p2m, unsigned long type); +mfn_t p2m_alloc_ptp(struct p2m_domain *p2m, unsigned long type); void p2m_free_ptp(struct p2m_domain *p2m, struct page_info *pg); /* Directly set a p2m entry: only for use by p2m code. Does not need -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |