Sizing the available memory should respect memory holes, so look at
the memory map when setting the boundary for the memory allocator.
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
{
long ret;
domid_t domid = DOMID_SELF;
- unsigned long max;
pt_base = page_table_base;
first_free_pfn = PFN_UP(to_phys(&_end));
xprintk("could not get memory size\n");
do_exit();
}
- last_free_pfn = ret;
- max = e820_get_maxpfn();
- if ( max < last_free_pfn )
- last_free_pfn = max;
+ last_free_pfn = e820_get_maxpfn(ret);
}
#endif
}
#endif
-unsigned long e820_get_maxpfn(void)
+unsigned long e820_get_maxpfn(unsigned long pages)
{
int i;
- unsigned long pfn, max = 0;
+ unsigned long pfns = 0, start = 0;
e820_get_memmap();
{
if ( e820_map[i].type != E820_RAM )
continue;
- pfn = (e820_map[i].addr + e820_map[i].size) >> PAGE_SHIFT;
- if ( pfn > max )
- max = pfn;
+ pfns = e820_map[i].size >> PAGE_SHIFT;
+ start = e820_map[i].addr >> PAGE_SHIFT;
+ if ( pages <= pfns )
+ return start + pages;
+ pages -= pfns;
}
- return max;
+ return start + pfns;
}
extern struct e820entry e820_map[];
extern unsigned e820_entries;
-unsigned long e820_get_maxpfn(void);
+unsigned long e820_get_maxpfn(unsigned long pages);
#endif /*__E820_HEADER*/