Fix invalid CR3 loading on execve() when timer ticks
This commit is contained in:
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user