diff --git a/mm/memory.c b/mm/memory.c index 2150243e..803fcc02 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -183,15 +183,6 @@ int mmu_init(void) atomic_int32_inc(&total_allocated_pages); atomic_int32_dec(&total_available_pages); - /* - * The init ram disk are already loaded. - * Therefore, we set these pages as used. - */ - for(addr=bootinfo->addr; addr < bootinfo->addr+bootinfo->size; addr+=PAGE_SIZE) { - page_set_mark(addr >> PAGE_SHIFT); - atomic_int32_inc(&total_allocated_pages); - atomic_int32_dec(&total_available_pages); - } #else #error Currently, MetalSVM supports only the Multiboot specification or the RockCreek processor! #endif @@ -239,6 +230,17 @@ int mmu_init(void) atomic_int32_inc(&total_pages); atomic_int32_inc(&total_available_pages); } + + /* + * The init ram disk are already loaded. + * Therefore, we set these pages as used. + */ + for(addr=bootinfo->addr; addr < bootinfo->addr+bootinfo->size; addr+=PAGE_SIZE) { + // This area is already mapped, so we need to virt_to_phys() these addresses. + page_set_mark(virt_to_phys(addr) >> PAGE_SHIFT); + atomic_int32_inc(&total_allocated_pages); + atomic_int32_dec(&total_available_pages); + } #endif return ret;