From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759423AbZBTBQc (ORCPT ); Thu, 19 Feb 2009 20:16:32 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754776AbZBTBPZ (ORCPT ); Thu, 19 Feb 2009 20:15:25 -0500 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.123]:40132 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754352AbZBTBPW (ORCPT ); Thu, 19 Feb 2009 20:15:22 -0500 Message-Id: <20090220011521.256901886@goodmis.org> References: <20090220011316.379904625@goodmis.org> User-Agent: quilt/0.46-1 Date: Thu, 19 Feb 2009 20:13:21 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Andrew Morton , Thomas Gleixner , Peter Zijlstra , Frederic Weisbecker , Linus Torvalds , Arjan van de Ven , Rusty Russell , Mathieu Desnoyers , "H. Peter Anvin" , Steven Rostedt Subject: [PATCH 5/6] ftrace: immediately stop code modification if failure is detected Content-Disposition: inline; filename=0005-ftrace-immediately-stop-code-modification-if-failur.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Rostedt Impact: fix to prevent NMI lockup If the page fault handler produces a WARN_ON in the modifying of text, and the system is setup to have a high frequency of NMIs, we can lock up the system on a failure to modify code. The modifying of code with NMIs allows all NMIs to modify the code if it is about to run. This prevents a modifier on one CPU from modifying code running in NMI context on another CPU. The modifying is done through stop_machine, so only NMIs must be considered. But if the write causes the page fault handler to produce a warning, the print can slow it down enough that as soon as it is done it will take another NMI before going back to the process context. The new NMI will perform the write again causing another print and this will hang the box. This patch turns off the writing as soon as a failure is detected and does not wait for it to be turned off by the process context. This will keep NMIs from getting stuck in this back and forth of print outs. Signed-off-by: Steven Rostedt --- arch/x86/kernel/ftrace.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 05041b0..26b64a8 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -131,6 +131,10 @@ static void ftrace_mod_code(void) */ mod_code_status = probe_kernel_write(mod_code_ip, mod_code_newcode, MCOUNT_INSN_SIZE); + + /* if we fail, then kill any new writers */ + if (mod_code_status) + mod_code_write = 0; } void ftrace_nmi_enter(void) -- 1.5.6.5 --