Fix invalid CR3 loading on execve() when timer ticks

This commit is contained in:
Mark
2020-06-12 11:12:01 +03:00
parent 765223b361
commit 6ebf440b60
2 changed files with 8 additions and 4 deletions
+2 -1
View File
@@ -129,8 +129,9 @@ void amd64_timer_init(void) {
// LAPIC Timer is only used to trigger task switches
LAPIC(LAPIC_REG_TMRDIV) = 0x3;
LAPIC(LAPIC_REG_LVTT) = 32 | (1 << 17);
LAPIC(LAPIC_REG_TMRINITCNT) = 1562500;
LAPIC(LAPIC_REG_TMRINITCNT) = 150000;
LAPIC(LAPIC_REG_TMRCURRCNT) = 0;
get_cpu()->ticks = 0;
asm volatile ("cli");
}
+6 -3
View File
@@ -562,14 +562,17 @@ int sys_execve(const char *path, const char **argv, const char **envp) {
thr->sigq = 0;
thr->space = amd64_mm_pool_alloc();
_assert(thr->space);
thr->data.cr3 = MM_PHYS(thr->space);
thr->flags = 0;
_assert(thr->space);
mm_space_clone(thr->space, mm_kernel, MM_CLONE_FLG_KERNEL);
asm volatile ("cli");
thr->data.fxsave = kmalloc(FXSAVE_REGION);
_assert(thr->data.fxsave);
mm_space_clone(thr->space, mm_kernel, MM_CLONE_FLG_KERNEL);
thr->data.cr3 = MM_PHYS(thr->space);
asm volatile ("sti");
} else {
mm_space_release(thr);
}