https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113321

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to H. Peter Anvin from comment #0)
> __attribute__((interrupt)) on x86 has two prototypes, and picking the wrong
> type "probably will cause a system crash." It turns out that this is
> unavoidable on i386, but on x86-64 we can do better:
> 
> - On x86-64, an exception/interrupt carries an error code if and only if the
> stack is 16-byte aligned (specifically, RSP[3] = 0) on exception entry.
> 
> The proper stack pointer for using with IRET is therefore always given by:
> 
> RSP |= 8
> 
> ... and the error code, if present, will be located at offset -8 from this
> address.

GCC always generates IRET for __attribute__((interrupt)).  If there are 2
arguments (one of them is the error code), it is an exception handler.
Otherwise, it is an interrupt handler.

Reply via email to