Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Nov 2001 22:47:12 +0100
From:      Pierre Beyssac <pb@fasterix.freenix.org>
To:        freebsd-emulation@freebsd.org
Cc:        fgouget@free.fr
Subject:   patching i386 trap codes for the Linux emulator
Message-ID:  <20011119224712.A81395@fasterix.frmug.org>

next in thread | raw e-mail | index | archive | help

--tKW2IUtsqtDRztdT
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hello,

The following patch has been provided to me by François Gouget
(fgouget@free.fr), a friend of mine and a Wine developer. It fixes
a discrepancy in the Linux emulator between the native i386 trap
codes and the FreeBSD trap codes, causing Linux programs such as,
for example, (a Linux binary of) Wine to act weirdly or break.

If nobody objects to it, I'd like to commit it to -current.

Pierre

--tKW2IUtsqtDRztdT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch.linux_sysvec.c"

--- linux_sysvec.c.orig	Mon Nov 19 22:35:37 2001
+++ linux_sysvec.c	Mon Nov 19 22:39:06 2001
@@ -138,6 +138,45 @@
 	SIGIO, SIGURG, 0
 };
 
+#define LINUX_T_UNKNOWN  255
+static int bsd_to_linux_trapcode[] = {
+	LINUX_T_UNKNOWN,     /* 0 */
+	6,                   /* 1  T_PRIVINFLT */
+	LINUX_T_UNKNOWN,     /* 2 */
+	3,                   /* 3  T_BPTFLT */
+	LINUX_T_UNKNOWN,     /* 4 */
+	LINUX_T_UNKNOWN,     /* 5 */
+	16,                  /* 6  T_ARITHTRAP */
+	254,                 /* 7  T_ASTFLT */
+	LINUX_T_UNKNOWN,     /* 8 */
+	13,                  /* 9  T_PROTFLT */
+	1,                   /* 10 T_TRCTRAP */
+	LINUX_T_UNKNOWN,     /* 11 */
+	14,                  /* 12 T_PAGEFLT */
+	LINUX_T_UNKNOWN,     /* 13 */
+	17,                  /* 14 T_ALIGNFLT */
+	LINUX_T_UNKNOWN,     /* 15 */
+	LINUX_T_UNKNOWN,     /* 16 */
+	LINUX_T_UNKNOWN,     /* 17 */
+	0,                   /* 18 T_DIVIDE */
+	2,                   /* 19 T_NMI */
+	4,                   /* 20 T_OFLOW */
+	5,                   /* 21 T_BOUND */
+	7,                   /* 22 T_DNA */
+	8,                   /* 23 T_DOUBLEFLT */
+	9,                   /* 24 T_FPOPFLT */
+	10,                  /* 25 T_TSSFLT */
+	11,                  /* 26 T_SEGNPFLT */
+	12,                  /* 27 T_STKFLT */
+	18,                  /* 28 T_MCHK */
+	19,                  /* 29 T_XMMFLT */
+	15                   /* 30 T_RESERVED */
+};
+#define bsd_to_linux_trapcode(code) \
+    ((code)<sizeof(bsd_to_linux_trapcode)/sizeof(*bsd_to_linux_trapcode)? \
+     bsd_to_linux_trapcode[(code)]: \
+     LINUX_T_UNKNOWN)
+
 /*
  * If FreeBSD & Linux have a difference of opinion about what a trap
  * means, deal with it here.
@@ -321,7 +360,7 @@
 	frame.sf_sc.uc_mcontext.sc_esp_at_signal = regs->tf_esp;
 	frame.sf_sc.uc_mcontext.sc_ss     = regs->tf_ss;
 	frame.sf_sc.uc_mcontext.sc_err    = regs->tf_err;
-	frame.sf_sc.uc_mcontext.sc_trapno = code;	/* XXX ???? */
+	frame.sf_sc.uc_mcontext.sc_trapno = bsd_to_linux_trapcode(code);
 
 #ifdef DEBUG
 	if (ldebug(rt_sendsig))
@@ -458,7 +497,7 @@
 	frame.sf_sc.sc_esp_at_signal = regs->tf_esp;
 	frame.sf_sc.sc_ss     = regs->tf_ss;
 	frame.sf_sc.sc_err    = regs->tf_err;
-	frame.sf_sc.sc_trapno = code;	/* XXX ???? */
+	frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(code);
 
 	bzero(&frame.sf_fpstate, sizeof(struct l_fpstate));
 

--tKW2IUtsqtDRztdT--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-emulation" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011119224712.A81395>