summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2018-10-09 20:22:48 -0400
committerFrans Kaashoek <[email protected]>2018-10-09 20:22:48 -0400
commita7ca32e3a3ec2d3c1947a06fbcde0f779b0b1fec (patch)
tree9f984054071e2724e5f1a96e0dd73a50c7b29db1 /vm.c
parent821ee3fc99b6363d7799d4f5cfa629e36b554dbf (diff)
downloadxv6-labs-a7ca32e3a3ec2d3c1947a06fbcde0f779b0b1fec.tar.gz
xv6-labs-a7ca32e3a3ec2d3c1947a06fbcde0f779b0b1fec.tar.bz2
xv6-labs-a7ca32e3a3ec2d3c1947a06fbcde0f779b0b1fec.zip
Change mycpu() to use %gs.
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/vm.c b/vm.c
index ebb6749..c0276a1 100644
--- a/vm.c
+++ b/vm.c
@@ -39,7 +39,8 @@ seginit(void)
struct cpu *c;
struct desctr dtr;
- c = mycpu();
+ c = getmycpu();
+
memmove(c->gdt, bootgdt, sizeof bootgdt);
dtr.limit = sizeof(c->gdt)-1;
dtr.base = (uint64) c->gdt;
@@ -54,10 +55,12 @@ seginit(void)
writemsr(MSR_LSTAR, (uint64)&sysentry);
writemsr(MSR_SFMASK, FL_TF | FL_IF);
- // Initialize cpu-local storage.
+ // Initialize cpu-local storage so that each core can easily
+ // find its struct cpu using %gs.
writegs(SEG_KDATA);
writemsr(MSR_GS_BASE, (uint64)c);
writemsr(MSR_GS_KERNBASE, (uint64)c);
+ c->cpu = c;
}
// Return the address of the PTE in page table pgdir