sandbox: vm: implement page freeing; merge/split bugfix

This commit is contained in:
2023-02-01 17:05:14 +00:00
parent ca92093c10
commit 9409ebbb19
4 changed files with 91 additions and 21 deletions

View File

@@ -17,7 +17,7 @@
#define VM_PAGE_SIZE 0x1000
#define VM_PAGE_SHIFT 12
#define VM_PAGE_IS_RESERVED(pg) ((pg)->p_flags & VM_PAGE_RESERVED)
#define VM_PAGE_IS_FREE(pg) (((pg)->p_flags & (VM_PAGE_RESERVED | VM_PAGE_ALLOC)) == 0)
#define vm_page_foreach(pg, i) \
for (vm_page_t *i = (pg); i; i = vm_page_get_next_tail(i))
@@ -101,10 +101,12 @@ typedef enum vm_page_flags {
/* page is reserved (probably by a call to memblock_reserve()) and cannot be
returned by any allocation function */
VM_PAGE_RESERVED = 0x01u,
/* page has been allocated by a zone's buddy allocator, and is in-use */
VM_PAGE_ALLOC = 0x02u,
/* page is the first page of a huge-page */
VM_PAGE_HEAD = 0x02u,
VM_PAGE_HEAD = 0x04u,
/* page is part of a huge-page */
VM_PAGE_HUGE = 0x04u,
VM_PAGE_HUGE = 0x08u,
} vm_page_flags_t;
typedef struct vm_page {