diff options
author | Steven Rostedt <srostedt@redhat.com> | 2012-05-30 11:47:00 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2012-05-31 23:12:21 -0400 |
commit | f8988175fd70874d1fb3712b1c5d3bfc6d455202 (patch) | |
tree | 2f00c9f7986e17b2cead373325e01081bc879b6c /arch/x86 | |
parent | c0525a6972d3f1fb83058ef503e183475d6e4e26 (diff) |
x86: Allow nesting of the debug stack IDT setting
When the NMI handler runs, it checks if it preempted a debug handler
and if that handler is using the debug stack. If it is, it changes the
IDT table not to update the stack, otherwise it will reset the debug
stack and corrupt the debug handler it preempted.
Now that ftrace uses breakpoints to change functions from nops to
callers, many more places may hit a breakpoint. Unfortunately this
includes some of the calls that lockdep performs. Which causes issues
with the debug stack. It too needs to change the debug stack before
tracing (if called from the debug handler).
Allow the debug_stack_set_zero() and debug_stack_reset() to be nested
so that the debug handlers can take advantage of them too.
[ Used this_cpu_*() over __get_cpu_var() as suggested by H. Peter Anvin ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 82f29e70d058..6b9333b429ba 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -1101,14 +1101,20 @@ int is_debug_stack(unsigned long addr) | |||
1101 | addr > (__get_cpu_var(debug_stack_addr) - DEBUG_STKSZ)); | 1101 | addr > (__get_cpu_var(debug_stack_addr) - DEBUG_STKSZ)); |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | static DEFINE_PER_CPU(u32, debug_stack_use_ctr); | ||
1105 | |||
1104 | void debug_stack_set_zero(void) | 1106 | void debug_stack_set_zero(void) |
1105 | { | 1107 | { |
1108 | this_cpu_inc(debug_stack_use_ctr); | ||
1106 | load_idt((const struct desc_ptr *)&nmi_idt_descr); | 1109 | load_idt((const struct desc_ptr *)&nmi_idt_descr); |
1107 | } | 1110 | } |
1108 | 1111 | ||
1109 | void debug_stack_reset(void) | 1112 | void debug_stack_reset(void) |
1110 | { | 1113 | { |
1111 | load_idt((const struct desc_ptr *)&idt_descr); | 1114 | if (WARN_ON(!this_cpu_read(debug_stack_use_ctr))) |
1115 | return; | ||
1116 | if (this_cpu_dec_return(debug_stack_use_ctr) == 0) | ||
1117 | load_idt((const struct desc_ptr *)&idt_descr); | ||
1112 | } | 1118 | } |
1113 | 1119 | ||
1114 | #else /* CONFIG_X86_64 */ | 1120 | #else /* CONFIG_X86_64 */ |