Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86_64 During signal delivery, arrange to have the ...



details:   https://anonhg.NetBSD.org/src/rev/becaea19b5f5
branches:  trunk
changeset: 533230:becaea19b5f5
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Jun 25 01:24:49 2002 +0000

description:
During signal delivery, arrange to have the signal handler invoked
directly, using the trampoline only for the return path.

diffstat:

 sys/arch/x86_64/include/frame.h            |   7 ++-----
 sys/arch/x86_64/include/netbsd32_machdep.h |   6 +++---
 sys/arch/x86_64/x86_64/genassym.cf         |   9 +--------
 sys/arch/x86_64/x86_64/locore.S            |  21 +++++++++------------
 sys/arch/x86_64/x86_64/machdep.c           |  13 +++++++------
 sys/arch/x86_64/x86_64/netbsd32_machdep.c  |   6 +++---
 sys/arch/x86_64/x86_64/netbsd32_sigcode.S  |  13 +++++++------
 7 files changed, 32 insertions(+), 43 deletions(-)

diffs (203 lines):

diff -r a26c764d2a16 -r becaea19b5f5 sys/arch/x86_64/include/frame.h
--- a/sys/arch/x86_64/include/frame.h   Tue Jun 25 01:07:38 2002 +0000
+++ b/sys/arch/x86_64/include/frame.h   Tue Jun 25 01:24:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: frame.h,v 1.3 2002/06/12 19:13:27 fvdl Exp $   */
+/*     $NetBSD: frame.h,v 1.4 2002/06/25 01:24:49 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -167,10 +167,7 @@
  * Signal frame
  */
 struct sigframe {
-       int64_t sf_signum;
-       int64_t sf_code;
-       struct  sigcontext *sf_scp;
-       sig_t   sf_handler;
+       uint64_t sf_ra;
        struct  sigcontext sf_sc;
        struct  fxsave64 sf_fp;
 };
diff -r a26c764d2a16 -r becaea19b5f5 sys/arch/x86_64/include/netbsd32_machdep.h
--- a/sys/arch/x86_64/include/netbsd32_machdep.h        Tue Jun 25 01:07:38 2002 +0000
+++ b/sys/arch/x86_64/include/netbsd32_machdep.h        Tue Jun 25 01:24:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.h,v 1.1 2001/06/19 00:20:11 fvdl Exp $        */
+/*     $NetBSD: netbsd32_machdep.h,v 1.2 2002/06/25 01:24:49 thorpej Exp $     */
 
 #ifndef _MACHINE_NETBSD32_H_
 #define _MACHINE_NETBSD32_H_
@@ -65,10 +65,10 @@
 #define sc_ps sc_eflags
 
 struct netbsd32_sigframe {
+       uint32_t sf_ra;
        int     sf_signum;
        int     sf_code;
-       u_int32_t sf_scp;               /* struct  sigcontext *sf_scp */
-       u_int32_t sf_handler;           /* sig_t sf_handler; */
+       uint32_t sf_scp;
        struct  netbsd32_sigcontext sf_sc;
 };
 
diff -r a26c764d2a16 -r becaea19b5f5 sys/arch/x86_64/x86_64/genassym.cf
--- a/sys/arch/x86_64/x86_64/genassym.cf        Tue Jun 25 01:07:38 2002 +0000
+++ b/sys/arch/x86_64/x86_64/genassym.cf        Tue Jun 25 01:24:49 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.5 2002/06/03 18:23:17 fvdl Exp $
+#      $NetBSD: genassym.cf,v 1.6 2002/06/25 01:24:50 thorpej Exp $
 
 #
 # Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -163,11 +163,6 @@
 
 define FRAMESIZE               sizeof(struct trapframe)
 
-define SIGF_HANDLER            offsetof(struct sigframe, sf_handler)
-define SIGF_SC                 offsetof(struct sigframe, sf_sc)
-define SIGF_SIGNUM             offsetof(struct sigframe, sf_signum)
-define SIGF_CODE               offsetof(struct sigframe, sf_code)
-define SIGF_SCP                offsetof(struct sigframe, sf_scp)
 define SC_FS                   offsetof(struct sigcontext, sc_fs)
 define SC_GS                   offsetof(struct sigcontext, sc_gs)
 define SC_RFLAGS               offsetof(struct sigcontext, sc_rflags)
@@ -180,8 +175,6 @@
 define IH_NEXT                 offsetof(struct intrhand, ih_next)
 
 ifdef COMPAT_NETBSD32
-define SIGF_HANDLER32          offsetof(struct netbsd32_sigframe, sf_handler)
-define SIGF_SC32               offsetof(struct netbsd32_sigframe, sf_sc)
 define SC_FS32                 offsetof(struct netbsd32_sigcontext, sc_fs)
 define SC_GS32                 offsetof(struct netbsd32_sigcontext, sc_gs)
 endif
diff -r a26c764d2a16 -r becaea19b5f5 sys/arch/x86_64/x86_64/locore.S
--- a/sys/arch/x86_64/x86_64/locore.S   Tue Jun 25 01:07:38 2002 +0000
+++ b/sys/arch/x86_64/x86_64/locore.S   Tue Jun 25 01:24:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.6 2002/06/12 19:13:27 fvdl Exp $  */
+/*     $NetBSD: locore.S,v 1.7 2002/06/25 01:24:50 thorpej Exp $       */
 
 /*
  * Copyright-o-rama!
@@ -660,21 +660,18 @@
 
 /*
  * Signal trampoline; copied to top of user stack.
- * XXXfvdl might as well do away with the frame here.
  */
 NENTRY(sigcode)
