Should IRET be used when returning from an interrupt?

IRET can restore registers from the stack, including EFLAGS, ESP, EIP, etc., but we can also restore registers ourselves. For example, "movl" can be used to restore the% esp register, "jmp" can move the address specified in EIP, which is stored on the stack.

The linux kernel returns from all interrupts using IRET, which is a weight instruction.

Some kernel operations (such as context switches) occur frequently.

Isn't IRET wasted?

+3
source share
3 answers

, IRET POPF+RETF, , . , (NMIs).

NMI CPU . IRET NMI, NMI. . NMI ISR NMI, , . -.:)

, , IRET .

+9

, .

0

wikipedija:

, , (ISR). , , , ( ) ISR, ISR , . , FLAGS CS: IP ISR CS: IP; ISR ( , ).

So, IRETit is not waste, the minimum (and the fastest way) is to return from the ISR. Also, all other CPU registers used in the ISR must be saved at start and restored to IRETexsecution!

0
source

All Articles