summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authoreivind <eivind@FreeBSD.org>1998-04-28 18:15:08 +0000
committereivind <eivind@FreeBSD.org>1998-04-28 18:15:08 +0000
commit67c7bb9c04ed76649b6be0484dcfaa84fa554bcd (patch)
tree1a99fec62896b96dd22a726554f4d62d24de741f /sys
parent470efec49a7164af77eed73b6ff91740609ea273 (diff)
downloadFreeBSD-src-67c7bb9c04ed76649b6be0484dcfaa84fa554bcd.zip
FreeBSD-src-67c7bb9c04ed76649b6be0484dcfaa84fa554bcd.tar.gz
Translate T_PROTFLT to SIGSEGV instead of SIGBUS when running under
Linux emulation. This make Allegro Common Lisp 4.3 work under FreeBSD! Submitted by: Fred Gilham <gilham@csl.sri.com> Commented on by: bde, dg, msmith, tg Hoping he got everything right: eivind
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/linux/linux_sysvec.c27
-rw-r--r--sys/amd64/amd64/trap.c6
-rw-r--r--sys/i386/i386/trap.c6
-rw-r--r--sys/i386/ibcs2/ibcs2_sysvec.c3
-rw-r--r--sys/i386/linux/linux_sysvec.c27
-rw-r--r--sys/kern/imgact_elf.c3
-rw-r--r--sys/kern/init_sysvec.c3
-rw-r--r--sys/kern/subr_trap.c6
-rw-r--r--sys/sys/sysent.h4
9 files changed, 76 insertions, 9 deletions
diff --git a/sys/alpha/linux/linux_sysvec.c b/sys/alpha/linux/linux_sysvec.c
index 134ff9e..a7da306 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 7f0f801..3325d32 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 @@ kernel_trap:
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 7f0f801..3325d32 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 @@ kernel_trap:
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 b7ecbca..7eefe14 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 <sys/param.h>
@@ -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 134ff9e..a7da306 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 a6d6785..7cfebf0 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 3e20383..35a04e2 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 <sys/param.h>
@@ -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 7f0f801..3325d32 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 @@ kernel_trap:
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 16575ff..6c2e014 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));
OpenPOWER on IntegriCloud