Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp148529lqi; Wed, 6 Mar 2024 12:40:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXhS4350uuJ8BGHeq68suSXiUvA16Iup9T462HrohG4zi+fmt4sT+kCTkFU9kVh2BT0VUG0u7tqYnXsMpuHt/xDGnNq+MZfjXEfXjF6rg== X-Google-Smtp-Source: AGHT+IHPXk2KE74ubwBFI/Do4fVfXDr6wpk0Pq+tAPwhHYRF9sqgjP9zZvJoepS0AdkCABIEDSw+ X-Received: by 2002:a17:90a:df13:b0:29a:6436:ed59 with SMTP id gp19-20020a17090adf1300b0029a6436ed59mr13960257pjb.2.1709757640602; Wed, 06 Mar 2024 12:40:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709757640; cv=pass; d=google.com; s=arc-20160816; b=MkovpavnuQ0Jm8N0wowBHDb5R3ZZ/1MsKRH4jkX6uwMUfKHOpZl8ELZKEl63IqmSPw 2ChBcEHbeVpE6cRKhYe+GB9DC0P5FVmG7tRXodMXhh0EoGPgxrMSxo0k5fe1mA4oiOlD ZX/Yd8jqPROgoJscqVeWQyUoTg9wVel5Vd1dN+J1La+6zrJBwknNLki6LSeM81es+Iiv IBpwwh99+WvC2qvmwd1sGhN2OCclxzH71WlFOchMX8/nSpA+QcveaoDDC1Icl4FXY5V1 ZNv5HOwRdxLvKFSae4aGlrAJ5D9i4OauPrlqKBa5Nzp+NSXNk6PoVd+Bzh2jNfdOadKx K6RA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:references:in-reply-to :user-agent:subject:cc:to:from:date:dkim-signature:dkim-filter; bh=T+TFJC5MWmKywYtHsaL1+tz57km/tmqpnjzR2/q4Iy8=; fh=FLFMxqUyMvp6mne062a62CbRdd3zmbqZOyrLChbAcoA=; b=JWVhHrUL+OQx94+423fLQvEFfnUp0UypKRXXa7EzRJ+iVEm0Xu2QzY6oFTdJ03tsn7 8yCxbsB0XGTKexVKJzkvAMGhnBQBHbK7cghzywyprvA9jvqh6AyS3J3Cc+HdGx+PrC4M xhDSch3kmrqGlT6KRNGn4gpHcJOCB+26gBOArfwV46xKkF8i0Lygjh14RcWyJYHBN8Rk /ieu0fJQDdwVoeIbDITTq6eTS/apOhN431Z2R4oZnEm41Lz5RgubwZ6Nojwwx10916oL tQFVLm+x1+A2ZB3qfpzpS21tDtczxmtIB2S4z6VbK0G7wbkX0ztQJipciJe/6q1cHqW3 wNyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@zytor.com header.s=2024021201 header.b="IF22+C//"; arc=pass (i=1 spf=pass spfdomain=zytor.com dkim=pass dkdomain=zytor.com dmarc=pass fromdomain=zytor.com); spf=pass (google.com: domain of linux-kernel+bounces-94564-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94564-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id pc18-20020a17090b3b9200b0029b0941fa43si260658pjb.127.2024.03.06.12.40.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 12:40:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94564-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2024021201 header.b="IF22+C//"; arc=pass (i=1 spf=pass spfdomain=zytor.com dkim=pass dkdomain=zytor.com dmarc=pass fromdomain=zytor.com); spf=pass (google.com: domain of linux-kernel+bounces-94564-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94564-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1A7D4B21D09 for ; Wed, 6 Mar 2024 20:40:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 394DE14A83; Wed, 6 Mar 2024 20:40:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="IF22+C//" Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B0C212E7F for ; Wed, 6 Mar 2024 20:40:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709757630; cv=none; b=mwjc9LLxDx7dJEQc4e3Yw7GAC0mtbANl3c6L6rwsw2uSvaAjXoRG/g3FA+uO7ZRILuJCSAfBbFPikLf2OIzMzW5d9ybCJRpxILQK8DI1RsXjf9dslYLh0yK5pOf36sUCN0wVIZ2m/BeGDT2DMV35dCr35HdNF/pDbZGt9ppWGuI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709757630; c=relaxed/simple; bh=Xtmn5eZuoRYGUPwEZUSP+0NSl+3b5TM+JwdWgf2bntg=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=kOO+Lxq47byU8pSwtudden9MqU7qpYTSgwUF/Kxu+1yk9YHf1oVMVJLdMx+if5B0A+L+kp3D2T/HlSLzwKCJMAQeuH+z/D9mw0Nd/X4JGQ5Bcre6uyTeWs8VAqX6GBD41r+PgZjK/gHVpwSJ6Qau9f0sr7uomJ5MMgdzpZxaxH0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=IF22+C//; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Received: from [127.0.0.1] ([76.133.66.138]) (authenticated bits=0) by mail.zytor.com (8.17.2/8.17.1) with ESMTPSA id 426KdmEp1568117 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Wed, 6 Mar 2024 12:39:48 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 426KdmEp1568117 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2024021201; t=1709757590; bh=T+TFJC5MWmKywYtHsaL1+tz57km/tmqpnjzR2/q4Iy8=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=IF22+C//PAdzoFM8/VC1KFqG86Yd4ozJyBLsozfUBX6dL48f4gjVLkL49nu+pfrmS tdDItHryquTqMaCAnNDb/lfU4fdOih7nPD1rscZBjqobxd5R4klrzAuFw9bfNo5fDo Ga9x/AR6CxYeyZCZkPtK4/TkBldMs5EFH9eOx1StAn5z5qFQmzZZ/4YGyTOtaniCPu v7LydORJLK3MIafxsts6K+MW780pijaPNPoxCGzPhPCnAsJdNN7DEE4zLUuVEzhoYi GMcpIAa3ksyd92zD2RbM7eBLLZWLLNECVhZU0XfErLpuM8uhp1GxVLHMyz8M+JHV2V iYAXCLEh7Kwfg== Date: Wed, 06 Mar 2024 12:39:46 -0800 From: "H. Peter Anvin" To: Xin Li , linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org CC: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, jgross@suse.com, boris.ostrovsky@oracle.com, arnd@arndb.de, andrew.cooper3@citrix.com, brgerst@gmail.com Subject: =?US-ASCII?Q?Re=3A_=5BPATCH_v2_1/1=5D_x86/fred=3A_Fix_init=5Ft?= =?US-ASCII?Q?ask_thread_stack_pointer_initialization?= User-Agent: K-9 Mail for Android In-Reply-To: References: <20240304083333.449322-1-xin@zytor.com> Message-ID: <82259B6F-2F57-4099-869D-84891D996664@zytor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On March 6, 2024 10:28:25 AM PST, Xin Li wrote: >On 3/4/2024 12:33 AM, Xin Li (Intel) wrote: >> As TOP_OF_KERNEL_STACK_PADDING is defined as 0 on x86_64, no one notice= d >> it's missing in the calculation of the =2Esp field in INIT_THREAD until= it >> is defined to 16 with CONFIG_X86_FRED=3Dy=2E >>=20 >> Subtract TOP_OF_KERNEL_STACK_PADDING from the =2Esp field of INIT_THREA= D=2E >>=20 >> 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 >> Closes: https://lore=2Ekernel=2Eorg/oe-lkp/202402262159=2E183c2a37-lkp@= intel=2Ecom >> Signed-off-by: Xin Li (Intel) >> --- > >Should this fix, if it looks good, be included for the coming merge >window? > >Thanks! > Xin > >>=20 >> Change Since v1: >> * Apply offset TOP_OF_KERNEL_STACK_PADDING to all uses of __end_init_ta= sk >> (Brian Gerst)=2E >> --- >> arch/x86/include/asm/processor=2Eh | 6 ++++-- >> arch/x86/kernel/head_64=2ES | 3 ++- >> arch/x86/xen/xen-head=2ES | 2 +- >> 3 files changed, 7 insertions(+), 4 deletions(-) >>=20 >> diff --git a/arch/x86/include/asm/processor=2Eh b/arch/x86/include/asm/= processor=2Eh >> index 26620d7642a9=2E=2E17fe81998ce4 100644 >> --- a/arch/x86/include/asm/processor=2Eh >> +++ b/arch/x86/include/asm/processor=2Eh >> @@ -664,8 +664,10 @@ static __always_inline void prefetchw(const void *= x) >> #else >> extern unsigned long __end_init_task[]; >> -#define INIT_THREAD { \ >> - =2Esp =3D (unsigned long)&__end_init_task - sizeof(struct pt_regs), \ >> +#define INIT_THREAD { \ >> + =2Esp =3D (unsigned long)&__end_init_task - \ >> + TOP_OF_KERNEL_STACK_PADDING - \ >> + sizeof(struct pt_regs), \ >> } >> extern unsigned long KSTK_ESP(struct task_struct *task); >> diff --git a/arch/x86/kernel/head_64=2ES b/arch/x86/kernel/head_64=2ES >> index d4918d03efb4=2E=2Ec38e43589046 100644 >> --- a/arch/x86/kernel/head_64=2ES >> +++ b/arch/x86/kernel/head_64=2ES >> @@ -26,6 +26,7 @@ >> #include >> #include >> #include >> +#include >> /* >> * We are not able to switch in one step to the final KERNEL ADDRESS = SPACE >> @@ -66,7 +67,7 @@ SYM_CODE_START_NOALIGN(startup_64) >> mov %rsi, %r15 >> /* Set up the stack for verify_cpu() */ >> - leaq (__end_init_task - PTREGS_SIZE)(%rip), %rsp >> + leaq (__end_init_task - TOP_OF_KERNEL_STACK_PADDING - PTREGS_SIZE)(%r= ip), %rsp >> leaq _text(%rip), %rdi >> diff --git a/arch/x86/xen/xen-head=2ES b/arch/x86/xen/xen-head=2ES >> index a0ea285878db=2E=2E04101b984f24 100644 >> --- a/arch/x86/xen/xen-head=2ES >> +++ b/arch/x86/xen/xen-head=2ES >> @@ -49,7 +49,7 @@ SYM_CODE_START(startup_xen) >> ANNOTATE_NOENDBR >> cld >> - leaq (__end_init_task - PTREGS_SIZE)(%rip), %rsp >> + leaq (__end_init_task - TOP_OF_KERNEL_STACK_PADDING - PTREGS_SIZE)(%r= ip), %rsp >> /* Set up %gs=2E >> * >>=20 >> base-commit: e13841907b8fda0ae0ce1ec03684665f578416a8 > Absolutely=2E