From 23301b8c1b54ceab4481fac2111302b0f8f2e00c Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Mon, 18 Nov 2024 03:27:06 +0200 Subject: [PATCH] memory: Kernel threads require more memory for stack Threads will now use 128 KiB --- core/memory/stack_guard.cpp | 10 +++++----- include/memory/macro.hpp | 15 ++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/memory/stack_guard.cpp b/core/memory/stack_guard.cpp index e05e85a..c052b5e 100644 --- a/core/memory/stack_guard.cpp +++ b/core/memory/stack_guard.cpp @@ -128,16 +128,16 @@ namespace Memory } else { - Memory::KernelStackManager::StackAllocation sa = StackManager.DetailedAllocate(STACK_SIZE); + Memory::KernelStackManager::StackAllocation sa = StackManager.DetailedAllocate(LARGE_STACK_SIZE); this->StackBottom = sa.VirtualAddress; - this->StackTop = (void *)((uintptr_t)this->StackBottom + STACK_SIZE); + this->StackTop = (void *)((uintptr_t)this->StackBottom + LARGE_STACK_SIZE); this->StackPhysicalBottom = sa.PhysicalAddress; - this->StackPhysicalTop = (void *)((uintptr_t)this->StackPhysicalBottom + STACK_SIZE); - this->Size = STACK_SIZE; + this->StackPhysicalTop = (void *)((uintptr_t)this->StackPhysicalBottom + LARGE_STACK_SIZE); + this->Size = LARGE_STACK_SIZE; debug("StackBottom: %#lx", this->StackBottom); - for (size_t i = 0; i < TO_PAGES(STACK_SIZE); i++) + for (size_t i = 0; i < TO_PAGES(LARGE_STACK_SIZE); i++) { AllocatedPages pa = { .PhysicalAddress = (void *)((uintptr_t)this->StackPhysicalBottom + (i * PAGE_SIZE)), diff --git a/include/memory/macro.hpp b/include/memory/macro.hpp index b82f502..c600c75 100644 --- a/include/memory/macro.hpp +++ b/include/memory/macro.hpp @@ -39,8 +39,9 @@ #define PAGE_SIZE_4M 0x400000 /* 4 MiB */ #define PAGE_SIZE_1G 0x40000000 /* 1 GiB */ -#define STACK_SIZE 0x4000 /* 16 KiB */ -#define USER_STACK_SIZE 0x2000 /* 8 KiB */ +#define STACK_SIZE 0x4000 /* 16 KiB */ +#define LARGE_STACK_SIZE 0x20000 /* 128 KiB */ +#define USER_STACK_SIZE 0x2000 /* 8 KiB */ /* To pages */ #define TO_PAGES(d) (((d) + PAGE_SIZE - 1) / PAGE_SIZE) @@ -50,14 +51,14 @@ #if defined(a64) || defined(aa64) #define KERNEL_VMA_OFFSET 0xFFFFFFFF80000000 -#define USER_ALLOC_BASE 0xFFFFA00000000000 /* 256 GiB */ -#define USER_ALLOC_END 0xFFFFB00000000000 +#define USER_ALLOC_BASE 0xFFFFA00000000000 /* 256 GiB */ +#define USER_ALLOC_END 0xFFFFB00000000000 #define KERNEL_STACK_BASE 0xFFFFB00000000000 /* 256 GiB */ -#define KERNEL_STACK_END 0xFFFFC00000000000 +#define KERNEL_STACK_END 0xFFFFC00000000000 -#define USER_STACK_END 0xFFFFEFFF00000000 /* 256 MiB */ -#define USER_STACK_BASE 0xFFFFEFFFFFFF0000 +#define USER_STACK_END 0xFFFFEFFF00000000 /* 256 MiB */ +#define USER_STACK_BASE 0xFFFFEFFFFFFF0000 #elif defined(a32) #define KERNEL_VMA_OFFSET 0xC0000000