Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386 During native signal delivery (and iBCS2, sinc...



details:   https://anonhg.NetBSD.org/src/rev/2420cc61d547
branches:  trunk
changeset: 533182:2420cc61d547
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Jun 23 22:18:49 2002 +0000

description:
During native signal delivery (and iBCS2, since it uses the native
sigcode), arrange to have the signal handler invoked directly, using
the trampoline only for the return path, saving a call insn.  Play
some other stack trickery in the trampoline to turn 2 pushl's into
one movl.

diffstat:

 sys/arch/i386/i386/genassym.cf     |   5 +----
 sys/arch/i386/i386/ibcs2_machdep.c |  11 ++++++-----
 sys/arch/i386/i386/locore.s        |  14 ++++++++------
 sys/arch/i386/i386/machdep.c       |  11 ++++++-----
 sys/arch/i386/include/frame.h      |  12 ++++++------
 5 files changed, 27 insertions(+), 26 deletions(-)

diffs (167 lines):

diff -r 4284116818c5 -r 2420cc61d547 sys/arch/i386/i386/genassym.cf
--- a/sys/arch/i386/i386/genassym.cf    Sun Jun 23 21:55:12 2002 +0000
+++ b/sys/arch/i386/i386/genassym.cf    Sun Jun 23 22:18:49 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.29 2002/05/11 09:39:26 jdolecek Exp $
+#      $NetBSD: genassym.cf,v 1.30 2002/06/23 22:18:49 thorpej Exp $
 
 #
 # Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -180,9 +180,6 @@
 
 define FRAMESIZE               sizeof(struct trapframe)
 
-define SIGF_HANDLER            offsetof(struct sigframe, sf_handler)
-define SIGF_SC                 offsetof(struct sigframe, sf_sc)
-
 ifdef COMPAT_SVR4
 define SVR4_SIGF_HANDLER       offsetof(struct svr4_sigframe, sf_handler)
 define SVR4_SIGF_UC            offsetof(struct svr4_sigframe, sf_uc)
diff -r 4284116818c5 -r 2420cc61d547 sys/arch/i386/i386/ibcs2_machdep.c
--- a/sys/arch/i386/i386/ibcs2_machdep.c        Sun Jun 23 21:55:12 2002 +0000
+++ b/sys/arch/i386/i386/ibcs2_machdep.c        Sun Jun 23 22:18:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ibcs2_machdep.c,v 1.18 2002/03/31 22:21:02 christos Exp $      */
+/*     $NetBSD: ibcs2_machdep.c,v 1.19 2002/06/23 22:18:49 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1997, 2000 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ibcs2_machdep.c,v 1.18 2002/03/31 22:21:02 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibcs2_machdep.c,v 1.19 2002/06/23 22:18:49 thorpej Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vm86.h"
@@ -125,10 +125,10 @@
        fp--;
 
        /* Build stack frame for signal trampoline. */
+       frame.sf_ra = (int)p->p_sigctx.ps_sigcode;
        frame.sf_signum = native_to_ibcs2_signo[sig];
        frame.sf_code = code;
        frame.sf_scp = &fp->sf_sc;
-       frame.sf_handler = catcher;
 
        /* Save register context. */
 #ifdef VM86
@@ -178,13 +178,14 @@
        }
 
        /*
-        * Build context to run handler in.
+        * Build context to run handler in.  We invoke the handler
+        * directly, only returning via the trampoline.
         */
        tf->tf_gs = GSEL(GUDATA_SEL, SEL_UPL);
        tf->tf_fs = GSEL(GUDATA_SEL, SEL_UPL);  
        tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
        tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
-       tf->tf_eip = (int)p->p_sigctx.ps_sigcode;
+       tf->tf_eip = (int)catcher;
        tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
        tf->tf_eflags &= ~(PSL_T|PSL_VM|PSL_AC);
        tf->tf_esp = (int)fp;
