ref: f3594897909571c9bdea99f9293c71def3850916
parent: b911002c4c01d15df5669ddaacd4009ea2b75de3
author: cinap_lenrek <cinap_lenrek@localhost>
date: Tue Jul 12 16:24:15 EDT 2011
trap: cleanup gpf fixup code
--- a/sys/src/9/pc/trap.c
+++ b/sys/src/9/pc/trap.c
@@ -446,22 +446,20 @@
/*
* 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;
}
}
--
⑨