Re: [RFC][PATCH 3/3] x86: Add workaround to NMI iret woes

From: Steven Rostedt
Date: Fri Dec 09 2011 - 10:20:37 EST


On Thu, 2011-12-08 at 21:43 -0500, Steven Rostedt wrote:

> diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
> index b9c8628..d35f554 100644
> --- a/arch/x86/kernel/nmi.c
> +++ b/arch/x86/kernel/nmi.c
> @@ -407,13 +407,29 @@ static notrace __kprobes void default_do_nmi(struct pt_regs *regs)
> dotraplinkage notrace __kprobes void
> do_nmi(struct pt_regs *regs, long error_code)
> {
> + int update_debug_stack = 0;
> +
> nmi_enter();
>
> + /*
> + * If we interrupted a breakpoint, it is possible that
> + * the nmi handler will have breakpoints too. We need to
> + * change the IDT such that breakpoints that happen here
> + * continue to use the NMI stack.
> + */
> + if (unlikely(is_debug_stack(regs->sp))) {

For kicks, I made the update happen every NMI, but also changed the IDT
entry of the NMI to also not change the stack. Then I was able to move a
lot of the hacks from assembly into C code, just before the nmi_enter()
above. It seems it can work too. I didn't finish it, I just wanted to
see if it was doable. But I'm not sure we want to change the IDT (twice)
for all NMIs.

-- Steve


> + zero_debug_stack();
> + update_debug_stack = 1;
> + }
> +
> inc_irq_stat(__nmi_count);
>
> if (!ignore_nmis)
> default_do_nmi(regs);
>
> + if (unlikely(update_debug_stack))
> + reset_debug_stack();
> +
> nmi_exit();
> }


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/