EXECHACK fix

上级 128f7acc
...@@ -80,7 +80,8 @@ struct proc : public rcu_freed, public sched_link { ...@@ -80,7 +80,8 @@ struct proc : public rcu_freed, public sched_link {
struct spinlock futex_lock; struct spinlock futex_lock;
u64 user_fs_; u64 user_fs_;
u64 unmap_tlbreq_; u64 unmap_tlbreq_;
int exec_cpuid_; int data_cpuid; // Where vmap, kstack, and uwq is likely
// to be cached
int run_cpuid_; int run_cpuid_;
int in_exec_; int in_exec_;
int uaccess_; int uaccess_;
......
...@@ -221,7 +221,8 @@ exec(const char *path, char **argv, void *ascopev) ...@@ -221,7 +221,8 @@ exec(const char *path, char **argv, void *ascopev)
w->rip = (void*) exec_cleanup; w->rip = (void*) exec_cleanup;
w->arg0 = oldvmap; w->arg0 = oldvmap;
w->arg1 = olduwq; w->arg1 = olduwq;
assert(wqcrit_push(w, myproc()->exec_cpuid_) >= 0); assert(wqcrit_push(w, myproc()->data_cpuid) >= 0);
myproc()->data_cpuid = myid();
gc_end_epoch(); gc_end_epoch();
return 0; return 0;
......
...@@ -41,8 +41,8 @@ proc::proc(int npid) : ...@@ -41,8 +41,8 @@ proc::proc(int npid) :
pid(npid), parent(0), tf(0), context(0), killed(0), pid(npid), parent(0), tf(0), context(0), killed(0),
ftable(0), cwd(0), tsc(0), curcycles(0), cpuid(0), epoch(0), ftable(0), cwd(0), tsc(0), curcycles(0), cpuid(0), epoch(0),
cpu_pin(0), oncv(0), cv_wakeup(0), cpu_pin(0), oncv(0), cv_wakeup(0),
user_fs_(0), unmap_tlbreq_(0), in_exec_(0), uaccess_(0), user_fs_(0), unmap_tlbreq_(0), data_cpuid(-1), in_exec_(0),
upath(0), uargv(userptr<const char>(nullptr)), uaccess_(0), upath(0), uargv(userptr<const char>(nullptr)),
exception_inuse(0), magic(PROC_MAGIC), state_(EMBRYO) exception_inuse(0), magic(PROC_MAGIC), state_(EMBRYO)
{ {
snprintf(lockname, sizeof(lockname), "cv:proc:%d", pid); snprintf(lockname, sizeof(lockname), "cv:proc:%d", pid);
...@@ -269,7 +269,7 @@ execswitch(proc* p) ...@@ -269,7 +269,7 @@ execswitch(proc* p)
if (w != nullptr) { if (w != nullptr) {
w->rip = (void*) kstackfree; w->rip = (void*) kstackfree;
w->arg0 = p->kstack; w->arg0 = p->kstack;
if (wqcrit_push(w, myproc()->exec_cpuid_) < 0) { if (wqcrit_push(w, p->data_cpuid) < 0) {
ksfree(slab_stack, p->kstack); ksfree(slab_stack, p->kstack);
delete w; delete w;
} }
...@@ -449,7 +449,7 @@ fork(int flags) ...@@ -449,7 +449,7 @@ fork(int flags)
np->parent = myproc(); np->parent = myproc();
*np->tf = *myproc()->tf; *np->tf = *myproc()->tf;
np->cpu_pin = myproc()->cpu_pin; np->cpu_pin = myproc()->cpu_pin;
np->exec_cpuid_ = myproc()->exec_cpuid_; np->data_cpuid = myproc()->data_cpuid;
np->run_cpuid_ = myproc()->run_cpuid_; np->run_cpuid_ = myproc()->run_cpuid_;
// Clear %eax so that fork returns 0 in the child. // Clear %eax so that fork returns 0 in the child.
......
...@@ -471,9 +471,8 @@ clean: ...@@ -471,9 +471,8 @@ clean:
int int
sys_exec(const char *upath, userptr<userptr<const char> > uargv) sys_exec(const char *upath, userptr<userptr<const char> > uargv)
{ {
myproc()->exec_cpuid_ = myid(); myproc()->data_cpuid = myid();
#if EXECSWITCH #if EXECSWITCH
myproc()->exec_cpuid_ = mycpuid();
myproc()->uargv = uargv; myproc()->uargv = uargv;
barrier(); barrier();
// upath serves as a flag to the scheduler // upath serves as a flag to the scheduler
......
...@@ -43,6 +43,7 @@ inituser(void) ...@@ -43,6 +43,7 @@ inituser(void)
p->tf->rflags = FL_IF; p->tf->rflags = FL_IF;
p->tf->rsp = PGSIZE; p->tf->rsp = PGSIZE;
p->tf->rip = INIT_START; // beginning of initcode.S p->tf->rip = INIT_START; // beginning of initcode.S
p->data_cpuid = myid();
safestrcpy(p->name, "initcode", sizeof(p->name)); safestrcpy(p->name, "initcode", sizeof(p->name));
p->cwd = 0; // forkret will fix in the process's context p->cwd = 0; // forkret will fix in the process's context
......
...@@ -46,6 +46,8 @@ int ...@@ -46,6 +46,8 @@ int
wqcrit_push(work *w, int c) wqcrit_push(work *w, int c)
{ {
assert(wqcrit_); assert(wqcrit_);
if (c >= NCPU || c < 0)
panic("Weird CPU %d", c);
return wqcrit_->push(w, c); return wqcrit_->push(w, c);
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论