@@ -13,6 +13,11 @@
static struct spinlock lock;
static void *freelist = 0;
+bool page_alloc_initialized(void)
+{
+ return freelist != 0;
+}
+
void free_pages(void *mem, unsigned long size)
{
void *old_freelist;
@@ -8,6 +8,7 @@
#ifndef ALLOC_PAGE_H
#define ALLOC_PAGE_H 1
+bool page_alloc_initialized(void);
void *alloc_page();
void *alloc_pages(unsigned long order);
void free_page(void *page);
@@ -94,9 +94,12 @@ void setup_vm()
return;
phys_alloc_get_unused(&base, &top);
- base = (base + PAGE_SIZE - 1) & -PAGE_SIZE;
- top = top & -PAGE_SIZE;
- free_pages(phys_to_virt(base), top - base);
+ assert(base != top || page_alloc_initialized());
+ if (!page_alloc_initialized()) {
+ base = (base + PAGE_SIZE - 1) & -PAGE_SIZE;
+ top = top & -PAGE_SIZE;
+ free_pages(phys_to_virt(base), top - base);
+ }
page_root = setup_mmu(top);
alloc_ops = &vmalloc_ops;
}
Signed-off-by: Andrew Jones <drjones@redhat.com> --- lib/alloc_page.c | 5 +++++ lib/alloc_page.h | 1 + lib/vmalloc.c | 9 ++++++--- 3 files changed, 12 insertions(+), 3 deletions(-)