[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMzpN2j7xKcGx=+z8mu_2z2RsqjB-mpODdrOH7N1J2_OzuyEUQ@mail.gmail.com>
Date: Fri, 1 Mar 2024 08:15:03 -0500
From: Brian Gerst <brgerst@...il.com>
To: "Xin Li (Intel)" <xin@...or.com>
Cc: linux-kernel@...r.kernel.org, tglx@...utronix.de, mingo@...hat.com,
bp@...en8.de, dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com
Subject: Re: [PATCH v1 1/1] x86/fred: Fix init_task thread stack pointer initialization
On Fri, Mar 1, 2024 at 3:41 AM Xin Li (Intel) <xin@...or.com> wrote:
>
> As TOP_OF_KERNEL_STACK_PADDING is defined as 0 on x86_64, no one noticed
> it's missing in the calculation of the .sp field in INIT_THREAD until it
> is defined to 16 with CONFIG_X86_FRED=y.
>
> Subtract TOP_OF_KERNEL_STACK_PADDING from the .sp field of INIT_THREAD.
>
> Fixes: 65c9cc9e2c14 ("x86/fred: Reserve space for the FRED stack frame")
> Fixes: 3adee777ad0d ("x86/smpboot: Remove initial_stack on 64-bit")
> Reported-by: kernel test robot <oliver.sang@...el.com>
> Closes: https://lore.kernel.org/oe-lkp/202402262159.183c2a37-lkp@intel.com
> Signed-off-by: Xin Li (Intel) <xin@...or.com>
> ---
> arch/x86/include/asm/processor.h | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
> index 26620d7642a9..17fe81998ce4 100644
> --- a/arch/x86/include/asm/processor.h
> +++ b/arch/x86/include/asm/processor.h
> @@ -664,8 +664,10 @@ static __always_inline void prefetchw(const void *x)
> #else
> extern unsigned long __end_init_task[];
>
> -#define INIT_THREAD { \
> - .sp = (unsigned long)&__end_init_task - sizeof(struct pt_regs), \
> +#define INIT_THREAD { \
> + .sp = (unsigned long)&__end_init_task - \
> + TOP_OF_KERNEL_STACK_PADDING - \
> + sizeof(struct pt_regs), \
> }
>
> extern unsigned long KSTK_ESP(struct task_struct *task);
>
There is another spot in head_64.S that also needs this offset:
/* Set up the stack for verify_cpu() */
leaq (__end_init_task - PTREGS_SIZE)(%rip), %rsp
Brian Gerst
Powered by blists - more mailing lists