Why linux kernel use trap gate to handle divide_error exception?

后端 未结 5 1455
一个人的身影
一个人的身影 2020-12-09 20:16

In kernel 2.6.11.5, divide zero exception handler is set up as:

set_trap_gate(0,÷_error);

According to \"Understanding The Linux

5条回答
  •  庸人自扰
    2020-12-09 20:22

    The answer to part of your question can be found at Section 6.12.1.1 of "Intel(R) 64 and IA-32 Architectures and Software Developer's Manual, Volume 3A"

    The processor checks the DPL of the interrupt or trap gate only if an exception or interrupt is generated with an INT n, INT 3, or INTO instruction. Here, the CPL must be less than or equal to the DPL of the gate. This restriction prevents application programs or procedures running at privilege level 3 from using a software interrupt to access critical exception handlers, such as the page-fault handler, providing that those handlers are placed in more privileged code segments (numerically lower privilege level). For hardware-generated interrupts and processor-detected exceptions, the processor ignores the DPL of interrupt and trap gates.

    It's what Alex Kreimer answered

    Regarding to the message. I'm not totally sure, but it seems that OS sends the SIGFPE signal to the process.

提交回复
热议问题