x86: Keep current stack in NMI breakpoints
authorSteven Rostedt <srostedt@redhat.com>
Fri, 9 Dec 2011 08:02:19 +0000 (03:02 -0500)
committerSteven Rostedt <rostedt@goodmis.org>
Wed, 21 Dec 2011 20:38:55 +0000 (15:38 -0500)
commit228bdaa95fb830e08b6acd1afd4d2c55093cabfa
tree11d91c3d9f5b576003a07852fcf31eb2ec53bc39
parent3f3c8b8c4b2a34776c3470142a7c8baafcda6eb0
x86: Keep current stack in NMI breakpoints

We want to allow NMI handlers to have breakpoints to be able to
remove stop_machine from ftrace, kprobes and jump_labels. But if
an NMI interrupts a current breakpoint, and then it triggers a
breakpoint itself, it will switch to the breakpoint stack and
corrupt the data on it for the breakpoint processing that it
interrupted.

Instead, have the NMI check if it interrupted breakpoint processing
by checking if the stack that is currently used is a breakpoint
stack. If it is, then load a special IDT that changes the IST
for the debug exception to keep the same stack in kernel context.
When the NMI is done, it puts it back.

This way, if the NMI does trigger a breakpoint, it will keep
using the same stack and not stomp on the breakpoint data for
the breakpoint it interrupted.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
arch/x86/include/asm/desc.h
arch/x86/include/asm/processor.h
arch/x86/kernel/cpu/common.c
arch/x86/kernel/head_64.S
arch/x86/kernel/nmi.c
arch/x86/kernel/traps.c