Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jul 2007 00:17:37 -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:  <200707300717.l6U7HcNC089641@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. :-/
> 
> 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.

After installing this patch, the bootstrap in the pm3-base port still
fails.  I installed pm3-base from the 6-STABLE package, and it isn't
able to compile any of the other ports.  I suspect the reason for the
latter is that it is new enough to use sendsig() and not osendsig().
This makes sense because osendsig is a COMPAT_43 function and the binary
is a lot newer than that.

To preserve the "kludge" ABI as much as possible, I think it would be
necessary to move the assignment to sc_err into the if-else block that
checks to see if the signal handler was installed with the SA_SIGIFNO
flag, and to make the same change in sendsig(), osendsig(), and
freebsd4_sendsig().  This will break the wine port unless it uses
SA_SIGINFO.


As an alternative, I've got a set of patches to pm3-base to get it
working on -CURRENT.  It wasn't too hard to fix the bootstrap to use the
"undocumented 4th arg" to the signal handler that is mentioned in
i386/include/sigframe.h.  The rest of the patches change the low-level
Module-3 code to use sigaction() with the SA_SIGINFO flag instead of
using a mixture of sigaction() (without SA_SIGINFO) and sigvec().
I'll post the patches for testing once I've had a chance to clean them
up some more.






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