Extension on Alexey:
When some interrupts (but not others) occur, they automatically push a 4-byte error code onto the stack. Page error is one of them.
This error code contains additional information about the interrupt.
Intel Programming Guide Volume Guide 3 - 325384-056US September 2015 Table 6-1. The column "Corrected and interrupted modes of protected mode" "Error code" tells us which interrupts click the error code and which do not.
38.9.2.2 "Page Error Error Codes" explains what the error means.
So you will need:
pop %eax /* Do something with %eax */ iret
Or if you want to ignore the error code:
add $4, %esp iret
For a minimal example, see the handler for this page and try to comment on pop .
Compare the above with the exception of the split error , which does not need to call the stack.
Please note that if you just int $14 , the extra byte will not be pressed: this will happen only with the actual exception.
An expert way to handle this is to push error code 0 on the stack for interrupts that don't do this to make things the same. The James Molloy tutorial does just that .
The Linux 4.2 kernel seems to do something similar. In arch / x86 / entry / entry64.S it models interrupts with has_error_code :
trace_idtentry page_fault do_page_fault has_error_code=1
and then uses it in the same file as:
.ifeq \has_error_code pushq $-1 /* ORIG_RAX: no syscall to restart */ .endif
which makes a click when has_error_code=0 .
A related question: Should I call an error code that has been pushed onto the stack with some exceptions before returning from the interrupt handler?
Ciro Santilli 包子 露 宪 六四 事件 法轮功
source share