Re: [PATCH 4/5] x86: Allow nesting of the debug stack IDT setting

From: Steven Rostedt
Date: Thu May 31 2012 - 17:38:44 EST


On Thu, 2012-05-31 at 17:37 -0400, Steven Rostedt wrote:
> On Thu, 2012-05-31 at 14:09 -0700, H. Peter Anvin wrote:
>
> > No, I'm asking what environments (alternate stacks) are permitted where.
> > That is the important information.
>
> I believe that the IST stack switch is just a convenient way to allow
> separate stacks for separate events instead of trying to handle all
> events on a single stack, and risk stack overflow.
>
> Thus, the debug/int3 and NMI events use a separate stack to not stress
> the current stack that is not expected to switch. The external interrupt
> stacks are switched on entry of the interrupt and stays on that stack
> and until its finished. There's a check to see if it is already on the
> stack before it does the switch so that it doesn't have the HW switch
> issues that NMI and int3 has.
>
> Thus, if we say we must stay on either the NMI stack or the DEBUG stack,
> then this is what happens. Well, almost.
>
> For NMIs, if it preempted something on the debug stack, it will always
> stay on the NMI stack and never switch. A check is made for both debug
> stacks at once:
>
> int is_debug_stack(unsigned long addr)
> {
> return __get_cpu_var(debug_stack_usage) ||
> (addr <= __get_cpu_var(debug_stack_addr) &&
> addr > (__get_cpu_var(debug_stack_addr) - DEBUG_STKSZ));
> }
>

And, yes, I can send a patch to change these to this_cpu_() if you
like ;-)

-- Steve


--
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/