git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: corner case for x87 context restore on execve
[lunaix-os.git]
/
lunaix-os
/
kernel
/
k_init.c
diff --git
a/lunaix-os/kernel/k_init.c
b/lunaix-os/kernel/k_init.c
index 71adb3098cadb369e9fdd7ced62e64c8ea218edf..2dc39e63eb3314a7fa880af5b6b856c5418e246f 100644
(file)
--- a/
lunaix-os/kernel/k_init.c
+++ b/
lunaix-os/kernel/k_init.c
@@
-126,10
+126,6
@@
spawn_proc0()
* 目前的解决方案是2
*/
* 目前的解决方案是2
*/
- proc0->intr_ctx = (isr_param){ .registers = { .ds = KDATA_SEG,
- .es = KDATA_SEG,
- .fs = KDATA_SEG,
- .gs = KDATA_SEG } };
proc0->parent = proc0;
// 方案1:必须在读取eflags之后禁用。否则当进程被调度时,中断依然是关闭的!
proc0->parent = proc0;
// 方案1:必须在读取eflags之后禁用。否则当进程被调度时,中断依然是关闭的!
@@
-141,7
+137,7
@@
spawn_proc0()
proc0->page_table = vmm_dup_vmspace(proc0->pid);
// 直接切换到新的拷贝,进行配置。
proc0->page_table = vmm_dup_vmspace(proc0->pid);
// 直接切换到新的拷贝,进行配置。
- cpu_l
cr3
(proc0->page_table);
+ cpu_l
dvmspace
(proc0->page_table);
// 为内核创建一个专属栈空间。
for (size_t i = 0; i < (KSTACK_SIZE >> PG_SIZE_BITS); i++) {
// 为内核创建一个专属栈空间。
for (size_t i = 0; i < (KSTACK_SIZE >> PG_SIZE_BITS); i++) {
@@
-155,17
+151,19
@@
spawn_proc0()
struct exec_param* execp =
(struct exec_param*)(KSTACK_TOP - sizeof(struct exec_param));
struct exec_param* execp =
(struct exec_param*)(KSTACK_TOP - sizeof(struct exec_param));
+ isr_param* isrp = (isr_param*)((ptr_t)execp - sizeof(isr_param));
*execp = (struct exec_param){ .cs = KCODE_SEG,
.eip = (ptr_t)__proc0,
.ss = KDATA_SEG,
.eflags = cpu_reflags() };
*execp = (struct exec_param){ .cs = KCODE_SEG,
.eip = (ptr_t)__proc0,
.ss = KDATA_SEG,
.eflags = cpu_reflags() };
- proc0->intr_ctx.execp = execp;
+ *isrp = (isr_param){ .registers = { .ds = KDATA_SEG,
+ .es = KDATA_SEG,
+ .fs = KDATA_SEG,
+ .gs = KDATA_SEG },
+ .execp = execp };
- // 加载x87默认配置
- asm volatile("fninit\n"
- "fxsave (%%eax)" ::"a"(proc0->fxstate)
- : "memory");
+ proc0->intr_ctx = isrp;
// 向调度器注册进程。
commit_process(proc0);
// 向调度器注册进程。
commit_process(proc0);