diff -r 4284116818c5 -r 2420cc61d547 sys/arch/i386/i386/locore.s
--- a/sys/arch/i386/i386/locore.s       Sun Jun 23 21:55:12 2002 +0000
+++ b/sys/arch/i386/i386/locore.s       Sun Jun 23 22:18:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.255 2002/05/31 18:07:31 thorpej Exp $     */
+/*     $NetBSD: locore.s,v 1.256 2002/06/23 22:18:50 thorpej Exp $     */
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -726,11 +726,13 @@
  */
 /* LINTSTUB: Var: char sigcode[1], esigcode[1]; */
 NENTRY(sigcode)
-       call    *SIGF_HANDLER(%esp)
-       leal    SIGF_SC(%esp),%eax      # scp (the call may have clobbered the
-                                       # copy at SIGF_SCP(%esp))
-       pushl   %eax
-       pushl   %eax                    # junk to fake return address
+       /*
+        * 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    %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
diff -r 4284116818c5 -r 2420cc61d547 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Sun Jun 23 21:55:12 2002 +0000
+++ b/sys/arch/i386/i386/machdep.c      Sun Jun 23 22:18:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.474 2002/06/18 09:56:33 tron Exp $       */
+/*     $NetBSD: machdep.c,v 1.475 2002/06/23 22:18:51 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.474 2002/06/18 09:56:33 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.475 2002/06/23 22:18:51 thorpej Exp $");
 
 #include "opt_cputype.h"
 #include "opt_ddb.h"
@@ -1991,10 +1991,10 @@
        fp--;
 
        /* Build stack frame for signal trampoline. */
+       frame.sf_ra = (int)p->p_sigctx.ps_sigcode;
        frame.sf_signum = sig;
        frame.sf_code = code;
        frame.sf_scp = &fp->sf_sc;
-       frame.sf_handler = catcher;
 
        /* Save register context. */
 #ifdef VM86
@@ -2054,13 +2054,14 @@
        }
 
        /*
-        * Build context to run handler in.
+        * Build context to run handler in.  We invoke the handler
+        * directly, only returning via the trampoline.
         */
        tf->tf_gs = GSEL(GUDATA_SEL, SEL_UPL);
        tf->tf_fs = GSEL(GUDATA_SEL, SEL_UPL);
        tf->tf_es = GSEL(GUDATA_SEL, SEL_UPL);
        tf->tf_ds = GSEL(GUDATA_SEL, SEL_UPL);
-       tf->tf_eip = (int)p->p_sigctx.ps_sigcode;
+       tf->tf_eip = (int)catcher;
        tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
        tf->tf_eflags &= ~(PSL_T|PSL_VM|PSL_AC);
        tf->tf_esp = (int)fp;
diff -r 4284116818c5 -r 2420cc61d547 sys/arch/i386/include/frame.h
--- a/sys/arch/i386/include/frame.h     Sun Jun 23 21:55:12 2002 +0000
+++ b/sys/arch/i386/include/frame.h     Sun Jun 23 22:18:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: frame.h,v 1.16 2001/06/17 21:01:38 sommerfeld Exp $    */
+/*     $NetBSD: frame.h,v 1.17 2002/06/23 22:18:54 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -156,11 +156,11 @@
  * Signal frame
  */
 struct sigframe {
-       int     sf_signum;
-       int     sf_code;
-       struct  sigcontext *sf_scp;
-       sig_t   sf_handler;
-       struct  sigcontext sf_sc;
+       int     sf_ra;                  /* return address for handler */
+       int     sf_signum;              /* "signum" argument for handler */
+       int     sf_code;                /* "code" argument for handler */
+       struct  sigcontext *sf_scp;     /* "scp" argument for handler */
+       struct  sigcontext sf_sc;       /* actual saved context */
 };
 
 #endif  /* _I386_FRAME_H_ */



Home | Main Index | Thread Index | Old Index