diff --git a/headers/private/kernel/arch/x86/arch_cpu.h b/headers/private/kernel/arch/x86/arch_cpu.h index 246ce53c0b..48e34e7900 100644 --- a/headers/private/kernel/arch/x86/arch_cpu.h +++ b/headers/private/kernel/arch/x86/arch_cpu.h @@ -268,6 +268,7 @@ uint32 x86_count_mtrrs(void); void x86_set_mtrr(uint32 index, uint64 base, uint64 length, uint8 type); status_t x86_get_mtrr(uint32 index, uint64 *_base, uint64 *_length, uint8 *_type); bool x86_check_feature(uint32 feature, enum x86_feature_type type); +void* x86_get_double_fault_stack(int32 cpu, size_t* _size); #define read_cr3(value) \ diff --git a/src/system/kernel/arch/x86/arch_cpu.c b/src/system/kernel/arch/x86/arch_cpu.c index b499da6599..775fa0b857 100644 --- a/src/system/kernel/arch/x86/arch_cpu.c +++ b/src/system/kernel/arch/x86/arch_cpu.c @@ -452,6 +452,14 @@ x86_check_feature(uint32 feature, enum x86_feature_type type) } +void* +x86_get_double_fault_stack(int32 cpu, size_t* _size) +{ + *_size = sizeof(sDoubleFaultStack); + return sDoubleFaultStack; +} + + // #pragma mark - diff --git a/src/system/kernel/arch/x86/arch_debug.cpp b/src/system/kernel/arch/x86/arch_debug.cpp index 79de3059b7..1ac7cefc20 100644 --- a/src/system/kernel/arch/x86/arch_debug.cpp +++ b/src/system/kernel/arch/x86/arch_debug.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -208,6 +209,14 @@ setup_for_thread(char *arg, struct thread **_thread, uint32 *_ebp, *_thread = thread; } +static bool +is_double_fault_stack_address(int32 cpu, addr_t address) +{ + size_t size; + addr_t bottom = (addr_t)x86_get_double_fault_stack(cpu, &size); + return address >= bottom && address < bottom + size; +} + static bool is_kernel_stack_address(struct thread* thread, addr_t address) @@ -218,7 +227,9 @@ is_kernel_stack_address(struct thread* thread, addr_t address) return IS_KERNEL_ADDRESS(address); return address >= thread->kernel_stack_base - && address < thread->kernel_stack_top; + && address < thread->kernel_stack_top + || thread->cpu != NULL + && is_double_fault_stack_address(thread->cpu->cpu_num, address); }