memblock can now self re-allocate its internal buffers
memory allocated by memblock_alloc() can now be limited to a certain region.
This commit is contained in:
34
sandbox/vm/vm_bootstrap.c
Normal file
34
sandbox/vm/vm_bootstrap.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <limits.h>
|
||||
#include <socks/vm.h>
|
||||
#include <socks/memblock.h>
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* One vm_pg_data_t per NUMA node. Right now we're only worrying about a single node */
|
||||
static vm_pg_data_t node_data = {};
|
||||
|
||||
kern_status_t vm_bootstrap(const vm_region_t *mem_map, size_t nr_mem_map_entries)
|
||||
{
|
||||
uintptr_t pmap_min = UINTPTR_MAX, pmap_max = 0x0;
|
||||
|
||||
for (size_t i = 0; i < nr_mem_map_entries; i++) {
|
||||
if (mem_map[i].r_base < pmap_min) {
|
||||
pmap_min = mem_map[i].r_base;
|
||||
}
|
||||
|
||||
if (mem_map[i].r_limit > pmap_max) {
|
||||
pmap_max = mem_map[i].r_limit;
|
||||
}
|
||||
}
|
||||
|
||||
memblock_add(pmap_min, pmap_max);
|
||||
|
||||
|
||||
for (size_t i = 0; i < nr_mem_map_entries; i++) {
|
||||
if (mem_map[i].r_status == VM_REGION_RESERVED) {
|
||||
memblock_reserve(mem_map[i].r_base, mem_map[i].r_limit);
|
||||
}
|
||||
}
|
||||
|
||||
return KERN_OK;
|
||||
}
|
||||
Reference in New Issue
Block a user