Source-Changes-HG archive

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

[src/trunk]: src/sys Fixed the Linux signal trampoline and linux_sys_sigretur...



details:   https://anonhg.NetBSD.org/src/rev/74376faf8672
branches:  trunk
changeset: 517877:74376faf8672
user:      manu <manu%NetBSD.org@localhost>
date:      Tue Nov 20 21:37:50 2001 +0000

description:
Fixed the Linux signal trampoline and linux_sys_sigreturn(). Linux signal
delivery now seems fully functionnal.

diffstat:

 sys/arch/mips/mips/locore.S                    |   8 ++-
 sys/compat/linux/arch/mips/linux_machdep.c     |  44 ++++++++++---------------
 sys/compat/linux/arch/mips/linux_syscall.h     |   4 +-
 sys/compat/linux/arch/mips/linux_syscallargs.h |   4 +-
 sys/compat/linux/arch/mips/linux_syscalls.c    |   4 +-
 sys/compat/linux/arch/mips/linux_sysent.c      |   4 +-
 sys/compat/linux/arch/mips/syscalls.master     |   4 +-
 7 files changed, 32 insertions(+), 40 deletions(-)

diffs (222 lines):

diff -r d62d6047a98e -r 74376faf8672 sys/arch/mips/mips/locore.S
--- a/sys/arch/mips/mips/locore.S       Tue Nov 20 21:21:03 2001 +0000
+++ b/sys/arch/mips/mips/locore.S       Tue Nov 20 21:37:50 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.126 2001/11/14 18:15:22 thorpej Exp $     */
+/*     $NetBSD: locore.S,v 1.127 2001/11/20 21:37:50 manu Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -205,9 +205,11 @@
 #endif
 
 #ifdef COMPAT_LINUX
+#define SYSCALL_SHIFT 4000             # 4000 shift as in linux_syscall.c
 LEAF_NOPROFILE(linux_sigcode)
-       addu    a0, sp, 16              # address of sigcontext
-       li      v0, LINUX_SYS_sigreturn # sigreturn(scp)
+/*     addu    a0, sp, 0               # address of sigframe */
+       move    a0, sp
+       li      v0, LINUX_SYS_sigreturn + SYSCALL_SHIFT # sigreturn(sf)
        syscall
        break   0                       # just in case sigreturn fails
 END(linux_sigcode)
diff -r d62d6047a98e -r 74376faf8672 sys/compat/linux/arch/mips/linux_machdep.c
--- a/sys/compat/linux/arch/mips/linux_machdep.c        Tue Nov 20 21:21:03 2001 +0000
+++ b/sys/compat/linux/arch/mips/linux_machdep.c        Tue Nov 20 21:37:50 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_machdep.c,v 1.7 2001/11/17 22:13:38 manu Exp $ */
+/*     $NetBSD: linux_machdep.c,v 1.8 2001/11/20 21:37:51 manu Exp $ */
 
 /*-
  * Copyright (c) 1995, 2000, 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.7 2001/11/17 22:13:38 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_machdep.c,v 1.8 2001/11/20 21:37:51 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -137,9 +137,6 @@
        printf("linux_sendsig()\n");
 #endif /* DEBUG_LINUX */
        f = (struct frame *)p->p_md.md_regs;
-#ifdef DEBUG_LINUX
-       printf("f = %p\n", f);
-#endif /* DEBUG_LINUX */
 
        /* 
         * Do we need to jump onto the signal stack? 
@@ -165,10 +162,6 @@
                /* cast for _MIPS_BSD_API == _MIPS_BSD_API_LP32_64CLEAN case */
                fp = (struct linux_sigframe *)(u_int32_t)f->f_regs[SP];
 
-#ifdef DEBUG_LINUX
-       printf("fp = %p, sf = %p\n", fp, &sf);
-#endif /* DEBUG_LINUX */
-
        /* 
         * Build stack frame for signal trampoline. 
         */
@@ -182,8 +175,9 @@
        sf.lsf_code[1] = 0x0000000c;    /* syscall                      */
 
        native_to_linux_sigset(mask, &sf.lsf_mask);
