From 0ee4ab17fa7b58c8024e23b7e6f570fcd84ecfb8 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 24 Jul 2020 10:26:32 +0300 Subject: [PATCH] Fix page directory not getting switched on switch to user process --- sys/execve.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/execve.c b/sys/execve.c index 80ddfcc..2b51825 100644 --- a/sys/execve.c +++ b/sys/execve.c @@ -234,6 +234,8 @@ int sys_execve(const char *path, const char **argv, const char **envp) { _assert(thr->data.fxsave); thr->data.cr3 = MM_PHYS(proc->space); + // Switch CR3 to the newly allocated space! + asm volatile ("movq %0, %%rax; movq %%rax, %%cr3"::"a"(thr->data.cr3)); asm volatile ("sti"); } else { mm_space_release(proc);