i386 page fault clobbers error code in trap frame

Kip Macy kip.macy at gmail.com
Sat Jul 29 19:58:53 UTC 2006


Looking at siginfo it isn't clear that there is a "right way" to
provide SIGSEGV, eva, and the error code.

_fault._trapno should contain the machine's  error code and si_signo
should contain SIGSEGV, and si_addr contains the faulting pc. Maybe
one could abuse si_code to contain eva. Sorry for asking a question
that has already been answered but where is eva being put currently?

typedef struct __siginfo {
        int     si_signo;               /* signal number */
        int     si_errno;               /* errno association */
        /*
         * Cause of signal, one of the SI_ macros or signal-specific
         * values, i.e. one of the FPE_... values for SIGFPE.  This
         * value is equivalent to the second argument to an old-style
         * FreeBSD signal handler.
         */
        int     si_code;                /* signal code */
        __pid_t si_pid;                 /* sending process */
        __uid_t si_uid;                 /* sender's ruid */
        int     si_status;              /* exit value */
        void    *si_addr;               /* faulting instruction */
        union sigval si_value;          /* signal value */
        union   {
                struct {
                        int     _trapno;/* machine specific trap code */
                } _fault;
/* .... */


On 7/29/06, Tijl Coosemans <tijl at ulyssis.org> wrote:
> I'm refering to the following two lines in sys/i386/i386/trap.c
>
> /* kludge to pass faulting virtual address to sendsig */
> frame->tf_err = eva;
>
> Isn't there some other way to do this? Wouldn't the address still be
> available in %cr2 inside sendsig? Or could there have been other page
> faults by then?
>
> The reason I'm asking this is that Wine wants to know the error code in
> case of a page fault (the No eXec bit (AMD) and the read/write bit
> specifically).
>
>
>


More information about the freebsd-hackers mailing list