From bca3215f8a67e154bbf033a44916b18196d2d546 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 4 Aug 2008 02:51:38 +0000 Subject: [PATCH] * Introduced x86_get_double_fault_stack(), which returns the address and size of the double fault stack. * is_kernel_stack_address() does now also check whether the given address is on the double fault stack. This fixes stack traces on double faults, which were broken (i.e. went only to the double fault iframe) since we started checking whether the addresses are on the kernel stack at all. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26775 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/arch/x86/arch_cpu.h | 1 + src/system/kernel/arch/x86/arch_cpu.c | 8 ++++++++ src/system/kernel/arch/x86/arch_debug.cpp | 13 ++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) 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); }