Error in save_stack_trace() on x86_64?
Subsystems (3)
Quoted 13 lines · Arjan van de Ven
Vegard Nossum wrote: in userspace this trace looks correct.
Quoted 6 lines
No, it is happening from kernel code. As you can see from the original backtrace, the
regs->ip(RIP) (regs taken from the very samedo_page_fault()) points atadd_uevent_var, which is a kernel function.Quoted 1 line
if it happens in kernel space... I wonder if the separate exception
stack
Quoted 3 lines
Quoted 3 lines
thing
is hurting us with the stacks not being properly connected... (but oopses and the like seem to come out just fine so I kinda doubtyou're
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
hitting that)
Thanks for looking into this.
do you happen to have something that I maybe can reproduce? (if you have that it would save me a ton of time in reproducing)
Here's a very dirty hack that reproduces it for me. I'm sorry I don't have the logs to show it, but it works correctly on 32-bit, but not on 64-bit.
I guess you should also make sure that:
CONFIG_DEBUG_INFO=yCONFIG_FRAME_POINTER=yCONFIG_STACKTRACE=y
Thanks.
Vegard
Signature · 8 lines
"The animistic metaphor of the bug that maliciously sneaked in while the programmer was not looking is intellectually dishonest as it disguises that the error is the programmer's own creation." -- E. W. Dijkstra, EWD1036 arch/x86/mm/fault.c | 17 +++++++++++++++++ init/main.c | 12 ++++++++++++ lib/Kconfig.debug | 1 + 3 files changed, 30 insertions(+), 0 deletions(-)
arch/x86/mm/fault.c +17 -0
@@ -25,6 +25,7 @@#include <linux/kprobes.h> #include <linux/uaccess.h> #include <linux/kdebug.h> +#include <linux/stacktrace.h> #include <asm/system.h> #include <asm/desc.h>
@@ -602,6 +603,22 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)if (notify_page_fault (regs))return ; +dump_stack (); + +struct stack_trace trace; +unsigned long entries[16 ]; + trace.nr_entries =0 ; + trace.entries = entries; + trace.max_entries =16 ; + trace.skip =0 ; +printk (KERN_EMERG "saved stack trace:\n" ); +save_stack_trace (&trace); +print_stack_trace (&trace,0 ); +printk (KERN_EMERG "end saved stack trace\n" ); + +while (1 ) +halt (); +/* * We fault-in kernel-space virtual memory on-demand. The * 'reference' page table is init_mm.pgd.
init/main.c +12 -0
@@ -531,6 +531,16 @@ void __init __weak thread_info_cache_init(void) { } +void noinline trigger_page_fault(void) { +struct page *p =alloc_pages (GFP_KERNEL ,0 ); +unsigned long addr =page_address (p); +set_memory_4k (addr,0 ); +int level; +pte_t *pte =lookup_address (addr, &level); +set_pte (pte,__pte (pte_val (*pte) & ~_PAGE_PRESENT)); + *(char *) addr =0 ; +} + asmlinkage void __init start_kernel(void) {char * command_line;
@@ -680,6 +690,8 @@ asmlinkage void __init start_kernel(void)acpi_early_init ();/* before LAPIC and SMP init */ +trigger_page_fault (); +/* Do the rest non-__init'ed, we're now alive */ rest_init (); }
lib/Kconfig.debug +1 -0
@@ -419,6 +419,7 @@ config DEBUG_LOCKING_API_SELFTESTS config STACKTRACE bool + default y depends on DEBUG_KERNEL depends on STACKTRACE_SUPPORT
Signature · 1 line
1.5.4.1