]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commit
ftrace: protect running nmi (V3)
authorLai Jiangshan <laijs@cn.fujitsu.com>
Wed, 18 Mar 2009 08:42:57 +0000 (16:42 +0800)
committerSteven Rostedt <srostedt@redhat.com>
Thu, 19 Mar 2009 00:36:59 +0000 (20:36 -0400)
commite9d9df44736d116726f4596f7e2f9ce2764ffc0a
treebca129639885fa7288b925e5053f3787fa7e625a
parent4acd4d00f716873e27e7b60ae292cbdbfae674dd
ftrace: protect running nmi (V3)

When I review the sensitive code ftrace_nmi_enter(), I found
the atomic variable nmi_running does protect NMI VS do_ftrace_mod_code(),
but it can not protects NMI(entered nmi) VS NMI(ftrace_nmi_enter()).

cpu#1                   | cpu#2                 | cpu#3
ftrace_nmi_enter()      | do_ftrace_mod_code()  |
  not modify            |                       |
------------------------|-----------------------|--
executing               | set mod_code_write = 1|
executing             --|-----------------------|--------------------
executing               |                       | ftrace_nmi_enter()
executing               |                       |    do modify
------------------------|-----------------------|-----------------
ftrace_nmi_exit()       |                       |

cpu#3 may be being modified the code which is still being executed on cpu#1,
it will have undefined results and possibly take a GPF, this patch
prevents it occurred.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
LKML-Reference: <49C0B411.30003@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
arch/x86/kernel/ftrace.c