From owner-freebsd-emulation Mon Nov 19 13:47:23 2001 Delivered-To: freebsd-emulation@freebsd.org Received: from fasterix.frmug.org (s196.dhcp212-75.cybercable.fr [212.198.75.196]) by hub.freebsd.org (Postfix) with ESMTP id 3C64C37B416 for ; Mon, 19 Nov 2001 13:47:17 -0800 (PST) Received: (from pb@localhost) by fasterix.frmug.org (8.11.6/8.11.5/pb-20010814) id fAJLlC881594; Mon, 19 Nov 2001 22:47:12 +0100 (CET) (envelope-from pb) Message-ID: <20011119224712.A81395@fasterix.frmug.org> Date: Mon, 19 Nov 2001 22:47:12 +0100 From: Pierre Beyssac To: freebsd-emulation@freebsd.org Cc: fgouget@free.fr Subject: patching i386 trap codes for the Linux emulator Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=tKW2IUtsqtDRztdT Content-Transfer-Encoding: 8bit X-Mailer: Mutt 0.92.8i Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --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)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