-       movq    SIGF_SIGNUM(%rsp),%rdi  # handler(sig, code, scp)
-       movq    SIGF_CODE(%rsp),%rsi
-       movq    SIGF_SCP(%rsp),%rdx
-       call    *SIGF_HANDLER(%rsp)
-       leaq    SIGF_SC(%rsp),%rax      # scp (the call may have clobbered the
-                                       # copy at SIGF_SCP(%esp))
-       movl    SC_FS(%rax),%ecx        # XXXfvdl these are wrong
-       movl    SC_GS(%rax),%edx
+       /*
+        * Handler has returned here as if we called it.  The sigcontext
+        * is now the first thing on the stack.
+        */
+       movl    SC_FS(%rsp),%ecx        /* XXXfvdl these are wrong */
+       movl    SC_GS(%rsp),%edx
        movl    %ecx,%fs
        movl    %edx,%gs
-       movq    %rax,%rdi
-       pushq   %rax
+       movq    %rsp,%rdi
+       pushq   %rdi                    /* fake return address */
        movq    $SYS___sigreturn14,%rax
        syscall
        movq    $SYS_exit,%rax
diff -r a26c764d2a16 -r becaea19b5f5 sys/arch/x86_64/x86_64/machdep.c
--- a/sys/arch/x86_64/x86_64/machdep.c  Tue Jun 25 01:07:38 2002 +0000
+++ b/sys/arch/x86_64/x86_64/machdep.c  Tue Jun 25 01:24:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.11 2002/06/18 08:35:14 fvdl Exp $        */
+/*     $NetBSD: machdep.c,v 1.12 2002/06/25 01:24:50 thorpej Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -516,10 +516,7 @@
        }
 
        /* Build stack frame for signal trampoline. */
-       frame.sf_signum = sig;
-       frame.sf_code = code;
-       frame.sf_scp = &fp->sf_sc;
-       frame.sf_handler = catcher;
+       frame.sf_ra = (uint64_t) p->p_sigctx.ps_sigcode;
 
        /* Save register context. */
        __asm("movl %%gs,%0" : "=r" (frame.sf_sc.sc_gs));
@@ -575,7 +572,11 @@
        tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
        tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
 #endif
-       tf->tf_rip = (u_int64_t)p->p_sigctx.ps_sigcode;
+       tf->tf_rdi = sig;
+       tf->tf_rsi = code;
+       tf->tf_rdx = (int64_t) &fp->sf_sc;
+
+       tf->tf_rip = (u_int64_t)catcher;
        tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
        tf->tf_rflags &= ~(PSL_T|PSL_VM|PSL_AC);
        tf->tf_rsp = (u_int64_t)fp;
diff -r a26c764d2a16 -r becaea19b5f5 sys/arch/x86_64/x86_64/netbsd32_machdep.c
--- a/sys/arch/x86_64/x86_64/netbsd32_machdep.c Tue Jun 25 01:07:38 2002 +0000
+++ b/sys/arch/x86_64/x86_64/netbsd32_machdep.c Tue Jun 25 01:24:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_machdep.c,v 1.7 2002/06/14 18:28:20 eeh Exp $ */
+/*     $NetBSD: netbsd32_machdep.c,v 1.8 2002/06/25 01:24:50 thorpej Exp $     */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -152,10 +152,10 @@
        fp--;
 
        /* Build stack frame for signal trampoline. */
+       frame.sf_ra = (uint32_t)(u_long)p->p_sigctx.ps_sigcode;
        frame.sf_signum = sig;
        frame.sf_code = code;
        frame.sf_scp = (u_int32_t)(u_long)&fp->sf_sc;
-       frame.sf_handler = (u_int32_t)(u_long)catcher;
 
        /*
         * XXXfvdl these need to be saved and restored for USER_LDT.
@@ -216,7 +216,7 @@
        tf->tf_es = GSEL(GUDATA32_SEL, SEL_UPL);
        tf->tf_ds = GSEL(GUDATA32_SEL, SEL_UPL);
 #endif
-       tf->tf_rip = (u_int64_t)p->p_sigctx.ps_sigcode;
+       tf->tf_rip = (u_int64_t)catcher;
        tf->tf_cs = GSEL(GUCODE32_SEL, SEL_UPL);
        tf->tf_rflags &= ~(PSL_T|PSL_VM|PSL_AC);
        tf->tf_rsp = (u_int64_t)fp;
diff -r a26c764d2a16 -r becaea19b5f5 sys/arch/x86_64/x86_64/netbsd32_sigcode.S
--- a/sys/arch/x86_64/x86_64/netbsd32_sigcode.S Tue Jun 25 01:07:38 2002 +0000
+++ b/sys/arch/x86_64/x86_64/netbsd32_sigcode.S Tue Jun 25 01:24:49 2002 +0000
@@ -11,16 +11,17 @@
 NENTRY(netbsd32_sigcode)
 
        .code32
-
-       call    *SIGF_HANDLER32(%esp)
-       leal    SIGF_SC32(%esp),%eax    # scp (the call may have clobbered the
-                                       # copy at SIGF_SCP(%esp))
+       /*
+        * Handler has returned here as if we called it.  The sigcontext
+        * is on the stack after the 3 args "we" pushed.
+        */
+       leal    12(%esp),%eax           # get pointer to sigcontext
        movl    SC_FS32(%eax),%ecx
        movl    SC_GS32(%eax),%edx
        movl    %ecx,%fs
        movl    %edx,%gs
-       pushl   %eax
-       pushl   %eax                    # junk to fake return address
+       movl    %eax,4(%esp)            # put it in the argument slot
+                                       # fake return address already there
        movl    $SYS___sigreturn14,%eax
        int     $0x80                   # enter kernel with args on stack
        movl    $SYS_exit,%eax



Home | Main Index | Thread Index | Old Index