On Fri, Apr 05, 2019 at 09:37:27AM -0700, Sean Christopherson wrote:
> On Fri, Apr 05, 2019 at 05:07:01PM +0200, Thomas Gleixner wrote:
> > From: Andy Lutomirski <l...@kernel.org>
> > 
> > stack_overflow_check() is using both irq_stack_ptr and irq_stack_union to
> > find the IRQ stack. That's going to break when vmapped irq stacks are
> > introduced.
> > 
> > Change it to just use irq_stack_ptr.
> > 
> > Signed-off-by: Andy Lutomirski <l...@kernel.org>
> > Signed-off-by: Thomas Gleixner <t...@linutronix.de>
> > 
> > ---
> >  arch/x86/kernel/irq_64.c |    3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > --- a/arch/x86/kernel/irq_64.c
> > +++ b/arch/x86/kernel/irq_64.c
> > @@ -55,9 +55,8 @@ static inline void stack_overflow_check(
> >         regs->sp <= curbase + THREAD_SIZE)
> >             return;
> >  
> > -   irq_stack_top = (u64)this_cpu_ptr(irq_stack_union.irq_stack) +
> > -                   STACK_TOP_MARGIN;
> >     irq_stack_bottom = (u64)__this_cpu_read(irq_stack_ptr);
> > +   irq_stack_top = irq_stack_bottom - IRQ_STACK_SIZE + STACK_TOP_MARGIN;
> 
> Not introduced in this patch, but the names for top and bottom are flipped,
> both for irq_stack and estack.  STACK_TOP_MARGIN should also be
> STACK_BOTTOM_MARGIN.  The actual checks are functionally correct, but holy
> hell does it make reading the code confusing, and the WARN prints backwards
> information.

I agree, but... one man's top is another man's bottom.  Especially when
stacks grow physically down (as defined by Intel) but conceptually up
(as defined by every CS algorithms class ever).

-- 
Josh

Reply via email to