Ticket #13744: handle-stack-fault.diff

File handle-stack-fault.diff, 1.8 KB (added by jua, 2 years ago)
  • src/system/kernel/arch/x86/64/descriptors.cpp

    diff --git a/src/system/kernel/arch/x86/64/descriptors.cpp b/src/system/kernel/arch/x86/64/descriptors.cpp
    index 993dfdf212..12f51c64e2 100644
    a b x86_64_general_protection_fault(iframe* frame)  
    329329}
    330330
    331331
     332static void
     333x86_64_stack_fault_exception(iframe* frame)
     334{
     335    // Non-canonical address accesses which reference the stack cause a stack
     336    // fault exception instead of GPF. However, we can treat it like a GPF.
     337    x86_64_general_protection_fault(frame);
     338}
     339
     340
    332341// #pragma mark -
    333342
    334343
    x86_descriptors_init(kernel_args* args)  
    381390    table[9]  = x86_fatal_exception;        // Coprocessor Segment Overrun
    382391    table[10] = x86_fatal_exception;        // Invalid TSS Exception (#TS)
    383392    table[11] = x86_fatal_exception;        // Segment Not Present (#NP)
    384     table[12] = x86_fatal_exception;        // Stack Fault Exception (#SS)
     393    table[12] = x86_64_stack_fault_exception;    // Stack Fault Exception (#SS)
    385394    table[13] = x86_64_general_protection_fault; // General Protection Exception (#GP)
    386395    table[14] = x86_page_fault_exception;   // Page-Fault Exception (#PF)
    387396    table[16] = x86_unexpected_exception;   // x87 FPU Floating-Point Error (#MF)
  • src/system/kernel/arch/x86/arch_int.cpp

    diff --git a/src/system/kernel/arch/x86/arch_int.cpp b/src/system/kernel/arch/x86/arch_int.cpp
    index 126e1f37a1..39119416af 100644
    a b x86_unexpected_exception(iframe* frame)  
    139139            signalAddress = frame->ip;
    140140            break;
    141141
     142        case 12:    // Stack Fault (#SS)
     143            type = B_STACK_FAULT;
     144            signalNumber = SIGILL;
     145            signalCode = ILL_ILLOPN;
     146            signalAddress = frame->ip;
     147            break;
     148
    142149        case 13:    // General Protection Exception (#GP)
    143150            type = B_GENERAL_PROTECTION_FAULT;
    144151            signalNumber = SIGILL;