vm: implement a sparse memory model

This commit is contained in:
2023-02-08 17:13:01 +00:00
parent 6690572bf3
commit a7d4166c89
4 changed files with 285 additions and 9 deletions

View File

@@ -3,6 +3,7 @@
#include <socks/vm.h>
#include <socks/memblock.h>
#include <socks/printk.h>
#include <socks/machine/cpu.h>
#include <stddef.h>
#include <limits.h>
#include <stdint.h>
@@ -18,8 +19,10 @@ kern_status_t vm_bootstrap(const vm_zone_descriptor_t *zones, size_t nr_zones)
node_data = memblock_alloc(sizeof(vm_pg_data_t) * numa_count, 8);
printk("vm: initialising %u node%s", numa_count, numa_count > 1 ? "s" : "");
vm_set_memory_model(VM_MODEL_FLAT);
vm_flat_init();
/* TODO select which memory model to use automatically, and add
a kernel boot parameter to override the choice */
vm_set_memory_model(VM_MODEL_SPARSE);
vm_sparse_init();
for (size_t i = 0; i < nr_zones; i++) {
vm_zone_init(&node_data->pg_zones[zones[i].zd_id], &zones[i]);