Re: Catching signals in a Kernel Module?

Stephen Polkowski (stephen@centtech.com)
Thu, 12 Aug 1999 14:58:12 -0500


Thanks Alan! My driver is working now. :-}

Alan Cox wrote:
>
> > my module working. However, when a user tries to read or
> > write an unsupported MSR, the Intel Pentium II returns with a GP(0).
> > This causes my module to die with a SEGV.
> >
> > How can I catch this signal within my module? I have
>
> Be careful about signal versus exception. Signal has a specific meaning in
> Unix that is different.
>
> > the Linux Device Drivers book, but it doesn't
> > appear to cover this type of problem.
>
> I'm not suprised 8). You can do this. The best example of it is the
> copy_*_user functions (include/asm-i386/uaccess.h)
>
> You want the asm code to look like
>
> 1: wrmsr blah
> 2:
> .section .fixup, "ax"
> 3: code to handle fault
> jmp 2b # Back to the original code path
> .previous
> .section __ex_table, "a"
> .align 4
> .long 1b,3b
> .previous
>
> What happens when you get a fault is the kernel walks the exception table
> looking for the fault address (thats the piece in the __ex_table. If it
> finds the address it jumps to the fault handler address. If not it
> follows the normal path.

-- 
Stephen Polkowski
Centaur Technology  
Austin, TX
(512) 418-5730

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/