aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/ftrace.c
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2008-12-02 23:50:06 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-03 02:56:27 -0500
commit62679efe0a5f02987a621942afc5979a80a6ca5a (patch)
tree6d10f9e3f8804ee6414f672695b4f15f78377c21 /arch/x86/kernel/ftrace.c
parente49dc19c6a19ea112fcb94b7c62ec62cdd5c08aa (diff)
ftrace: add checks on ret stack in function graph
Import: robustness checks Add more checks in the function graph code to detect errors and perhaps print out better information if a bug happens. Signed-off-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/ftrace.c')
-rw-r--r--arch/x86/kernel/ftrace.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index d278ad2ebda2..f98c4076a170 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -420,6 +420,15 @@ static void pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret)
420 int index; 420 int index;
421 421
422 index = current->curr_ret_stack; 422 index = current->curr_ret_stack;
423
424 if (unlikely(index < 0)) {
425 ftrace_graph_stop();
426 WARN_ON(1);
427 /* Might as well panic, otherwise we have no where to go */
428 *ret = (unsigned long)panic;
429 return;
430 }
431
423 *ret = current->ret_stack[index].ret; 432 *ret = current->ret_stack[index].ret;
424 trace->func = current->ret_stack[index].func; 433 trace->func = current->ret_stack[index].func;
425 trace->calltime = current->ret_stack[index].calltime; 434 trace->calltime = current->ret_stack[index].calltime;
@@ -427,6 +436,7 @@ static void pop_return_trace(struct ftrace_graph_ret *trace, unsigned long *ret)
427 trace->depth = index; 436 trace->depth = index;
428 barrier(); 437 barrier();
429 current->curr_ret_stack--; 438 current->curr_ret_stack--;
439
430} 440}
431 441
432/* 442/*
@@ -442,6 +452,13 @@ unsigned long ftrace_return_to_handler(void)
442 trace.rettime = cpu_clock(raw_smp_processor_id()); 452 trace.rettime = cpu_clock(raw_smp_processor_id());
443 ftrace_graph_return(&trace); 453 ftrace_graph_return(&trace);
444 454
455 if (unlikely(!ret)) {
456 ftrace_graph_stop();
457 WARN_ON(1);
458 /* Might as well panic. What else to do? */
459 ret = (unsigned long)panic;
460 }
461
445 return ret; 462 return ret;
446} 463}
447 464