diff --git a/arch/x86/kernel/memory.c b/arch/x86/kernel/memory.c index dc5df9d3..74e5d95e 100644 --- a/arch/x86/kernel/memory.c +++ b/arch/x86/kernel/memory.c @@ -45,7 +45,11 @@ void *early_alloc_pages(int nr_pages) last_page = phys_to_virt(virt_to_phys(last_page)); } else if (last_page == (void *)-1) { panic("Early allocator is already finalized. Do not use it.\n"); - } + } else { + if(virt_to_phys(last_page) >= bootstrap_mem_end) { + panic("Early allocator: Out of memory\n"); + } + } p = last_page; last_page += (nr_pages * PAGE_SIZE); diff --git a/lib/include/ihk/mm.h b/lib/include/ihk/mm.h index 97da7066..b1cd80d6 100644 --- a/lib/include/ihk/mm.h +++ b/lib/include/ihk/mm.h @@ -34,6 +34,8 @@ enum ihk_mc_gma_type { IHK_MC_RESERVED_AREA_END, }; +extern unsigned long bootstrap_mem_end; + enum ihk_mc_ma_type { IHK_MC_MA_AVAILABLE, IHK_MC_MA_RESERVED,