lkml.org 
[lkml]   [2009]   [Jun]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [tip:perfcounters/core] perf_counter: x86: Fix call-chain support to use NMI-safe methods


On Mon, 15 Jun 2009, tip-bot for Peter Zijlstra wrote:
>
> __copy_from_user_inatomic() isn't NMI safe in that it can trigger
> the page fault handler which is another trap and its return path
> invokes IRET which will also close the NMI context.

That's not the only problem.

An even more fundamental problem is that the page fault handler is not
re-entrant because of simple the value in %cr2. So regardless of any
'iret' issues, you *CANNOT* take a page fault in an NMI, because the NMI
might happen while we're in the critical region of having taken another
page fault, but before we've saved off the value of %cr2 in that old page
fault.

If the NMI handler causes a page fault, it will corrupt the %cr2 of the
outer page fault. That's why the page fault is done with an interrupt
gate, and why we have that conditional local_irq_enable() in it.

So page faults are fundamentally only safe wrt normal interrupts, not NMI.

Linus


\
 
 \ /
  Last update: 2009-10-18 23:28    [from the cache]
©2003-2011 Jasper Spaans