diff options
author | cinap_lenrek <cinap_lenrek@localhost> | 2011-07-12 20:24:15 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@localhost> | 2011-07-12 20:24:15 +0200 |
commit | ca4adfc25048e99a0063d8fd06f4b2bb2ded4c8f (patch) | |
tree | 2ceb9098464fac3fac1f2327a25dcd4c70001e90 /sys/src/9/pc/trap.c | |
parent | 2d288b400241451febf419d3238140084ca7fd1d (diff) |
trap: cleanup gpf fixup code
Diffstat (limited to 'sys/src/9/pc/trap.c')
-rw-r--r-- | sys/src/9/pc/trap.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/sys/src/9/pc/trap.c b/sys/src/9/pc/trap.c index 08033a9ee..661aa06e8 100644 --- a/sys/src/9/pc/trap.c +++ b/sys/src/9/pc/trap.c @@ -446,22 +446,20 @@ trap(Ureg* ureg) /* * we test for the instructions used by forkret() - * to load the segments. this needs to be changed - * if forkret changes! + * to load the segments and replace the selectors + * on the (kernel) stack with null selectors. */ - - /* POP */ - if((pc[0] == 0x0f && (pc[1] == 0xa9 /*GS*/ || - pc[1] == 0xa1 /*FS*/)) || (pc[0] == 0x07) /*ES*/ || - (pc[0] == 0x1f) /*DS*/){ + switch(pc[0]){ + case 0x0f: /* POP GS/FS */ + if(pc[1] != 0xa9 && pc[1] != 0xa1) + break; + case 0x07: /* POP ES */ + case 0x1f: /* POP DS */ sp[0] = NULLSEL; return; - } - - /* IRET */ - if(pc[0] == 0xcf){ - sp[1] = UESEL; /*CS*/ - sp[4] = UDSEL; /*SS*/ + case 0xcf: /* IRET */ + sp[1] = UESEL; /* CS */ + sp[4] = UDSEL; /* SS */ return; } } |