diff options
author | Robert Morris <[email protected]> | 2017-08-08 13:27:06 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2017-08-08 13:27:06 -0400 |
commit | 14270288b7e5327832cdf6a8d9da52ef58fce652 (patch) | |
tree | b604cb49fb049a14966418eda4589cd1271f8e53 /vm.c | |
parent | aba8423c4a5ae01828040d04f668f07ec544dcd0 (diff) | |
parent | 825ce074b10a0e1f63fd3a1fe245220d04054e0a (diff) | |
download | xv6-labs-14270288b7e5327832cdf6a8d9da52ef58fce652.tar.gz xv6-labs-14270288b7e5327832cdf6a8d9da52ef58fce652.tar.bz2 xv6-labs-14270288b7e5327832cdf6a8d9da52ef58fce652.zip |
Merge branch 'master' of g.csail.mit.edu:xv6-dev
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 21 |
1 files changed, 6 insertions, 15 deletions
@@ -21,21 +21,12 @@ seginit(void) // Cannot share a CODE descriptor for both kernel and user // because it would have to have DPL_USR, but the CPU forbids // an interrupt from CPL=0 to DPL=3. - c = &cpus[cpunum()]; + c = &cpus[cpuid()]; c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); - - // Map cpu and proc -- these are private per cpu. - c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0); - lgdt(c->gdt, sizeof(c->gdt)); - loadgs(SEG_KCPU << 3); - - // Initialize cpu-local storage. - cpu = c; - proc = 0; } // Return the address of the PTE in page table pgdir @@ -173,13 +164,13 @@ switchuvm(struct proc *p) 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)p->kstack + KSTACKSIZE; + mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, sizeof(mycpu()->ts)-1, 0); + mycpu()->gdt[SEG_TSS].s = 0; + mycpu()->ts.ss0 = SEG_KDATA << 3; + mycpu()->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; + mycpu()->ts.iomb = (ushort) 0xFFFF; ltr(SEG_TSS << 3); lcr3(V2P(p->pgdir)); // switch to process's address space popcli(); |