Date: Fri, 27 Jul 2007 15:20:12 -0700 (PDT) From: Don Lewis <truckman@FreeBSD.org> To: jhb@FreeBSD.org Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/i386/i386 trap.c Message-ID: <200707272220.l6RMKCa1083345@gw.catspoiler.org> In-Reply-To: <200707270819.08197.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 27 Jul, John Baldwin wrote: > On Friday 27 July 2007 06:42:20 am Don Lewis wrote: >> On 13 Jun, John Baldwin wrote: >> > jhb 2007-06-13 22:37:48 UTC >> > >> > FreeBSD src repository >> > >> > Modified files: >> > sys/i386/i386 trap.c >> > Log: >> > Don't clobber tf_err with the eva from a page fault as the page fault >> > address is saved in ksi_addr already. >> > >> > PR: i386/101379 >> > Submitted by: Tijl Coosemans : tijl ulyssis org >> > >> > Revision Changes Path >> > 1.306 +0 -3 src/sys/i386/i386/trap.c >> >> This change appears to have broken the garbage collector in >> ports/lang/pm3-base, which means that cvsup no longer works on -CURRENT. >> The garbage collector uses the old sigvec() interface, and counts on >> getting the fault address from the sc_err field in struct sigcontext, >> which is copied from tf_err. >> >> The Modula-3 source code for the handler and the sigvec() call is in >> pm3-1.1.15/libs/m3core/src/runtime/FreeBSD4/RTHeapDep.m3 under the port >> work directory. Since Modula-3 compiler uses this code, the compiler is >> bootstrapped from a version of this file that has already been >> translated to i386 assembly language. The latter lives in >> pm3-1.1.15/boot-FreeBSD4/m3core/FreeBSD4/RTHeapDep.ms. >> >> Modifying the assembly code to convert it to use sigaction() and to pull >> the fault address out of the siginfo structure is left as an exercise >> for someone more masochistic than me. > > Assuming wine doesn't use sigvec() this should work. I noticed while looking > at this that ddb's backtrace had some special handling that assumes tf_err == > faulting address as well. :-/ Cute! > Index: machdep.c > =================================================================== > RCS file: /usr/cvs/src/sys/i386/i386/machdep.c,v > retrieving revision 1.657 > diff -u -r1.657 machdep.c > --- machdep.c 6 Jun 2007 07:35:07 -0000 1.657 > +++ machdep.c 27 Jul 2007 12:17:22 -0000 > @@ -352,7 +352,12 @@ > sf.sf_siginfo.si_sc.sc_pc = regs->tf_eip; > sf.sf_siginfo.si_sc.sc_ps = regs->tf_eflags; > sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno; > - sf.sf_siginfo.si_sc.sc_err = regs->tf_err; > + > + /* > + * XXX: Some old binaries using sigvec() such as cvsup depend > + * on this. > + */ > + sf.sf_siginfo.si_sc.sc_err = (register_t)ksi->ksi_addr; > > /* > * If we're a vm86 process, we want to save the segment registers. I was considering something like this as well, but I was able to come up with a simple, two line change to the pm3 bootstrap assembly code to get it to use the "undocumented 4th arg", sf_addr that is a member of the struct sigframe* in sys/i386/include/sigframe.h. This appears to be portable all the way back to RELENG_4, and probably earlier, and also looks like it should work in i386 mode on amd64. With this change to the bootstrap code, the pm3 build gets a lot farther. It blows up pretty badly when it tries to build the compiler with GCC 4.2, but I worked around that by hacking the build to use GCC 3.4 from ports. The next problem is that it rebuilds the runtime code from Module-3 source and blows up when it tries to use the signal handler compiled from the unmodified Modula-3 source. I started working on a patch for that, which turns out to be a bit more tedious than I thought, because the code uses a mixture of sigvec() and sigaction() and assumes that the handlers are compatible. Your patch might be worthwhile from the POLA standpoint. Would similar changes need to be made to freebsd4_sendsig() and sendsig()?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707272220.l6RMKCa1083345>