[haiku-commits] BRANCH xyzzy-github.x86_64 - src/system/kernel/arch/x86/64

  • From: xyzzy-github.x86_64 <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 14 Aug 2012 17:49:14 +0200 (CEST)

added 1 changeset to branch 'refs/remotes/xyzzy-github/x86_64'
old head: b067b2878bc1f74c9f0d2f60b3d702830e61e8b2
new head: a53cfbf4911ef182672f5a37779a047cfa971221

----------------------------------------------------------------------------

a53cfbf: Jump to the fault handler for GPFs in the debugger.
  
  If an uncanonical address is accessed a general protection fault will
  be raised. When in the debugger, uncanonical address faults should be
  handled by the fault handler (if any).

                                      [ Alex Smith <alex@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Commit:      a53cfbf4911ef182672f5a37779a047cfa971221

Author:      Alex Smith <alex@xxxxxxxxxxxxxxxx>
Date:        Tue Aug 14 15:03:33 2012 UTC

----------------------------------------------------------------------------

1 file changed, 21 insertions(+), 1 deletion(-)
src/system/kernel/arch/x86/64/int.cpp |   22 +++++++++++++++++++++-

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/x86/64/int.cpp 
b/src/system/kernel/arch/x86/64/int.cpp
index 6f0ad29..86681bd 100644
--- a/src/system/kernel/arch/x86/64/int.cpp
+++ b/src/system/kernel/arch/x86/64/int.cpp
@@ -10,6 +10,7 @@
 
 #include <boot/kernel_args.h>
 #include <cpu.h>
+#include <debug.h>
 #include <vm/vm.h>
 #include <vm/vm_priv.h>
 
@@ -29,6 +30,25 @@ interrupt_handler_function* 
gInterruptHandlerTable[kInterruptHandlerTableSize];
 extern uint8 isr_array[kInterruptHandlerTableSize][16];
 
 
+static void
+x86_64_general_protection_fault(iframe* frame)
+{
+       if (debug_debugger_running()) {
+               // Handle GPFs if there is a debugger fault handler installed, 
for
+               // non-canonical address accesses.
+               cpu_ent* cpu = &gCPU[smp_get_current_cpu()];
+               if (cpu->fault_handler != 0) {
+                       debug_set_page_fault_info(0, frame->ip, 
DEBUG_PAGE_FAULT_NO_INFO);
+                       frame->ip = cpu->fault_handler;
+                       frame->bp = cpu->fault_handler_stack_pointer;
+                       return;
+               }
+       }
+
+       x86_unexpected_exception(frame);
+}
+
+
 /*!    Returns the virtual IDT address for CPU \a cpu. */
 void*
 x86_get_idt(int32 cpu)
@@ -87,7 +107,7 @@ arch_int_init(kernel_args* args)
        table[10] = x86_fatal_exception;                // Invalid TSS 
Exception (#TS)
        table[11] = x86_fatal_exception;                // Segment Not Present 
(#NP)
        table[12] = x86_fatal_exception;                // Stack Fault 
Exception (#SS)
-       table[13] = x86_unexpected_exception;   // General Protection Exception 
(#GP)
+       table[13] = x86_64_general_protection_fault; // General Protection 
Exception (#GP)
        table[14] = x86_page_fault_exception;   // Page-Fault Exception (#PF)
        table[16] = x86_unexpected_exception;   // x87 FPU Floating-Point Error 
(#MF)
        table[17] = x86_unexpected_exception;   // Alignment Check Exception 
(#AC)


Other related posts: