Home

Exceptions


The x86_64 processors provide several exceptions. These are, in essence, interrupt routines that are called when some exceptional circumstance occurs - for example an attempt to divide by zero, an attempt to access a non-existant page or one to which the program does not have access rights, etc. All of these exceptions are dealt with in interrupts.s starting at the label intr. They print a message on the screen and then dump some of the more important registers and the stack frame of the interrupt. This consists of either 5 or 6 long words and contains information about the registers %rip, %cs, %flags, %rsp, and %rsp. Some exceptions also provide an error code giving more information about the error; for example, for a Page Fault this gives the address of the attempted memory access.

If the fault occurs in a user program (a very simple test - is %rip greater than, or equal to, the value of $UserCode), then a message is printed to that effect and the program is killed. (This test should really be improved to cover things like memory deallocation; although a fault in the user program, it is actually kernel code that will be running at the time of the exception.) For errors produced by the kernel the system is halted; it can then be examined in a debugger to determine the cause.