]> git.baikalelectronics.ru Git - kernel.git/commit
ftrace: Synchronize variable setting with breakpoints
authorSteven Rostedt <srostedt@redhat.com>
Wed, 30 May 2012 17:26:37 +0000 (13:26 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 1 Jun 2012 03:12:17 +0000 (23:12 -0400)
commit405ca044d7689e035c60320037b21f8dc7b09fb5
tree739c64a3fd4bf58b7c34a9eb5bc83aa844a06bf3
parentb19aea3506879219a8d924235a31a7145a527e28
ftrace: Synchronize variable setting with breakpoints

When the function tracer starts modifying the code via breakpoints
it sets a variable (modifying_ftrace_code) to inform the breakpoint
handler to call the ftrace int3 code.

But there's no synchronization between setting this code and the
handler, thus it is possible for the handler to be called on another
CPU before it sees the variable. This will cause a kernel crash as
the int3 handler will not know what to do with it.

I originally added smp_mb()'s to force the visibility of the variable
but H. Peter Anvin suggested that I just make it atomic.

[ Added comments as suggested by Peter Zijlstra ]

Suggested-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
arch/x86/include/asm/ftrace.h
arch/x86/kernel/ftrace.c
arch/x86/kernel/traps.c