vm: sparse: ensure that vm_pages for the reserved bsp region are created

This commit is contained in:
2026-02-08 12:51:55 +00:00
parent 2b1bed844a
commit b31c3a40b4

View File

@@ -23,6 +23,7 @@
overhead, and the flat memory model may be a better choice. overhead, and the flat memory model may be a better choice.
*/ */
#include <mango/arg.h> #include <mango/arg.h>
#include <mango/bsp.h>
#include <mango/machine/cpu.h> #include <mango/machine/cpu.h>
#include <mango/memblock.h> #include <mango/memblock.h>
#include <mango/panic.h> #include <mango/panic.h>
@@ -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) for_each_reserved_mem_range(&it, 0x0, pmem_end)
{ {
if (it.it_base & VM_PAGE_MASK) { if (it.it_base & VM_PAGE_MASK) {