From e7272b29feb855f4678c5c510d331f297351d3a2 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Mon, 9 Dec 2024 18:35:54 +0100 Subject: mmu: Make certain allocations physical and virtual mapping linear Previously it was possible for fragmentation to occur and as a result certain allocations would have a linear virtual address space but not a linear physical address space. This is bad since a lot of calls to kmalloc_align rely upon both being linear, it has now been changed such that all allocations done by kmalloc_align now guarantee this mapping holds for both virtual and physical addresses. It was due to oversight and sheer luck that this had been working for so long. --- kernel/kmalloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'kernel/kmalloc.c') diff --git a/kernel/kmalloc.c b/kernel/kmalloc.c index bea9431..e5c95af 100644 --- a/kernel/kmalloc.c +++ b/kernel/kmalloc.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -62,7 +61,7 @@ MallocHeader *final = NULL; u32 total_heap_size = 0; int init_heap(void) { - head = (MallocHeader *)ksbrk(NEW_ALLOC_SIZE); + head = (MallocHeader *)ksbrk(NEW_ALLOC_SIZE, 0); if (!head) { return 0; } @@ -80,7 +79,7 @@ int add_heap_memory(size_t min_desired) { size_t allocation_size = max(min_desired, NEW_ALLOC_SIZE); allocation_size += delta_page(allocation_size); void *p; - if (!(p = (void *)ksbrk(allocation_size))) { + if (!(p = (void *)ksbrk(allocation_size, 0))) { return 0; } total_heap_size += allocation_size - sizeof(MallocHeader); -- cgit v1.2.3