-       for (i=0; i<32; i++)
+       for (i=0; i<32; i++) {
                sf.lsf_sc.lsc_regs[i] = f->f_regs[i];
+       }
        sf.lsf_sc.lsc_mdhi = f->f_regs[MULHI];
        sf.lsf_sc.lsc_mdlo = f->f_regs[MULLO];
        sf.lsf_sc.lsc_pc = f->f_regs[PC];
@@ -231,6 +225,10 @@
        if (onstack)
                p->p_sigctx.ps_sigstk.ss_flags |= SS_ONSTACK;
 
+       /* Attempt to flush everything just in case it fixes problems */
+/*     mips_icache_sync_all();
+       mips_dcache_wbinv_all(); */
+
        return;
 }
 
@@ -246,9 +244,8 @@
        register_t *retval;
 {
        struct linux_sys_sigreturn_args /* {
-               syscallarg(struct linux_pt_regs) regs;
+               syscallarg(struct linux_sigframe *) sf;
        } */ *uap = v;
-       struct linux_pt_regs regs, kregs;
        struct linux_sigframe *sf, ksf;
        struct frame *f;
        sigset_t mask;
@@ -263,28 +260,21 @@
         * It is unsafe to keep track of it ourselves, in the event that a
         * program jumps out of a signal handler.
         */
-       regs = SCARG(uap, regs); 
+       sf = SCARG(uap, sf); 
 
-       kregs = regs;
-       /* if ((error = copyin(regs, &kregs, sizeof(kregs))) != 0)
-               return (error); */
-
-       sf = (struct linux_sigframe *)kregs.lregs[29];
        if ((error = copyin(sf, &ksf, sizeof(ksf))) != 0)
                return (error);
 
        /* Restore the register context. */
        f = (struct frame *)p->p_md.md_regs;
-#ifdef DEBUG_LINUX
-       printf("sf = %p, f = %p\n", sf, f);
-#endif /* DEBUG_LINUX */
        for (i=0; i<32; i++)
-               f->f_regs[i] = kregs.lregs[i];
-       f->f_regs[MULLO] = kregs.llo;
-       f->f_regs[MULHI] = kregs.lhi;
-       f->f_regs[PC] = kregs.lcp0_epc;
-       f->f_regs[BADVADDR] = kregs.lcp0_badvaddr;
-       f->f_regs[CAUSE] = kregs.lcp0_cause;
+               f->f_regs[i] = ksf.lsf_sc.lsc_regs[i];
+       f->f_regs[MULLO] = ksf.lsf_sc.lsc_mdlo;
+       f->f_regs[MULHI] = ksf.lsf_sc.lsc_mdhi;
+       f->f_regs[PC] = ksf.lsf_sc.lsc_pc;
+       f->f_regs[BADVADDR] = ksf.lsf_sc.lsc_badvaddr;
+       f->f_regs[CAUSE] = ksf.lsf_sc.lsc_cause;
+       f->f_regs[SR] = ksf.lsf_sc.lsc_status;
 
        /* Restore signal stack. */
        p->p_sigctx.ps_sigstk.ss_flags &= ~SS_ONSTACK;
diff -r d62d6047a98e -r 74376faf8672 sys/compat/linux/arch/mips/linux_syscall.h
--- a/sys/compat/linux/arch/mips/linux_syscall.h        Tue Nov 20 21:21:03 2001 +0000
+++ b/sys/compat/linux/arch/mips/linux_syscall.h        Tue Nov 20 21:37:50 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_syscall.h,v 1.5 2001/11/13 02:08:44 lukem Exp $ */
+/* $NetBSD: linux_syscall.h,v 1.6 2001/11/20 21:37:51 manu Exp $ */
 
 /*
  * System call numbers.
@@ -302,7 +302,7 @@
 /* syscall: "fsync" ret: "int" args: "int" */
 #define        LINUX_SYS_fsync 118
 
-/* syscall: "sigreturn" ret: "int" args: "struct linux_pt_regs" */
+/* syscall: "sigreturn" ret: "int" args: "struct linux_sigframe *" */
 #define        LINUX_SYS_sigreturn     119
 
 /* syscall: "clone" ret: "int" args: "int" "void *" */
diff -r d62d6047a98e -r 74376faf8672 sys/compat/linux/arch/mips/linux_syscallargs.h
--- a/sys/compat/linux/arch/mips/linux_syscallargs.h    Tue Nov 20 21:21:03 2001 +0000
+++ b/sys/compat/linux/arch/mips/linux_syscallargs.h    Tue Nov 20 21:37:50 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_syscallargs.h,v 1.5 2001/11/13 02:08:44 lukem Exp $ */
+/* $NetBSD: linux_syscallargs.h,v 1.6 2001/11/20 21:37:51 manu Exp $ */
 
 /*
  * System call argument lists.
@@ -292,7 +292,7 @@
 };
 
 struct linux_sys_sigreturn_args {
-       syscallarg(struct linux_pt_regs) regs;
+       syscallarg(struct linux_sigframe *) sf;
 };
 
 struct linux_sys_clone_args {
diff -r d62d6047a98e -r 74376faf8672 sys/compat/linux/arch/mips/linux_syscalls.c
--- a/sys/compat/linux/arch/mips/linux_syscalls.c       Tue Nov 20 21:21:03 2001 +0000
+++ b/sys/compat/linux/arch/mips/linux_syscalls.c       Tue Nov 20 21:37:50 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_syscalls.c,v 1.5 2001/11/13 02:08:45 lukem Exp $ */
+/* $NetBSD: linux_syscalls.c,v 1.6 2001/11/20 21:37:51 manu Exp $ */
 
 /*
  * System call names.
@@ -8,7 +8,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_syscalls.c,v 1.5 2001/11/13 02:08:45 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_syscalls.c,v 1.6 2001/11/20 21:37:51 manu Exp $");
 
 #if defined(_KERNEL_OPT)
 #if defined(_KERNEL_OPT)
diff -r d62d6047a98e -r 74376faf8672 sys/compat/linux/arch/mips/linux_sysent.c
--- a/sys/compat/linux/arch/mips/linux_sysent.c Tue Nov 20 21:21:03 2001 +0000
+++ b/sys/compat/linux/arch/mips/linux_sysent.c Tue Nov 20 21:37:50 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_sysent.c,v 1.5 2001/11/13 02:08:45 lukem Exp $ */
+/* $NetBSD: linux_sysent.c,v 1.6 2001/11/20 21:37:51 manu Exp $ */
 
 /*
  * System call switch table.
@@ -8,7 +8,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_sysent.c,v 1.5 2001/11/13 02:08:45 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_sysent.c,v 1.6 2001/11/20 21:37:51 manu Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
diff -r d62d6047a98e -r 74376faf8672 sys/compat/linux/arch/mips/syscalls.master
--- a/sys/compat/linux/arch/mips/syscalls.master        Tue Nov 20 21:21:03 2001 +0000
+++ b/sys/compat/linux/arch/mips/syscalls.master        Tue Nov 20 21:37:50 2001 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.3 2001/10/06 13:32:59 manu Exp $  
+       $NetBSD: syscalls.master,v 1.4 2001/11/20 21:37:51 manu Exp $  
 
 ;      @(#)syscalls.master     8.1 (Berkeley) 7/19/93
 
@@ -218,7 +218,7 @@
 117    STD             { int linux_sys_ipc(int what, int a1, int a2, int a3, \
                            caddr_t ptr); }
 118    NOARGS          { int sys_fsync(int fd); }
-119    STD             { int linux_sys_sigreturn(struct linux_pt_regs regs); }
+119    STD             { int linux_sys_sigreturn(struct linux_sigframe *sf); }
 120    STD             { int linux_sys_clone(int flags, void *stack); }
 121    STD             { int linux_sys_setdomainname(char *domainname, \
                            int len); }



Home | Main Index | Thread Index | Old Index