From b31c3a40b461c0d8e650fe997e802747b700564b Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sun, 8 Feb 2026 12:51:55 +0000 Subject: [PATCH] vm: sparse: ensure that vm_pages for the reserved bsp region are created --- vm/sparse.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/vm/sparse.c b/vm/sparse.c index aa28f6a..f0663c2 100644 --- a/vm/sparse.c +++ b/vm/sparse.c @@ -23,6 +23,7 @@ overhead, and the flat memory model may be a better choice. */ #include +#include #include #include #include @@ -281,6 +282,25 @@ void vm_sparse_init(void) } } + struct boot_module bsp; + bsp_get_location(&bsp); + if (bsp.mod_base & VM_PAGE_MASK) { + bsp.mod_base &= ~VM_PAGE_MASK; + } + + if (bsp.mod_size & VM_PAGE_MASK) { + bsp.mod_size &= ~VM_PAGE_MASK; + bsp.mod_size += VM_PAGE_SIZE; + } + + /* make sure the vm_pages for the bsp image exist, so that they can be + * mapped in later */ + for (phys_addr_t i = bsp.mod_base; i < bsp.mod_base + bsp.mod_size; + i += VM_PAGE_SIZE) { + struct vm_page *pg = get_or_create_page(i); + pg->p_flags = VM_PAGE_RESERVED; + } + for_each_reserved_mem_range(&it, 0x0, pmem_end) { if (it.it_base & VM_PAGE_MASK) {