ref: c78c6e349ae55d4964142780f957a9a3488b0789
parent: 20b7a19c58c79568424bf40b826b681af86e6ed5
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Jul 19 22:59:45 EDT 2014
pc64: dont save/restore DS/ES/FS/GS segment registers on syscall or interrupt, they are ignored in long mode. we do not support 32 bit processes and DS, ES, FS and GS segment registers are ignored in long mode, so theres no point in saving and restoring them.
--- a/sys/src/9/pc64/l.s
+++ b/sys/src/9/pc64/l.s
@@ -687,14 +687,6 @@
CLI
SWAPGS
- MOVW $UDSEL, AX
- MOVW AX, DS
- MOVW AX, ES
-
- MOVW $NULLSEL, AX
- MOVW AX, FS
- MOVW AX, GS
-
MOVL $0, RMACH
MOVL $0, RUSER
@@ -719,14 +711,8 @@
PUSHQ R11 /* old flags */
PUSHQ $UESEL /* old code segment */
PUSHQ CX /* old ip */
-
SUBQ $(16+16*8), SP /* unsaved registers */
- MOVW $UDSEL, (15*8+0)(SP)
- MOVW ES, (15*8+2)(SP)
- MOVW FS, (15*8+4)(SP)
- MOVW GS, (15*8+6)(SP)
-
MOVQ RMACH, (14*8)(SP)
MOVQ RUSER, (13*8)(SP)
@@ -746,11 +732,6 @@
CLI
SWAPGS
- MOVW 22(SP), GS
- MOVW 20(SP), FS
- MOVW 18(SP), ES
- MOVW 16(SP), DS
-
MOVQ 8(SP), RMACH
MOVQ 0(SP), RUSER
@@ -785,10 +766,6 @@
MOVQ RUSER, 0(SP)
MOVQ RMACH, 8(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) */
@@ -834,10 +811,7 @@
JEQ _iretnested
SWAPGS
- MOVW 22(SP), GS
- MOVW 20(SP), FS
- MOVW 18(SP), ES
- MOVW 16(SP), DS
+
MOVQ 8(SP), RMACH
MOVQ 0(SP), RUSER
--- a/sys/src/9/pc64/trap.c
+++ b/sys/src/9/pc64/trap.c
@@ -476,21 +476,19 @@
else
iprint("cpu%d: registers for kernel\n", m->machno);
- iprint(" DS %.4uX AX %.16lluX BX %.16lluX CX %.16lluX\n",
- ureg->ds, ureg->ax, ureg->bx, ureg->cx);
- iprint(" ES %.4uX DX %.16lluX SI %.16lluX DI %.16lluX\n",
- ureg->es, ureg->dx, ureg->si, ureg->di);
- iprint(" FS %.4uX BP %.16lluX R8 %.16lluX R9 %.16lluX\n",
- ureg->fs, ureg->bp, ureg->r8, ureg->r9);
- iprint(" GS %.4uX R10 %.16lluX R11 %.16lluX R12 %.16lluX\n",
- ureg->gs, ureg->r10, ureg->r11, ureg->r12);
-
- iprint(" SS %.4lluX R13 %.16lluX R14 %.16lluX R15 %.16lluX\n",
- ureg->ss & 0xffff, ureg->r13, ureg->r14, ureg->r15);
- iprint(" CS %.4lluX PC %.16lluX SP %.16lluX\n",
- ureg->cs & 0xffff, ureg->pc, ureg->sp);
-
- iprint("TYPE %.2lluX ERROR %.4lluX FLAGS %.8lluX\n",
+ iprint(" AX %.16lluX BX %.16lluX CX %.16lluX\n",
+ ureg->ax, ureg->bx, ureg->cx);
+ iprint(" DX %.16lluX SI %.16lluX DI %.16lluX\n",
+ ureg->dx, ureg->si, ureg->di);
+ iprint(" BP %.16lluX R8 %.16lluX R9 %.16lluX\n",
+ ureg->bp, ureg->r8, ureg->r9);
+ iprint(" R10 %.16lluX R11 %.16lluX R12 %.16lluX\n",
+ ureg->r10, ureg->r11, ureg->r12);
+ iprint(" R13 %.16lluX R14 %.16lluX R15 %.16lluX\n",
+ ureg->r13, ureg->r14, ureg->r15);
+ iprint(" CS %.4lluX SS %.4lluX PC %.16lluX SP %.16lluX\n",
+ ureg->cs & 0xffff, ureg->ss & 0xffff, ureg->pc, ureg->sp);
+ iprint("TYPE %.2lluX ERROR %.4lluX FLAGS %.8lluX\n",
ureg->type & 0xff, ureg->error & 0xffff, ureg->flags & 0xffffffff);
/*
@@ -507,7 +505,7 @@
if(ureg->type == 18)
dumpmcregs();
}
- iprint("\n ur %#p up %#p\n", ureg, up);
+ iprint(" ur %#p up %#p\n", ureg, up);
}
@@ -854,7 +852,7 @@
ureg->pc = (uintptr)up->notify;
ureg->bp = (uintptr)up->ureg; /* arg1 passed in RARG */
ureg->cs = UESEL;
- ureg->ss = ureg->ds = ureg->es = UDSEL;
+ ureg->ss = UDSEL;
up->notified = 1;
up->nnote--;
memmove(&up->lastnote, &up->note[0], sizeof(Note));
@@ -952,8 +950,7 @@
ureg->sp = (uintptr)sp;
ureg->pc = entry;
ureg->cs = UESEL;
- ureg->ss = ureg->ds = ureg->es = UDSEL;
- ureg->fs = ureg->gs = NULLSEL;
+ ureg->ss = UDSEL;
ureg->r14 = ureg->r15 = 0; /* extern user registers */
return (uintptr)USTKTOP-sizeof(Tos); /* address of kernel/user shared data */
}
@@ -981,11 +978,7 @@
flags = ureg->flags;
memmove(pureg, uva, n);
ureg->cs = UESEL;
- ureg->ss = ureg->ds = ureg->es = UDSEL;
- if(ureg->fs != UDSEL)
- ureg->fs = NULLSEL;
- if(ureg->gs != UDSEL)
- ureg->gs = NULLSEL;
+ ureg->ss = UDSEL;
ureg->flags = (ureg->flags & 0x00ff) | (flags & 0xff00);
ureg->pc &= UADDRMASK;
}