From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99EE4C001DC for ; Mon, 24 Jul 2023 03:07:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2AFD480ADF; Mon, 24 Jul 2023 05:07:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=andestech.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 42217866D9; Mon, 24 Jul 2023 05:07:39 +0200 (CEST) Received: from Atcsqr.andestech.com (60-248-80-70.hinet-ip.hinet.net [60.248.80.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1C93B80628 for ; Mon, 24 Jul 2023 05:07:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=andestech.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ycliang@andestech.com Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 36O37DZg054956; Mon, 24 Jul 2023 11:07:13 +0800 (+08) (envelope-from ycliang@andestech.com) Received: from ubuntu01 (10.0.12.75) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Mon, 24 Jul 2023 11:07:10 +0800 Date: Mon, 24 Jul 2023 03:07:07 +0000 From: Leo Liang To: Bo Gan CC: , Rick Chen , Sean Anderson , Bin Meng , Lukas Auer Subject: Re: [RESEND PATCH v2] riscv: setup per-hart stack earlier Message-ID: References: <1686527657-366116-1-git-send-email-ganboing@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1686527657-366116-1-git-send-email-ganboing@gmail.com> User-Agent: Mutt/2.0.5 (2021-01-21) X-Originating-IP: [10.0.12.75] X-DNSRBL: X-MAIL: Atcsqr.andestech.com 36O37DZg054956 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On Sun, Jun 11, 2023 at 04:54:17PM -0700, Bo Gan wrote: > Harts need to use per-hart stack before any function call, even if that > function is a simple one. When the callee uses stack for register save/ > restore, especially RA, if nested call, concurrent access by multiple > harts on the same stack will cause data-race. > > This patch sets up SP before `board_init_f_alloc_reserve`. A side effect > of this is that the memory layout has changed as the following: > > +----------------+ +----------------+ <----- SPL_STACK/ > | ...... | | hart 0 stack | SYS_INIT_SP_ADDR > | malloc_base | +----------------+ > +----------------+ | hart 1 stack | > | GD | +----------------+ If not SMP, N=1 > +----------------+ | ...... | > | hart 0 stack | +----------------+ > +----------------+ ==> | hart N-1 stack| > | hart 1 stack | +----------------+ > +----------------+ | ...... | > | ...... | | malloc_base | > +----------------+ +----------------+ > | hart N-1 stack| | GD | > +----------------+ +----------------+ > | | | | > > Signed-off-by: Bo Gan > Cc: Rick Chen > Cc: Leo > Cc: Sean Anderson > Cc: Bin Meng > Cc: Lukas Auer > Reviewed-by: Rick Chen > --- > > v2: > - Fixed macro CONFIG_SYS_INIT_SP_ADDR -> SYS_INIT_SP_ADDR > - Tested SPL with VisionFive 2 board > --- > arch/riscv/cpu/start.S | 37 ++++++++++++++++++++++++------------- > 1 file changed, 24 insertions(+), 13 deletions(-) Reviewed-by: Leo Yu-Chi Liang