Eliminate code for gs trick to track per-cpu state. We rely on lapiccpunum()

to find a per-cpu id with which we locate a cpu's cpu struct.
This commit is contained in:
Frans Kaashoek 2017-02-01 18:04:13 -05:00
parent fbb4c09444
commit ed396c068b
8 changed files with 33 additions and 67 deletions

7
vm.c
View file

@ -21,17 +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[lapiccpunum()];
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);
c->cpu = c;
c->proc = 0;
// Map cpu and proc -- these are private per cpu.
c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 4, 0);
lgdt(c->gdt, sizeof(c->gdt));
loadgs(SEG_KCPU << 3);
}
// Return the address of the PTE in page table pgdir