summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2010-08-05 21:16:55 -0400
committerRobert Morris <[email protected]>2010-08-05 21:16:55 -0400
commit1afc9d3fcaa7c5992659bb8b69f639b746dda2bc (patch)
treee60a41707282ba0ef2c1e00b9cba97bb71339284 /vm.c
parentc99599784e950169d85bf1e4446e7dbfb1a40f59 (diff)
downloadxv6-labs-1afc9d3fcaa7c5992659bb8b69f639b746dda2bc.tar.gz
xv6-labs-1afc9d3fcaa7c5992659bb8b69f639b746dda2bc.tar.bz2
xv6-labs-1afc9d3fcaa7c5992659bb8b69f639b746dda2bc.zip
add some comments
find out the hard way why user and kernel must have separate segment descriptors
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/vm.c b/vm.c
index c94e9a3..9ea5e92 100644
--- a/vm.c
+++ b/vm.c
@@ -93,12 +93,15 @@ ksegment(void)
{
struct cpu *c;
- // Map once virtual addresses to linear addresses using identity map
+ // Map virtual addresses to linear addresses using identity map.
+ // 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->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, 0x0, 0xffffffff, DPL_USER);
- c->gdt[SEG_UDATA] = SEG(STA_W, 0x0, 0xffffffff, DPL_USER);
+ 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 curproc
c->gdt[SEG_KCPU] = SEG(STA_W, &c->cpu, 8, 0);