summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vm.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/vm.c b/vm.c
index 764512c..9db8b67 100644
--- a/vm.c
+++ b/vm.c
@@ -163,17 +163,22 @@ switchkvm(void)
void
switchuvm(struct proc *p)
{
+ if(p == 0)
+ panic("switchuvm: no process");
+ if(p->kstack == 0)
+ panic("switchuvm: no kstack");
+ if(p->pgdir == 0)
+ panic("switchuvm: no pgdir");
+
pushcli();
cpu->gdt[SEG_TSS] = SEG16(STS_T32A, &cpu->ts, sizeof(cpu->ts)-1, 0);
cpu->gdt[SEG_TSS].s = 0;
cpu->ts.ss0 = SEG_KDATA << 3;
- cpu->ts.esp0 = (uint)proc->kstack + KSTACKSIZE;
+ cpu->ts.esp0 = (uint)p->kstack + KSTACKSIZE;
// setting IOPL=0 in eflags *and* iomb beyond the tss segment limit
// forbids I/O instructions (e.g., inb and outb) from user space
cpu->ts.iomb = (ushort) 0xFFFF;
ltr(SEG_TSS << 3);
- if(p->pgdir == 0)
- panic("switchuvm: no pgdir");
lcr3(V2P(p->pgdir)); // switch to process's address space
popcli();
}