• Thomas Gleixner's avatar
    x86/irq/64: Adjust the per CPU irq stack pointer by 8 · 951c2a51
    Thomas Gleixner authored
    The per CPU hardirq_stack_ptr contains the pointer to the irq stack in the
    form that it is ready to be assigned to [ER]SP so that the first push ends
    up on the top entry of the stack.
    
    But the stack switching on 64 bit has the following rules:
    
        1) Store the current stack pointer (RSP) in the top most stack entry
           to allow the unwinder to link back to the previous stack
    
        2) Set RSP to the top most stack entry
    
        3) Invoke functions on the irq stack
    
        4) Pop RSP from the top most stack entry (stored in #1) so it's back
           to the original stack.
    
    That requires all stack switching code to decrement the stored pointer by 8
    in order to be able to store the current RSP and then set RSP to that
    location. That's a pointless exercise.
    
    Do the -8 adjustment right when storing the pointer and make the data type
    a void pointer to avoid confusion vs. the struct irq_stack data type which
    is on 64bit only used to declare the backing store. Move the definition
    next to the inuse flag so they likely end up in the same cache
    line. Sticking them into a struct to enforce it is a seperate change.
    Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
    Reviewed-by: default avatarKees Cook <keescook@chromium.org>
    Link: https://lore.kernel.org/r/20210210002512.354260928@linutronix.de
    951c2a51
dumpstack_64.c 5.26 KB