# HG changeset patch # User Gorka Guardiola # Date 1331806938 -3600 # Node ID 9323f8fa6d56c87847052d79e05a0e44a329109b # Parent 0de9c3c7dd45addaf9daabe59aa1d1ea9f4e1a05 selectors: not saving and restoring the selectors breaks programs. R=nixiedev, nemo CC=nix-dev http://codereview.appspot.com/5821046 diff -r 0de9c3c7dd45 -r 9323f8fa6d56 sys/src/nix/k10/l64idt.s --- a/sys/src/nix/k10/l64idt.s Thu Mar 15 09:58:11 2012 +0100 +++ b/sys/src/nix/k10/l64idt.s Thu Mar 15 11:22:18 2012 +0100 @@ -22,10 +22,10 @@ MOVQ RUSER, 0(SP) MOVQ RMACH, 8(SP) -// MOVW DS, 16(SP) -// MOVW ES, 18(SP) -// MOVW FS, 20(SP) -// MOVW GS, 22(SP) + MOVW DS, 16(SP) + MOVW ES, 18(SP) + MOVW FS, 20(SP) + MOVW GS, 22(SP) SWAPGS BYTE $0x65; MOVQ 0, RMACH /* m-> (MOVQ GS:0x0, R15) */ @@ -71,11 +71,13 @@ JEQ _iretnested SWAPGS - /* per the architecture manual, moving 16 bits to FS can zero it. Bad ... */ -// MOVW 22(SP), GS -// MOVW 20(SP), FS -// MOVW 18(SP), ES -// MOVW 16(SP), DS + /* per the architecture manual, moving 16 bits to FS can zero it. Bad ... + * not restoring it gives back the bad segment selector bug + */ + MOVW 22(SP), GS + MOVW 20(SP), FS + MOVW 18(SP), ES + MOVW 16(SP), DS MOVQ 8(SP), RMACH MOVQ 0(SP), RUSER