[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] x86: Clean up {alloc, free}_xen_pagetable() interface to avoid use of
# HG changeset patch # User kfraser@xxxxxxxxxxxxxxxxxxxxx # Date 1172507117 0 # Node ID 9e5e94942045ac09a4d3e4aa87ef49e226b79d56 # Parent 45ddffd595a1a1bcf87ad3823143e37dab459fdd x86: Clean up {alloc,free}_xen_pagetable() interface to avoid use of frame_table variable before initialisation. This wasn't a bug, but was confusing. Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx> --- xen/arch/x86/mm.c | 6 +++--- xen/arch/x86/x86_32/mm.c | 25 +++++++++++++------------ xen/arch/x86/x86_64/mm.c | 29 +++++++++++++++++------------ xen/include/asm-x86/page.h | 4 ++-- 4 files changed, 35 insertions(+), 29 deletions(-) diff -r 45ddffd595a1 -r 9e5e94942045 xen/arch/x86/mm.c --- a/xen/arch/x86/mm.c Mon Feb 26 15:50:50 2007 +0000 +++ b/xen/arch/x86/mm.c Mon Feb 26 16:25:17 2007 +0000 @@ -3401,7 +3401,7 @@ int map_pages_to_xen( { local_flush_tlb_pge(); if ( !(l2e_get_flags(ol2e) & _PAGE_PSE) ) - free_xen_pagetable(l2e_get_page(ol2e)); + free_xen_pagetable(page_to_virt(l2e_get_page(ol2e))); } virt += 1UL << L2_PAGETABLE_SHIFT; @@ -3413,14 +3413,14 @@ int map_pages_to_xen( /* Normal page mapping. */ if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) ) { - pl1e = page_to_virt(alloc_xen_pagetable()); + pl1e = alloc_xen_pagetable(); clear_page(pl1e); l2e_write(pl2e, l2e_from_page(virt_to_page(pl1e), __PAGE_HYPERVISOR)); } else if ( l2e_get_flags(*pl2e) & _PAGE_PSE ) { - pl1e = page_to_virt(alloc_xen_pagetable()); + pl1e = alloc_xen_pagetable(); for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) l1e_write(&pl1e[i], l1e_from_pfn(l2e_get_pfn(*pl2e) + i, diff -r 45ddffd595a1 -r 9e5e94942045 xen/arch/x86/x86_32/mm.c --- a/xen/arch/x86/x86_32/mm.c Mon Feb 26 15:50:50 2007 +0000 +++ b/xen/arch/x86/x86_32/mm.c Mon Feb 26 16:25:17 2007 +0000 @@ -35,26 +35,27 @@ unsigned int PAGE_HYPERVISOR_NOCACHE = _ static unsigned long mpt_size; -struct page_info *alloc_xen_pagetable(void) +void *alloc_xen_pagetable(void) { extern int early_boot; extern unsigned long xenheap_phys_start; - struct page_info *pg; + unsigned long mfn; if ( !early_boot ) { void *v = alloc_xenheap_page(); - return ((v == NULL) ? NULL : virt_to_page(v)); - } - - pg = maddr_to_page(xenheap_phys_start); + BUG_ON(v == NULL); + return v; + } + + mfn = xenheap_phys_start >> PAGE_SHIFT; xenheap_phys_start += PAGE_SIZE; - return pg; -} - -void free_xen_pagetable(struct page_info *pg) -{ - free_xenheap_page(page_to_virt(pg)); + return mfn_to_virt(mfn); +} + +void free_xen_pagetable(void *v) +{ + free_xenheap_page(v); } l2_pgentry_t *virt_to_xen_l2e(unsigned long v) diff -r 45ddffd595a1 -r 9e5e94942045 xen/arch/x86/x86_64/mm.c --- a/xen/arch/x86/x86_64/mm.c Mon Feb 26 15:50:50 2007 +0000 +++ b/xen/arch/x86/x86_64/mm.c Mon Feb 26 16:25:17 2007 +0000 @@ -36,22 +36,27 @@ unsigned int m2p_compat_vstart = __HYPER unsigned int m2p_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START; #endif -struct page_info *alloc_xen_pagetable(void) +void *alloc_xen_pagetable(void) { extern int early_boot; - unsigned long pfn; + unsigned long mfn; if ( !early_boot ) - return alloc_domheap_page(NULL); + { + struct page_info *pg = alloc_domheap_page(NULL); + BUG_ON(pg == NULL); + return page_to_virt(pg); + } /* Early pagetables must come from low 1GB of memory. */ - pfn = alloc_boot_low_pages(1, 1); /* 0x0 - 0x40000000 */ - return ((pfn == 0) ? NULL : mfn_to_page(pfn)); -} - -void free_xen_pagetable(struct page_info *pg) -{ - free_domheap_page(pg); + mfn = alloc_boot_low_pages(1, 1); /* 0x0 - 0x40000000 */ + BUG_ON(mfn == 0); + return mfn_to_virt(mfn); +} + +void free_xen_pagetable(void *v) +{ + free_domheap_page(virt_to_page(v)); } l2_pgentry_t *virt_to_xen_l2e(unsigned long v) @@ -63,7 +68,7 @@ l2_pgentry_t *virt_to_xen_l2e(unsigned l pl4e = &idle_pg_table[l4_table_offset(v)]; if ( !(l4e_get_flags(*pl4e) & _PAGE_PRESENT) ) { - pl3e = page_to_virt(alloc_xen_pagetable()); + pl3e = alloc_xen_pagetable(); clear_page(pl3e); l4e_write(pl4e, l4e_from_paddr(__pa(pl3e), __PAGE_HYPERVISOR)); } @@ -71,7 +76,7 @@ l2_pgentry_t *virt_to_xen_l2e(unsigned l pl3e = l4e_to_l3e(*pl4e) + l3_table_offset(v); if ( !(l3e_get_flags(*pl3e) & _PAGE_PRESENT) ) { - pl2e = page_to_virt(alloc_xen_pagetable()); + pl2e = alloc_xen_pagetable(); clear_page(pl2e); l3e_write(pl3e, l3e_from_paddr(__pa(pl2e), __PAGE_HYPERVISOR)); } diff -r 45ddffd595a1 -r 9e5e94942045 xen/include/asm-x86/page.h --- a/xen/include/asm-x86/page.h Mon Feb 26 15:50:50 2007 +0000 +++ b/xen/include/asm-x86/page.h Mon Feb 26 16:25:17 2007 +0000 @@ -363,8 +363,8 @@ static inline int get_order_from_pages(u } /* Allocator functions for Xen pagetables. */ -struct page_info *alloc_xen_pagetable(void); -void free_xen_pagetable(struct page_info *pg); +void *alloc_xen_pagetable(void); +void free_xen_pagetable(void *v); l2_pgentry_t *virt_to_xen_l2e(unsigned long v); /* Map machine page range in Xen virtual address space. */ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |