• Andy Lutomirski's avatar
    x86/nmi/64: Switch stacks on userspace NMI entry · 9b6e6a83
    Andy Lutomirski authored
    Returning to userspace is tricky: IRET can fail, and ESPFIX can
    rearrange the stack prior to IRET.
    
    The NMI nesting fixup relies on a precise stack layout and
    atomic IRET.  Rather than trying to teach the NMI nesting fixup
    to handle ESPFIX and failed IRET, punt: run NMIs that came from
    user mode on the normal kernel stack.
    
    This will make some nested NMIs visible to C code, but the C
    code is okay with that.
    
    As a side effect, this should speed up perf: it eliminates an
    RDMSR when NMIs come from user mode.
    Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
    Reviewed-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    Reviewed-by: default avatarBorislav Petkov <bp@suse.de>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    9b6e6a83
entry_64.S 40.1 KB