[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] page_alloc: clear nr_bootmem_regions in end_boot_allocator()
commit 5fcf1c2516d253011b7c1001fe6a82e6c293f708 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Tue Feb 7 14:32:05 2017 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Tue Feb 7 14:32:05 2017 +0100 page_alloc: clear nr_bootmem_regions in end_boot_allocator() ... to make alloc_boot_pages() fail for late callers. Don't rely on reaching the BOOT_BUG_ON(1) near the end of that function though, but instead make this situation easier to distinguish from actual allocation failures by adding an explicit check. While there, make the iteration variable unsigned and guard against underflow. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/common/page_alloc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index ae2476d..915e1f7 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -329,13 +329,16 @@ unsigned long __init alloc_boot_pages( unsigned long nr_pfns, unsigned long pfn_align) { unsigned long pg, _e; - int i; + unsigned int i = nr_bootmem_regions; - for ( i = nr_bootmem_regions - 1; i >= 0; i-- ) + BOOT_BUG_ON(!nr_bootmem_regions); + + while ( i-- ) { struct bootmem_region *r = &bootmem_region_list[i]; + pg = (r->e - nr_pfns) & ~(pfn_align - 1); - if ( pg < r->s ) + if ( pg >= r->e || pg < r->s ) continue; #if defined(CONFIG_X86) && !defined(NDEBUG) @@ -1352,6 +1355,7 @@ void __init end_boot_allocator(void) if ( r->s < r->e ) init_heap_pages(mfn_to_page(r->s), r->e - r->s); } + nr_bootmem_regions = 0; init_heap_pages(virt_to_page(bootmem_region_list), 1); if ( !dma_bitsize && (num_online_nodes() > 1) ) -- 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 |