process_create_user

This commit is contained in:
2026-04-03 18:45:12 +02:00
parent 1fe5eb2d38
commit 437bd0e751
6 changed files with 60 additions and 35 deletions
+6 -4
View File
@@ -246,17 +246,19 @@ uintptr_t vmm_alloc_user_stack(uint64_t* pml4)
for (size_t i=stack_top; i>stack_top-stack_size; i-=PAGE_SIZE) {
vmm_map(pml4, i, PTE_PRESENT | PTE_WRITABLE | PTE_USER);
}
return stack_top;
}
uintptr_t vmm_alloc_user_code(uint64_t* pml4, void* code_addr, uint64_t code_size)
{
uintptr_t code_start = USER_CODE_START;
for (size_t i=code_start; i<code_start+code_size; i+=PAGE_SIZE) {
// Round code_size up to next page boundary
uint64_t code_size_aligned = (code_size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
for (uint64_t i=code_start; i<code_start+code_size_aligned; i+=PAGE_SIZE) {
vmm_map(pml4, i, PTE_PRESENT | PTE_WRITABLE | PTE_USER);
}
}
return code_start;
}