lkml.org 
[lkml]   [2014]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: perf_fuzzer compiled for x32 causes reboot
On Mon, 24 Feb 2014 20:30:43 +0100
Peter Zijlstra <peterz@infradead.org> 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


\
 
 \ /
  Last update: 2014-02-24 21:21    [W:0.215 / U:0.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site