diff --git a/sys/alpha/linux/linux_sysvec.c b/sys/alpha/linux/linux_sysvec.c index 134ff9ebf820..a7da30635c62 100644 --- a/sys/alpha/linux/linux_sysvec.c +++ b/sys/alpha/linux/linux_sysvec.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_sysvec.c,v 1.26 1998/02/13 07:34:52 bde Exp $ + * $Id: linux_sysvec.c,v 1.27 1998/04/13 17:49:51 sos Exp $ */ /* XXX we use functions that might not exist. */ @@ -98,6 +98,29 @@ int linux_to_bsd_signal[LINUX_NSIG] = { SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGURG, SIGURG, 0 }; +/* + * If FreeBSD & Linux have a difference of opinion about what a trap + * means, deal with it here. + */ +static int +translate_traps(int signal, int trap_code) +{ + switch(signal) { + case SIGBUS: + switch(trap_code) { + case T_PROTFLT: + case T_TSSFLT: + case T_DOUBLEFLT: + case T_PAGEFLT: + return SIGSEGV; + default: + return signal; + } + default: + return signal; + } +} + static int linux_fixup(int **stack_base, struct image_params *imgp) { @@ -374,6 +397,7 @@ struct sysentvec linux_sysvec = { bsd_to_linux_signal, ELAST, bsd_to_linux_errno, + translate_traps, linux_fixup, linux_sendsig, linux_sigcode, @@ -390,6 +414,7 @@ struct sysentvec elf_linux_sysvec = { bsd_to_linux_signal, ELAST, bsd_to_linux_errno, + translate_traps, elf_linux_fixup, linux_sendsig, linux_sigcode, diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 7f0f801c151e..3325d326905b 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.125 1998/03/30 09:48:27 phk Exp $ + * $Id: trap.c,v 1.126 1998/04/15 17:45:07 bde Exp $ */ /* @@ -545,6 +545,10 @@ trap(frame) return; } + /* Translate fault for emulators (e.g. Linux) */ + if (*p->p_sysent->sv_transtrap) + i = (*p->p_sysent->sv_transtrap)(i, type); + trapsignal(p, i, ucode); #ifdef DEBUG diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 7f0f801c151e..3325d326905b 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.125 1998/03/30 09:48:27 phk Exp $ + * $Id: trap.c,v 1.126 1998/04/15 17:45:07 bde Exp $ */ /* @@ -545,6 +545,10 @@ trap(frame) return; } + /* Translate fault for emulators (e.g. Linux) */ + if (*p->p_sysent->sv_transtrap) + i = (*p->p_sysent->sv_transtrap)(i, type); + trapsignal(p, i, ucode); #ifdef DEBUG diff --git a/sys/i386/ibcs2/ibcs2_sysvec.c b/sys/i386/ibcs2/ibcs2_sysvec.c index b7ecbca0e027..7eefe14be7fe 100644 --- a/sys/i386/ibcs2/ibcs2_sysvec.c +++ b/sys/i386/ibcs2/ibcs2_sysvec.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ + * $Id: ibcs2_sysvec.c,v 1.6 1997/02/22 09:33:28 peter Exp $ */ #include @@ -49,6 +49,7 @@ struct sysentvec ibcs2_svr3_sysvec = { bsd_to_ibcs2_sig, ELAST, bsd_to_ibcs2_errno, + 0, /* trap-to-signal translation function */ 0, /* fixup */ sendsig, sigcode, /* use generic trampoline */ diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 134ff9ebf820..a7da30635c62 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: linux_sysvec.c,v 1.26 1998/02/13 07:34:52 bde Exp $ + * $Id: linux_sysvec.c,v 1.27 1998/04/13 17:49:51 sos Exp $ */ /* XXX we use functions that might not exist. */ @@ -98,6 +98,29 @@ int linux_to_bsd_signal[LINUX_NSIG] = { SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGURG, SIGURG, 0 }; +/* + * If FreeBSD & Linux have a difference of opinion about what a trap + * means, deal with it here. + */ +static int +translate_traps(int signal, int trap_code) +{ + switch(signal) { + case SIGBUS: + switch(trap_code) { + case T_PROTFLT: + case T_TSSFLT: + case T_DOUBLEFLT: + case T_PAGEFLT: + return SIGSEGV; + default: + return signal; + } + default: + return signal; + } +} + static int linux_fixup(int **stack_base, struct image_params *imgp) { @@ -374,6 +397,7 @@ struct sysentvec linux_sysvec = { bsd_to_linux_signal, ELAST, bsd_to_linux_errno, + translate_traps, linux_fixup, linux_sendsig, linux_sigcode, @@ -390,6 +414,7 @@ struct sysentvec elf_linux_sysvec = { bsd_to_linux_signal, ELAST, bsd_to_linux_errno, + translate_traps, elf_linux_fixup, linux_sendsig, linux_sigcode, diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index a6d67855b4c3..7cfebf0bba9f 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -26,7 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: imgact_elf.c,v 1.22 1998/03/02 05:47:58 peter Exp $ + * $Id: imgact_elf.c,v 1.23 1998/03/28 13:24:52 bde Exp $ */ #include "opt_rlimit.h" @@ -78,6 +78,7 @@ static struct sysentvec elf_freebsd_sysvec = { 0, 0, 0, + 0, elf_freebsd_fixup, sendsig, sigcode, diff --git a/sys/kern/init_sysvec.c b/sys/kern/init_sysvec.c index 3e203836170c..35a04e2cd227 100644 --- a/sys/kern/init_sysvec.c +++ b/sys/kern/init_sysvec.c @@ -1,7 +1,7 @@ /* * sysentvec for native FreeBSD a.out executable format. * - * $Id: init_sysvec.c,v 1.4 1997/02/22 09:38:59 peter Exp $ + * $Id: init_sysvec.c,v 1.5 1997/08/02 14:31:26 bde Exp $ */ #include @@ -19,6 +19,7 @@ struct sysentvec aout_sysvec = { 0, 0, 0, + 0, sendsig, sigcode, &szsigcode, diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 7f0f801c151e..3325d326905b 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.125 1998/03/30 09:48:27 phk Exp $ + * $Id: trap.c,v 1.126 1998/04/15 17:45:07 bde Exp $ */ /* @@ -545,6 +545,10 @@ trap(frame) return; } + /* Translate fault for emulators (e.g. Linux) */ + if (*p->p_sysent->sv_transtrap) + i = (*p->p_sysent->sv_transtrap)(i, type); + trapsignal(p, i, ucode); #ifdef DEBUG diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index 16575ff3861a..6c2e014d1165 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: sysent.h,v 1.15 1997/11/06 19:29:47 phk Exp $ + * $Id: sysent.h,v 1.16 1998/02/03 21:51:57 bde Exp $ */ #ifndef _SYS_SYSENT_H_ @@ -58,6 +58,8 @@ struct sysentvec { int *sv_sigtbl; /* signal translation table */ int sv_errsize; /* size of errno translation table */ int *sv_errtbl; /* errno translation table */ + int (*sv_transtrap) __P((int, int)); + /* translate trap-to-signal mapping */ int (*sv_fixup) __P((int **, struct image_params *)); /* stack fixup function */ void (*sv_sendsig) __P((void (*)(int), int, int, u_long));