From: Keir Fraser Date: Fri, 5 Dec 2008 13:06:57 +0000 (+0000) Subject: minios: Clip memory not usable by Mini-OS (above 1GB) X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14026^2~67 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7e60fdf5b1f934061f26ec514b6dfecb83d7d46b;p=xen.git minios: Clip memory not usable by Mini-OS (above 1GB) Signed-off-by: Samuel Thibault --- diff --git a/extras/mini-os/arch/x86/mm.c b/extras/mini-os/arch/x86/mm.c index b1c0084fe7..07b6da8d1e 100644 --- a/extras/mini-os/arch/x86/mm.c +++ b/extras/mini-os/arch/x86/mm.c @@ -420,7 +420,9 @@ static unsigned long demand_map_area_start; #define DEMAND_MAP_PAGES ((2ULL << 30) / PAGE_SIZE) #endif -#ifdef HAVE_LIBC +#ifndef HAVE_LIBC +#define HEAP_PAGES 0 +#else unsigned long heap, brk, heap_mapped, heap_end; #ifdef __x86_64__ #define HEAP_PAGES ((128ULL << 30) / PAGE_SIZE) @@ -591,7 +593,7 @@ void arch_init_p2m(unsigned long max_pfn) void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p) { - unsigned long start_pfn, max_pfn; + unsigned long start_pfn, max_pfn, virt_pfns; printk(" _text: %p\n", &_text); printk(" _etext: %p\n", &_etext); @@ -604,7 +606,12 @@ void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p) start_pfn = PFN_UP(to_phys(start_info.pt_base)) + start_info.nr_pt_frames + 3; max_pfn = start_info.nr_pages; - + + /* We need room for demand mapping and heap, clip available memory */ + virt_pfns = DEMAND_MAP_PAGES + HEAP_PAGES; + if (max_pfn + virt_pfns + 1 < max_pfn) + max_pfn = -(virt_pfns + 1); + printk(" start_pfn: %lx\n", start_pfn); printk(" max_pfn: %lx\n", max_pfn);