Commit Graph

45 Commits

Author SHA1 Message Date
883b5ac9e2 vm: add vm-region to manage userspace virtual memory address spaces
vm-region supports creating nested regions of virtual memory, each with their
own memory protection restrictions.

vm-objects can be mapped into a vm-region, making the underlying memory
accessible. all mappings are lazy: page tables are not updated until the
mapped memory is accessed.
2026-02-08 12:59:08 +00:00
b8ccffd2d4 vm: add vm-object to represent non-contiguous physical memory allocations
vm-object can be used to demand-allocate non-contiguous physical memory, and
will provide an api for userspace programs to do the same. unless a vm-object
is created in-place (i.e. to represent a specific area of physical memory),
its memory pages are only allocated when the object is mapped AND someone
attempts to access the memory.
2026-02-08 12:58:31 +00:00
b31c3a40b4 vm: sparse: ensure that vm_pages for the reserved bsp region are created 2026-02-08 12:51:55 +00:00
2b1bed844a vm: change virt_to_phys param to const 2026-02-08 12:51:23 +00:00
26afc3c6c3 vm: sparse: fix region base/limit alignment calculation 2026-02-08 12:50:08 +00:00
aaa76ff197 memblock: make virt_to_phys pointer param const 2026-02-08 12:33:03 +00:00
0490541dc9 kernel: adjust formatting 2026-02-08 12:32:48 +00:00
62ec4c93ab meta: rename 2024-11-02 11:31:51 +00:00
149f49bd28 vm: limit sparse page init loop to last free page frame
when the sector coverage mode is set to free, the loop that initialises the vm_page structs for free and reserved pages is limited to the same upper bound that is used to calculate the sector size and count.
2023-12-30 15:29:48 +00:00
abfd97b924 memblock: fix bounds being ignored when iterating through total or reserved regions 2023-12-30 15:29:13 +00:00
1c5c256c89 vm: sparse sector map now extends to cover only all free pages by default
by default, the sector map created under the sparse model now only extends to the last non-reserved page frame, any reserved page frames afterwards are ignored.
2023-12-29 19:53:31 +00:00
8803c23f08 vm: improve memory usage under sparse with a high reserved memory ratio
previously, sparse would attempt to create a smaller number of larger sectors on systems with lots of reserved memory, often causing an out-of-memory condition. the reserved memory ratio calculation now compares reserved memory to free memory, rather than to the address of the last byte in physical memory. this improved heuristic means sparse is now better at choosing an appropriate sector size, allowing sparse to operate on systems with high amounts of reserved memory.
2023-12-24 09:39:28 +00:00
8b99158d66 vm: fix overflow in memblock do_alloc when allocating large aligned blocks
allocating a large power-of-2 block with memblock may cause the base pointer of a region to exceed the limit pointer after it has been aligned during the free region scan in do_alloc().
2023-12-24 09:37:52 +00:00
1cbab5f2f4 vm: optimise vm_zone_init by only making blocks from free regions during boot 2023-12-24 09:35:50 +00:00
9f3c080e41 vm: minimum and maximum zone IDs are now defined in arch/../vm.h 2023-05-07 21:39:31 +01:00
223b37a113 vm: only align slab headers when offslab is being used 2023-05-01 18:12:46 +01:00
b6f8c1ccaa kernel: don't use typedef for enums or non-opaque structs 2023-04-13 11:40:52 +01:00
b1b16ba19c kernel: reduce log message spam during boot 2023-04-09 17:14:19 +01:00
dd6c190720 memblock: fix returned memory region overrunning reserved memory region 2023-03-24 14:17:28 +00:00
2bfb6bcd78 kernel: add c++ support 2023-03-20 20:41:39 +00:00
ff19915466 vm: mark memory holes as reserved under sparse memory model 2023-02-17 19:34:12 +00:00
8c4c224435 vm: fix get_or_create_page not allocating enough memory for sparse page map 2023-02-08 21:29:45 +00:00
22eabbedbc vm: log per-zone free memory during init 2023-02-08 21:29:20 +00:00
9792aa512d vm: use vm_memory_mode() to determine which model to initialise 2023-02-08 21:28:47 +00:00
6c6ca6920b vm: handle null vm_pages and empty zones in zone init 2023-02-08 20:26:51 +00:00
b32791ade7 vm: zero sector array; perform overflow checks 2023-02-08 20:26:18 +00:00
a595b3040a vm: remove debug message from get_or_create_page 2023-02-08 20:25:52 +00:00
a9f8069aab vm: add sparse mm support to vm_page functions 2023-02-08 20:25:24 +00:00
a7d4166c89 vm: implement a sparse memory model 2023-02-08 17:13:01 +00:00
b8eb88627a vm: add huge page order size definitions 2023-02-08 17:11:08 +00:00
4edc7e308e vm: refactor page_array and functions into a separate source file 2023-02-07 21:18:08 +00:00
9879bbf646 vm: optimise page array size and initialisation.
* the page array now only extends up to the last non-reserved memory frame.
* rather than memset'ing the whole array to zero, we only initialise p_flags
  for each page in vm_page_array_init, and then leave it to group_pages_into_block
  to initialise the other parts of vm_page_t.
2023-02-07 16:00:28 +00:00
51ad3d48fd memblock: mark bytes preceding an aligned allocation as reserved.
this prevents tiny holes of free memory appearing between
blocks of aligned allocations.
2023-02-07 15:57:18 +00:00
e9d4b60181 vm: print log messages during initialisation 2023-02-07 15:43:14 +00:00
bf0b4d412c vm: use direct page mapping to convert virt/phys addresses 2023-02-07 15:40:06 +00:00
0516ef06a3 vm: explicitly initialise kmalloc in vm_bootstrap
if kmalloc is called with count=N before vm_bootstrap is finished,
the request will be fulfilled using memblock_alloc.

if N is a power of 2, the returned pointer will be aligned to
an N-byte boundary.
2023-02-06 20:50:38 +00:00
5c7bde4fdf vm: add alignment parameter to cache allocator
caches with object size N, where N is a power of two, will naturally
align their objects on N-byte boundaries.

all other caches will align to an 8-byte boundary by default.
2023-02-06 20:50:38 +00:00
109616ec30 vm: add memblock support to vm_virt_to_phys, add vm_phys_to_virt 2023-02-06 20:50:38 +00:00
998f05d337 memblock: add functions to convert allocated pointers between virt/phys 2023-02-06 20:50:38 +00:00
6afb3bd10d memblock: add alignment parameter to alloc functions 2023-02-06 20:50:38 +00:00
21907010bd memblock: return NULL on virtual alloc failure 2023-02-05 10:49:59 +00:00
247bb2b530 kernel: port sandbox components 2023-02-03 20:51:23 +00:00
40f83922da sandbox: moved all sources to main kernel tree 2023-02-03 20:43:38 +00:00
e714d619ba kernel: remove placeholder vm subsystem 2023-02-03 20:37:45 +00:00
e922a776c3 Added stubs for the kernel memory manager 2022-12-28 23:04:09 +00:00