Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amd64/amd64 Use %rax instead of %r15 in the non-SVS...



details:   https://anonhg.NetBSD.org/src/rev/464865f657f2
branches:  trunk
changeset: 830054:464865f657f2
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Feb 24 17:12:10 2018 +0000

description:
Use %rax instead of %r15 in the non-SVS case, to reduce the diff against
SVS. In SVS we use %rax instead of %r15 because the following instructions
cannot be encoded:

        movq    %r15,SVS_UTLS+UTLS_SCRATCH
        movq    SVS_UTLS+UTLS_RSP0,%r15

diffstat:

 sys/arch/amd64/amd64/locore.S |  45 ++++++++++++++++++------------------------
 1 files changed, 19 insertions(+), 26 deletions(-)

diffs (75 lines):

diff -r 37849f00df11 -r 464865f657f2 sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Sat Feb 24 14:06:27 2018 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Sat Feb 24 17:12:10 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.155 2018/02/22 14:57:11 maxv Exp $        */
+/*     $NetBSD: locore.S,v 1.156 2018/02/24 17:12:10 maxv Exp $        */
 
 /*
  * Copyright-o-rama!
@@ -1358,6 +1358,7 @@
  * Entry points of the 'syscall' instruction, 64bit and 32bit mode.
  */
 
+#define SP(x)  (x)-(TF_SS+8)(%rax)
 
 .macro SYSCALL_ENTRY   name,is_svs
 IDTVEC(\name)
@@ -1376,40 +1377,32 @@
         */
        swapgs
 
-#define SP(x,reg)      (x)-(TF_SS+8)(reg)
-
+       /* Get the LWP's kernel stack pointer in %rax */
        .if     \is_svs
                movq    %rax,SVS_UTLS+UTLS_SCRATCH
                movq    SVS_UTLS+UTLS_RSP0,%rax
+       .else
+               movq    %rax,CPUVAR(SCRATCH)
+               movq    CPUVAR(CURLWP),%rax
+               movq    L_PCB(%rax),%rax
+               movq    PCB_RSP0(%rax),%rax
+       .endif
 
-               /* Make stack look like an 'int nn' frame */
-               movq    $(LSEL(LUDATA_SEL, SEL_UPL)),SP(TF_SS,%rax)     /* user %ss */
-               movq    %rsp,SP(TF_RSP,%rax)                            /* user %rsp */
-               movq    %r11,SP(TF_RFLAGS,%rax)                         /* user %rflags */
-               movq    $(LSEL(LUCODE_SEL, SEL_UPL)),SP(TF_CS,%rax)     /* user %cs */
-               movq    %rcx,SP(TF_RIP,%rax)                            /* user %rip */
-               leaq    SP(0,%rax),%rsp                 /* %rsp now valid after frame */
+       /* Make stack look like an 'int nn' frame */
+       movq    $(LSEL(LUDATA_SEL, SEL_UPL)),SP(TF_SS)  /* user %ss */
+       movq    %rsp,SP(TF_RSP)                         /* user %rsp */
+       movq    %r11,SP(TF_RFLAGS)                      /* user %rflags */
+       movq    $(LSEL(LUCODE_SEL, SEL_UPL)),SP(TF_CS)  /* user %cs */
+       movq    %rcx,SP(TF_RIP)                         /* user %rip */
+       leaq    SP(0),%rsp              /* %rsp now valid after frame */
 
+       /* Restore %rax */
+       .if     \is_svs
                movq    SVS_UTLS+UTLS_SCRATCH,%rax
        .else
-               movq    %r15,CPUVAR(SCRATCH)
-               movq    CPUVAR(CURLWP),%r15
-               movq    L_PCB(%r15),%r15
-               movq    PCB_RSP0(%r15),%r15     /* LWP's kernel stack pointer */
-
-               /* Make stack look like an 'int nn' frame */
-               movq    $(LSEL(LUDATA_SEL, SEL_UPL)),SP(TF_SS,%r15)     /* user %ss */
-               movq    %rsp,SP(TF_RSP,%r15)                            /* user %rsp */
-               movq    %r11,SP(TF_RFLAGS,%r15)                         /* user %rflags */
-               movq    $(LSEL(LUCODE_SEL, SEL_UPL)),SP(TF_CS,%r15)     /* user %cs */
-               movq    %rcx,SP(TF_RIP,%r15)                            /* user %rip */
-               leaq    SP(0,%r15),%rsp                 /* %rsp now valid after frame */
-
-               movq    CPUVAR(SCRATCH),%r15
+               movq    CPUVAR(SCRATCH),%rax
        .endif
 
-#undef SP
-
        movq    $2,TF_ERR(%rsp)         /* syscall instruction size */
        movq    $T_ASTFLT,TF_TRAPNO(%rsp)
 #else



Home | Main Index | Thread Index | Old Index