Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753359AbaBXTcw (ORCPT ); Mon, 24 Feb 2014 14:32:52 -0500 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.226]:35327 "EHLO cdptpa-oedge-vip.email.rr.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752764AbaBXTcv (ORCPT ); Mon, 24 Feb 2014 14:32:51 -0500 Date: Mon, 24 Feb 2014 14:32:49 -0500 From: Steven Rostedt To: Peter Zijlstra Cc: "H. Peter Anvin" , Vince Weaver , Linux Kernel , Ingo Molnar , "H.J. Lu" Subject: Re: perf_fuzzer compiled for x32 causes reboot Message-ID: <20140224143249.2c37e16f@gandalf.local.home> In-Reply-To: <20140224193043.GP6835@laptop.programming.kicks-ass.net> References: <18f0cea3-7e3b-4477-b433-0269f3de976b@email.android.com> <20140224172536.GD9987@twins.programming.kicks-ass.net> <530B841F.5050803@zytor.com> <530B90A5.3090302@zytor.com> <20140224141329.1cd3bb52@gandalf.local.home> <20140224193043.GP6835@laptop.programming.kicks-ass.net> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.22; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-RR-Connecting-IP: 107.14.168.142:25 X-Cloudmark-Score: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 Feb 2014 20:30:43 +0100 Peter Zijlstra wrote: > On Mon, Feb 24, 2014 at 02:13:29PM -0500, Steven Rostedt wrote: > > Ah, and x86_64 saves off the cr2 register when entering NMI and restores > > it before returning. But it seems to be missing from the i386 code. > > arch/x86/kernel/nmi.c: > > #define nmi_nesting_preprocess(regs) \ > do { \ > if (this_cpu_read(nmi_state) != NMI_NOT_RUNNING) { \ > this_cpu_write(nmi_state, NMI_LATCHED); \ > return; \ > } \ > this_cpu_write(nmi_state, NMI_EXECUTING); \ > this_cpu_write(nmi_cr2, read_cr2()); \ > } while (0); \ > nmi_restart: > > #define nmi_nesting_postprocess() \ > do { \ > if (unlikely(this_cpu_read(nmi_cr2) != read_cr2())) \ > write_cr2(this_cpu_read(nmi_cr2)); \ > if (this_cpu_dec_return(nmi_state)) \ > goto nmi_restart; \ > } while (0) > > That very much looks like saving/restoring CR2 to me. > Ah, I forgot to look in the C file. > FWIW; I hate how the x86_64 and i386 versions of this NMI nesting magic > are so completely different. Yeah, it sucks. But that's because the architecture on handling NMIs is completely different. x86_64 swaps the stack automatically, where as i386 uses the same stack if you are already in the kernel. -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/