From patchwork Wed Jan 17 10:41:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1887354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=K9quyQl9; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=Xx+ai/se; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFMsV0f8xz23f1 for ; Wed, 17 Jan 2024 21:42:53 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WDPYtWRC4W5XHULjD1DYijC2DkKN0C1koQv9s4TOWT8=; b=K9quyQl9Sqa08D XGWB4SFKJA2OsPECy5jqzreKJX7dHyThdAI0ZUwUJabFu/13AHRL3UpxWEModhpm8RmcSAYA1yCD9 p43L10MbBqQcnV9u0rIh7DinI1BSH8ZZE42ah3jeK13dnnCHOSWTTPzCGY7eg9qaxVnuOacJzv/Rm 3992wSW5GZRre1k2VIPUKZpBq4dYxC8wENC7oaLmZgW6S8oZinwjgVXr7UPnJMLNCWFOD9zy8poFl XtQ41FUePSHDebzLz66IOmglyDx6b+yfL3qH0MSWotm8PKiIwWd/L6eYU5d8ZOcxOeSBRES2oLIF/ lPLuC5Wiq/cE0gs3Jkbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NR-00FJo5-2w; Wed, 17 Jan 2024 10:42:33 +0000 Received: from m16.mail.126.com ([220.197.31.7]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NL-00FJk3-2B for opensbi@lists.infradead.org; Wed, 17 Jan 2024 10:42:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=qVqHe oLcOsEV4Wfig+xzFZ7sqNjN/4xHD9x6HaUCkRQ=; b=Xx+ai/sekCdAHgx46bxZc msboRnVYCG00cJ9lYCeLj7FtWm9OzvqV4iiQ5tz4QygTIhiQeb/U9w8qGXWeYJPo 8Ru/psoQLvYY/lSO72lAEXvAY9Cg56+Y0DJLeYJ2e//XvdgCzncVqJdJWeIPBUei d/uP2pEw0ni0jo3ap3+Au4= Received: from T490.lan (unknown [112.83.182.118]) by gzga-smtp-mta-g0-0 (Coremail) with SMTP id _____wC3_5cLr6dlF6RgAQ--.42458S3; Wed, 17 Jan 2024 18:42:21 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 01/10] firmware: fw_base.S: Improve loading u32 Date: Wed, 17 Jan 2024 18:41:58 +0800 Message-ID: <20240117104212.1055737-2-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117104212.1055737-1-wxjstz@126.com> References: <20240117104212.1055737-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3_5cLr6dlF6RgAQ--.42458S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7tFyUCw4fCFWrtw1UAFyxKrg_yoW8JFyfpr 43CayfCF4jg34SgryfXw48Zr45K3s8Gws8KayUuF1fAr1avr47ur9xtay3ZF1xtrWIy39Y vF1Ivr18Ca47CaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRTKZXUUUUU= X-Originating-IP: [112.83.182.118] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdANoOmSdLsc-mQACsR X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_024228_122473_44D2F07E X-CRM114-Status: UNSURE ( 6.63 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: lwu exists under the current rv64 and should also exist under the rv128 in the future, so I modified the conditions of conditional compilation so that it can adapt to the future situation Signed-off-by: Xiang W --- firmware/fw_base.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org lwu exists under the current rv64 and should also exist under the rv128 in the future, so I modified the conditions of conditional compilation so that it can adapt to the future situation Signed-off-by: Xiang W Reviewed-by: Anup Patel --- firmware/fw_base.S | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index f7763f4..2f30d00 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -358,7 +358,7 @@ _scratch_init: /* t0 = source FDT start address */ add t0, a1, zero /* t2 = source FDT size in big-endian */ -#if __riscv_xlen == 64 +#if __riscv_xlen > 32 lwu t2, 4(t0) #else lw t2, 4(t0) @@ -424,7 +424,7 @@ _start_warm: /* Find HART count and HART stack size */ lla a4, platform -#if __riscv_xlen == 64 +#if __riscv_xlen > 32 lwu s7, SBI_PLATFORM_HART_COUNT_OFFSET(a4) lwu s8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4) #else @@ -440,7 +440,7 @@ _start_warm: beqz s9, 3f li a4, 0 1: -#if __riscv_xlen == 64 +#if __riscv_xlen > 32 lwu a5, (s9) #else lw a5, (s9) @@ -527,7 +527,7 @@ _hartid_to_scratch: * t2 -> Temporary */ lla t2, platform -#if __riscv_xlen == 64 +#if __riscv_xlen > 32 lwu t0, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(t2) lwu t2, SBI_PLATFORM_HART_COUNT_OFFSET(t2) #else From patchwork Wed Jan 17 10:41:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1887356 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=4PlGuI1j; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=qKDuNjim; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFMsV2r0kz23f8 for ; Wed, 17 Jan 2024 21:42:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LA+L8DlgMoDUuiCiNxB3fS21Mippe9/bZbQUz8PAUBc=; b=4PlGuI1jEXJE3E Shma/rR+imTuLsG/EC+3TIb8upm77Ec88zOgrK7yzMyd3FvxP6frQwIVzGDWejxcYsA8C/f6P/ehF PE2WrjLu8MHVIjJOHI7K5gGwsrfHZvcliL/f1q24SUNoYWtlHgPgcz4M+rhjPeZPoFbmvOIKPwDYF iFrgoi9I4Hga1xWo2mxtL0y8Tw3yzDbIN0+SuITqL/Xbm3ECJ6yL+L/XqOO7r0kKSJkVmCWphpB8A G7Id+Vo3FubFpwnFjplc69CBFJrktjMRmRd0XPjrv2Bsw74gmDvbfo5MKoEQWfNfhzwenIoKsJxc8 s3x4VTdLU1CbeFw0J7ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NU-00FJow-13; Wed, 17 Jan 2024 10:42:36 +0000 Received: from m16.mail.126.com ([220.197.31.7]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NN-00FJkK-0D for opensbi@lists.infradead.org; Wed, 17 Jan 2024 10:42:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=+FXpI DYXg8eoK01C1g9237u8qlXkLhvMxQt0kyU3zUQ=; b=qKDuNjimh6DIFCgwgNkDM JHoBTmTmytkYuoKiqQjeq1qaF5o/0EhMC++0RgOCz2A23z5OfnVlQ+sa1Qrf6FN8 iUtoWdTJMLQlsOJ8+vnBzEdNkUK5UnwoEujjPLHOkcGS3Yb+RMehrcUV2fxsQVVc +vmuOAdHxsyLFJdgsNHQ9E= Received: from T490.lan (unknown [112.83.182.118]) by gzga-smtp-mta-g0-0 (Coremail) with SMTP id _____wC3_5cLr6dlF6RgAQ--.42458S4; Wed, 17 Jan 2024 18:42:22 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 02/10] firmware: fw_base.S: remove _runtime_offset Date: Wed, 17 Jan 2024 18:41:59 +0800 Message-ID: <20240117104212.1055737-3-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117104212.1055737-1-wxjstz@126.com> References: <20240117104212.1055737-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3_5cLr6dlF6RgAQ--.42458S4 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xw1UArW7Cw4DZFy7uryfJFb_yoW3Jrg_CF WakFWxJrWFqr4UWw1rGryrArWFv3s5u3WF9w1kA39rtF17G3yjvFZrA3yqvryUWF43KFW5 ZFWfXFnF9rn29jkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRC38n5UUUUU== X-Originating-IP: [112.83.182.118] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdANoOmSdLsc-mQAEsX X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_024229_510220_874373AB X-CRM114-Status: UNSURE ( 4.94 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: _runtime_offset is a variable not used elsewhere, so remove it. Signed-off-by: Xiang W --- firmware/fw_base.S | 6 ------ 1 file changed, 6 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 2f30d00..0e1b6fb 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -74,8 +74,6 @@ _try_lottery: REG_L t0, 0(t0) /* t1 shall has the [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org _runtime_offset is a variable not used elsewhere, so remove it. Signed-off-by: Xiang W Reviewed-by: Anup Patel --- firmware/fw_base.S | 6 ------ 1 file changed, 6 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 2f30d00..0e1b6fb 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -74,8 +74,6 @@ _try_lottery: REG_L t0, 0(t0) /* t1 shall has the address of _fw_start */ sub t2, t1, t0 - lla t3, _runtime_offset - REG_S t2, (t3) lla t0, __rel_dyn_start lla t1, __rel_dyn_end beq t0, t1, _relocate_done @@ -500,10 +498,6 @@ _skip_trap_exit_rv32_hyp: .data .align 3 -#ifdef FW_PIC -_runtime_offset: - RISCV_PTR 0 -#endif _relocate_lottery: RISCV_PTR 0 _boot_status: From patchwork Wed Jan 17 10:42:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1887350 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=N/OYj49V; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=TQgWe7So; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFMsV2nQyz23f6 for ; Wed, 17 Jan 2024 21:42:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=29ad46w1hyby0FWPmsSHGB2sMTs028ndjPDLkqnfues=; b=N/OYj49VcJhxe0 iA0U2/eFL7IPpHtfiN2qXaTqsnnVqsYbzk3MG50IFbaCpYCZ1Q3TgT6U8Ksisq7In0uwyy5Y0nTdX BBXXTJQs/IFvTCjkopd7xpn5aBoSDAoO2LjM0vHMoa3HX5DvzlBrSLIqgBTvKXHRiHAuhAglnVPYH EhXe6N0CwpVM6RAEGSgdd+XK/BgO7AP3bAU45N6yq+RA539AkUcO5ZuqDtrNZOJT1We50Rf4gkxXo iY7NJ3UBTSyECLJxAZOJUUDRRhq3PA3N4rJ7XifWFr1VO5uFo1lBNTL97uYezGjj+gaZNfr+F7UJX cgEV71xu4ku7k2dm9Ivg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NS-00FJoG-1N; Wed, 17 Jan 2024 10:42:34 +0000 Received: from m16.mail.126.com ([220.197.31.8]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NM-00FJk5-0I for opensbi@lists.infradead.org; Wed, 17 Jan 2024 10:42:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=sfcC4 JZfHJbIPyPg8/eFqjrf39H/Nwd0ESLb7KGbtf0=; b=TQgWe7SozCNadkx9PHa6h 1/bk4D9GPuotAQCoxFTP+DN/qIFuswuPNEgcLd5saVIm7iHJlLRKu30V5CoDa1Ty bAjq39JFHZOXduYUpCQbVvGxZeMZoD4NYp7w/Yg/5Ywp34Kn6VJ9ULwES+vJ/2+6 YstSgT9PDTKSCnKPPmkl3A= Received: from T490.lan (unknown [112.83.182.118]) by gzga-smtp-mta-g0-0 (Coremail) with SMTP id _____wC3_5cLr6dlF6RgAQ--.42458S5; Wed, 17 Jan 2024 18:42:22 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 03/10] firmware: fw_base.S: Simplify address get in _relocate Date: Wed, 17 Jan 2024 18:42:00 +0800 Message-ID: <20240117104212.1055737-4-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117104212.1055737-1-wxjstz@126.com> References: <20240117104212.1055737-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3_5cLr6dlF6RgAQ--.42458S5 X-Coremail-Antispam: 1Uf129KBjvdXoW7GFWftr4DZF1UAryxuw17Wrg_yoWktFb_XF yIvFykGr1jqrW5Zr4Svr1rJrn0kw4avanYgF4kuay7XFWxC3s0vr4UX3yDWa90van8Kr98 ZFn7Xrs29Fn7XjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRM-B_UUUUUU== X-Originating-IP: [112.83.182.118] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBcw5oOmSQAhyLnAAAsS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_024228_539206_EE2F7935 X-CRM114-Status: UNSURE ( 5.92 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Simplify address get in _relocate. Remove _link_end. Signed-off-by: Xiang W --- firmware/fw_base.S | 17 ++++++ 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 0e1b6fb..3d88704 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -97,17 +97,14 @@ _wait_relocate_copy_done: /* Relocate if load a [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Simplify address get in _relocate. Remove _link_end. Signed-off-by: Xiang W --- firmware/fw_base.S | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 0e1b6fb..3d88704 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -97,17 +97,14 @@ _wait_relocate_copy_done: /* Relocate if load address != link address */ _relocate: lla t0, _link_start - REG_L t0, 0(t0) - lla t1, _link_end - REG_L t1, 0(t1) - lla t2, _load_start - REG_L t2, 0(t2) + REG_L t0, 0(t0) /* link start */ + lla t2, _fw_start /* load start */ beq t0, t2, _relocate_done - sub t3, t1, t0 - add t3, t3, t2 + sub t6, t2, t0 /* runtime offset */ + lla t3, _fw_reloc_end /* load end */ lla t4, _relocate_done - sub t4, t4, t2 - add t4, t4, t0 + sub t1, t3, t6 /* link end */ + sub t4, t4, t6 /* link _relocate_done */ blt t2, t0, _relocate_copy_to_upper _relocate_copy_to_lower: ble t1, t2, _relocate_copy_to_lower_loop @@ -506,8 +503,6 @@ _load_start: RISCV_PTR _fw_start _link_start: RISCV_PTR FW_TEXT_START -_link_end: - RISCV_PTR _fw_reloc_end .section .entry, "ax", %progbits .align 3 From patchwork Wed Jan 17 10:42:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1887355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=I/rTuqbW; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=Tt31sFD4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFMsV2xLdz23f9 for ; Wed, 17 Jan 2024 21:42:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qMJU2yx0OXWll72K1q4Yu7hltiH6dXuk6IrLseia35c=; b=I/rTuqbWB46irb wGC5oh+Q1ahX76nnWj3RtHA0Y+FSwaSh8mcPGOh0my7BR1G2xdL1VjP7/dN5M3z0wCzIz+Z4+RANR P8OMEIFj5+Op0jQVWE0Ey5F8v0HbUe5NxZP6EOCnjlVlAJ9TiODp6Tho5AbrjN1jrm91lFAbWOeT1 tXmEpwoMn4WjUXSlBefzbuqUDKEksq6PqMQDRhJlPhET8KzL7G+ZCq9AZthoVdM8h4+JzJJlhSHQa We4JoogU142ZlRp/fSKyzoC/hcynEKwwHlm7D35bKvGtNQYBvvjX8BLhRMw+CEsL7INr2cdX2N8C4 VlCFznsHGEmXJQsqerJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NT-00FJoi-2I; Wed, 17 Jan 2024 10:42:35 +0000 Received: from m16.mail.126.com ([220.197.31.9]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NM-00FJkF-31 for opensbi@lists.infradead.org; Wed, 17 Jan 2024 10:42:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=D/zcO KiTSBMEbT97Dp0p0m92BcZbpWTGDfY7OMWKhPY=; b=Tt31sFD498lUKjeAUnfJf AwoCJeaotryCEttueKj5sSV0mpUjncsxtTxh2U2/FjITapnugfxWkEfLvKk3KBa3 GEAskrs+oBSVj5Vvts1Y1ehZNqhG9y4f11HYPGJT9sdTVs4gvijfBf0imOiGKKh9 qWD7f+TPNRYNJMQeMUMEAA= Received: from T490.lan (unknown [112.83.182.118]) by gzga-smtp-mta-g0-0 (Coremail) with SMTP id _____wC3_5cLr6dlF6RgAQ--.42458S6; Wed, 17 Jan 2024 18:42:22 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 04/10] firmware: fw_base.S: Simplify relocate Date: Wed, 17 Jan 2024 18:42:01 +0800 Message-ID: <20240117104212.1055737-5-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117104212.1055737-1-wxjstz@126.com> References: <20240117104212.1055737-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3_5cLr6dlF6RgAQ--.42458S6 X-Coremail-Antispam: 1Uf129KBjvJXoWxJF45GF1DuF4DXw4DWFyUWrg_yoW5Xw1rpr 43Ca43KanIqa48XFy0k3WUGr45Xa1DXF9rW3y7KFWrAr1rZr15A3W8JryFy3sIq3y0qwsY qFy2kr13Cay2yFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0p_sjjkUUUUU= X-Originating-IP: [112.83.182.118] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBcxBoOmSQAhyLogAAsy X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_024229_299479_F8CA619C X-CRM114-Status: UNSURE ( 8.01 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Regardless of whether the FW_PIC macro is defined or not, the starting address of load/link and the runtime offset are required. Regardless of whether it is boot hart or not, the runtime offset are re [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Regardless of whether the FW_PIC macro is defined or not, the starting address of load/link and the runtime offset are required. Regardless of whether it is boot hart or not, the runtime offset are required. so the code to obtain these values is moved forward. Signed-off-by: Xiang W --- firmware/fw_base.S | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 3d88704..18dd0c5 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -52,6 +52,12 @@ _start: call fw_boot_hart add a6, a0, zero MOV_3R a0, s0, a1, s1, a2, s2 + + lla t2, _fw_start /* load start */ + lla t0, _link_start + REG_L t0, 0(t0) /* link start */ + sub t6, t2, t0 /* runtime offset */ + li a7, -1 beq a6, a7, _try_lottery /* Jump to relocation wait loop if we are not boot hart */ @@ -63,17 +69,7 @@ _try_lottery: amoadd.w a6, a7, (a6) bnez a6, _wait_relocate_copy_done - /* Save load address */ - lla t0, _load_start - lla t1, _fw_start - REG_S t1, 0(t0) - #ifdef FW_PIC - /* relocate the global table content */ - lla t0, _link_start - REG_L t0, 0(t0) - /* t1 shall has the address of _fw_start */ - sub t2, t1, t0 lla t0, __rel_dyn_start lla t1, __rel_dyn_end beq t0, t1, _relocate_done @@ -83,8 +79,8 @@ _try_lottery: bne t5, t3, 3f REG_L t3, 0(t0) REG_L t5, (REGBYTES * 2)(t0) /* t5 <-- addend */ - add t5, t5, t2 - add t3, t3, t2 + add t5, t5, t6 + add t3, t3, t6 REG_S t5, 0(t3) /* store runtime address to the GOT entry */ 3: @@ -96,11 +92,7 @@ _wait_relocate_copy_done: #else /* Relocate if load address != link address */ _relocate: - lla t0, _link_start - REG_L t0, 0(t0) /* link start */ - lla t2, _fw_start /* load start */ beq t0, t2, _relocate_done - sub t6, t2, t0 /* runtime offset */ lla t3, _fw_reloc_end /* load end */ lla t4, _relocate_done sub t1, t3, t6 /* link end */ @@ -143,14 +135,10 @@ _relocate_copy_to_upper_loop: blt t0, t1, _relocate_copy_to_upper_loop jr t4 _wait_relocate_copy_done: - lla t0, _fw_start - lla t1, _link_start - REG_L t1, 0(t1) - beq t0, t1, _wait_for_boot_hart + beq t0, t2, _wait_for_boot_hart lla t2, _boot_status lla t3, _wait_for_boot_hart - sub t3, t3, t0 - add t3, t3, t1 + sub t3, t3, t6 1: /* waitting for relocate copy done (_boot_status == 1) */ li t4, BOOT_STATUS_RELOCATE_DONE @@ -170,12 +158,7 @@ _relocate_done: */ lla t0, _boot_status #ifndef FW_PIC - lla t1, _link_start - REG_L t1, 0(t1) - lla t2, _load_start - REG_L t2, 0(t2) - sub t0, t0, t1 - add t0, t0, t2 + add t0, t0, t6 #endif li t1, BOOT_STATUS_RELOCATE_DONE REG_S t1, 0(t0) @@ -499,8 +482,6 @@ _relocate_lottery: RISCV_PTR 0 _boot_status: RISCV_PTR 0 -_load_start: - RISCV_PTR _fw_start _link_start: RISCV_PTR FW_TEXT_START From patchwork Wed Jan 17 10:42:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1887357 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=gZav/L5f; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=oJaoYwVX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFMsV0ZxLz23f0 for ; Wed, 17 Jan 2024 21:42:53 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dlAhEgcjnMrrx3BOMxdkaqe9gOcw6Uc9jr8y+EGfLwI=; b=gZav/L5faTiKp8 TkMqZJOR2zl4b9eiemnIbELY3w3oLUaNsjfxawkSM2UHQDxKItcnQ353w3KMzL3o+CE/XGPjdGAgL 1vePWu4Yzk4e3GsMCdu/rHEyWubirsXXbASa39beLvvo4lyCkUewciSRYONUDBihzMK8TzD0odo5r i4o5rBV+5P7dSZysl3qzAJ6jNFcZP6wInbz5XFEg6ozcQht1eZFb7XSUWelUaVAo8CrGJZbxQ119B 3JnIYMWlH9ckeDHgzFYyfF3+Jz9cbU/Gup64vM+bxTFk1DRogctAqzxW5c4G1c/XIWqtC9PwpGfFl 5Z8m4e9Hl4ErHiIzIrsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NX-00FJrm-1y; Wed, 17 Jan 2024 10:42:39 +0000 Received: from m16.mail.126.com ([220.197.31.9]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NO-00FJm5-0X for opensbi@lists.infradead.org; Wed, 17 Jan 2024 10:42:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=1HN7i jw4axSPeAVE9Rk/1uvlY6BAKUTQ6IEFMA1f90w=; b=oJaoYwVXlsA0giPPplyuA 7/U4kolBk9c6UqkVQiSZOWfWC04OSi6aWoNpe7va1MMjlbDbKDVXJA3JeCVEn9jd sBlGaNByDZNe7uul+wgM4zflX0QBGj4X0jLUKhjH1j/l0cITZoLYqWcERz3sBYLc 3YPRrAX9Nx+fCnzvQTqQ5k= Received: from T490.lan (unknown [112.83.182.118]) by gzga-smtp-mta-g0-0 (Coremail) with SMTP id _____wC3_5cLr6dlF6RgAQ--.42458S7; Wed, 17 Jan 2024 18:42:22 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 05/10] firmware: fw_base.S: Move _link_start to .rodata section Date: Wed, 17 Jan 2024 18:42:02 +0800 Message-ID: <20240117104212.1055737-6-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117104212.1055737-1-wxjstz@126.com> References: <20240117104212.1055737-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3_5cLr6dlF6RgAQ--.42458S7 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjTRn2-eDUUUU X-Originating-IP: [112.83.182.118] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBcxBoOmSQAhyLogAFs3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_024230_521964_D9DB4736 X-CRM114-Status: UNSURE ( 5.31 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: _link_start is readonly, so move it to rodata section. Signed-off-by: Xiang W --- firmware/fw_base.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 18dd0c5..7c7157d 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -482,6 +482,9 @@ _relocate_lottery: RISCV_PTR 0 _boot_status: RI [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org _link_start is readonly, so move it to rodata section. Signed-off-by: Xiang W Reviewed-by: Anup Patel --- firmware/fw_base.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 18dd0c5..7c7157d 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -482,6 +482,9 @@ _relocate_lottery: RISCV_PTR 0 _boot_status: RISCV_PTR 0 + + .section .rodata + .align 3 _link_start: RISCV_PTR FW_TEXT_START From patchwork Wed Jan 17 10:42:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1887352 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=kywECpUu; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=jKbIQ76r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFMsV0XYLz23dx for ; Wed, 17 Jan 2024 21:42:53 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Hfu5cXs9ZyTshrn02a0xz61CYS1bbDLes6jHpfcn2k8=; b=kywECpUu+PZKdl WUjBWt0xuL24oi9B9g9ptm0sG0nYrPrpOssLAgygDNIAf3UyuwvHlcC4ieOvdBfNnhepZ5FAzkcYQ 63viK0m3a7CkZbZwS4mQcaiBGg0SV8UUOJJPNeHxRR3Kj4WwIcj0di2BKRDmQJOsq7ALAAtdapbJ2 UTEvnwrQrBJ+8egXGM4OExgjO7rED+/MTTOnbvWa2P/QRqml9Cj1yKE+PLyYQJ7+0F1mabJSOCZN2 UhuZzKjjA+UN36AlC+0kUxuC5iTgWCZ4AhOog2kOit4JV9t28lzZuWQSVIVxQ6JJPHJv9tkHssw+K z86yzDbq8tb7zI4J9GqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NT-00FJoQ-0H; Wed, 17 Jan 2024 10:42:35 +0000 Received: from m16.mail.126.com ([220.197.31.8]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NN-00FJkL-02 for opensbi@lists.infradead.org; Wed, 17 Jan 2024 10:42:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=7T6lb 6rTK8AZBUrIRtrl67ncfcz5G25TDrAdrA4hJL0=; b=jKbIQ76rPd50Cv0FBOxJB eGS+JItZjjfm8/deXAF/uaHaGKBykLPW0YB2cf94fL/bTmIN8JQA+Z4/Y4GmlBkO fukuHHv8lNnBSuarLsNwDzIjdkModI8YvlFQntHN+106Q0XChgOqyp/eEmYZkFuu +1+LNtDAKFWuPOIN1cWJ8c= Received: from T490.lan (unknown [112.83.182.118]) by gzga-smtp-mta-g0-0 (Coremail) with SMTP id _____wC3_5cLr6dlF6RgAQ--.42458S8; Wed, 17 Jan 2024 18:42:23 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 06/10] firmware: fw_base: Simplified setup trap handler Date: Wed, 17 Jan 2024 18:42:03 +0800 Message-ID: <20240117104212.1055737-7-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117104212.1055737-1-wxjstz@126.com> References: <20240117104212.1055737-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3_5cLr6dlF6RgAQ--.42458S8 X-Coremail-Antispam: 1Uf129KBjvdXoW7Xw4fZFy3Jw45uryfur1DGFg_yoWkGFb_XF WUua4Iqw4qvrWrX3y0krW3Wwn7WrWF9F4Yg34Dur4jqr13tFWagr9rJw4DWrWrX3s2gr98 AF4DXrsrJr92kjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRNyCJPUUUUU== X-Originating-IP: [112.83.182.118] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdBBoOmSdLsdj5wAAsi X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_024229_406333_349DE25C X-CRM114-Status: UNSURE ( 5.54 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The same detection was done twice when setting mtvec and trap_exit. Merging can reduce code size. Signed-off-by: Xiang W --- firmware/fw_base.S | 16 ++++ 1 file changed, 4 insertions(+), 12 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The same detection was done twice when setting mtvec and trap_exit. Merging can reduce code size. Signed-off-by: Xiang W Reviewed-by: Anup Patel --- firmware/fw_base.S | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 7c7157d..d4a6d3a 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -452,22 +452,14 @@ _start_warm: srli a5, a5, ('H' - 'A') andi a5, a5, 0x1 beq a5, zero, _skip_trap_handler_rv32_hyp - lla a4, _trap_handler_rv32_hyp -_skip_trap_handler_rv32_hyp: -#endif - csrw CSR_MTVEC, a4 - -#if __riscv_xlen == 32 /* Override trap exit for H-extension */ - csrr a5, CSR_MISA - srli a5, a5, ('H' - 'A') - andi a5, a5, 0x1 - beq a5, zero, _skip_trap_exit_rv32_hyp - lla a4, _trap_exit_rv32_hyp csrr a5, CSR_MSCRATCH + lla a4, _trap_exit_rv32_hyp REG_S a4, SBI_SCRATCH_TRAP_EXIT_OFFSET(a5) -_skip_trap_exit_rv32_hyp: + lla a4, _trap_handler_rv32_hyp +_skip_trap_handler_rv32_hyp: #endif + csrw CSR_MTVEC, a4 /* Initialize SBI runtime */ csrr a0, CSR_MSCRATCH From patchwork Wed Jan 17 10:42:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1887359 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pTPxANu/; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=VZjZCrqq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFMsW6h1Fz23fB for ; Wed, 17 Jan 2024 21:42:55 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RaKwiNkqhwVKU36fZkhhoVIrtSQlRd+f98rsObviVXM=; b=pTPxANu/CtS4hY Po56ePTEJohT9ZlO6g4yxm9hq7jzvyljpbPrCXAUkuJOr+fBen1EM6d0aRn3r5YnLablQSpJg3l1A QBCLOaOgthSsVBS4olV7CH7t4pqWjzn4KtHkGoUTmn5ZOWSJcte+AwU1L7/EgaWBkWwFvKarrIquP dxOr/TNTvieNpAb33s3qtfiwWxpn0bqosgO68u+LxgfE+7G9S+F38TK4AylN1IvA6RHiQsOkdBkL4 XfsA2Lnb4H+EFfGPIGBfm3tKK2sKFMBDDPysxpZuabIZF1dEYIPNWr1DwIeIb7bUqfwSO6ldD0Qlo +gEQNVL4USmogpMWQm4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NX-00FJrQ-02; Wed, 17 Jan 2024 10:42:39 +0000 Received: from m16.mail.126.com ([220.197.31.8]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NN-00FJlT-1n for opensbi@lists.infradead.org; Wed, 17 Jan 2024 10:42:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=87iZz lN6RzG1SpLHLdbb2U2qeqVRHuBOGpgTMBxpWuw=; b=VZjZCrqqDvUpJqri7xCqz cy5zJjguuLCTy3lh8opHeSb06YF8ljapapYZnzKCV5bvYnJEvtnlCEn0iZOlvbqp FCwQYVwgBK0iRoMMq1jIZitfn3U8rY/DwDB1V9HiHgfgTVOAoAhvLnzspK3VY6pF XMahsEGESkUVDzZGPbXu8Q= Received: from T490.lan (unknown [112.83.182.118]) by gzga-smtp-mta-g0-0 (Coremail) with SMTP id _____wC3_5cLr6dlF6RgAQ--.42458S9; Wed, 17 Jan 2024 18:42:23 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 07/10] firmware: fw_dynamic.S: Remove _bad_dynamic_info Date: Wed, 17 Jan 2024 18:42:04 +0800 Message-ID: <20240117104212.1055737-8-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117104212.1055737-1-wxjstz@126.com> References: <20240117104212.1055737-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3_5cLr6dlF6RgAQ--.42458S9 X-Coremail-Antispam: 1Uf129KBjvdXoWrZw17uw1rJryUAr1fur4DArb_yoWDJwc_AF y3uFnxCr4Fvr4rtw48ur1rCw1xZ34xua1qg3WxAw4UXr13J34aqrs5CFW2qrWv9F48Kr4r JF17CrnayFn7WjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7sRKID7PUUUUU== X-Originating-IP: [112.83.182.118] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdBJoOmSdLsdj6wAAss X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_024229_972089_F9E651DE X-CRM114-Status: UNSURE ( 5.79 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: _bad_dynamic_info is same as _start_hang, so remove it. Signed-off-by: Xiang W --- firmware/fw_dynamic.S | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/firmware/fw_dynamic.S b/firmware/fw_dynamic.S index 7ff1c6a..5ee2883 100644 --- a/firmware/fw_dynamic.S +++ b/firmware/fw_dynamic.S @@ -11,12 +11,6 @@ Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org _bad_dynamic_info is same as _start_hang, so remove it. Signed-off-by: Xiang W Reviewed-by: Anup Patel --- firmware/fw_dynamic.S | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/firmware/fw_dynamic.S b/firmware/fw_dynamic.S index 7ff1c6a..5ee2883 100644 --- a/firmware/fw_dynamic.S +++ b/firmware/fw_dynamic.S @@ -11,12 +11,6 @@ #include "fw_base.S" - .section .entry, "ax", %progbits - .align 3 -_bad_dynamic_info: - wfi - j _bad_dynamic_info - .section .entry, "ax", %progbits .align 3 .global fw_boot_hart @@ -30,10 +24,10 @@ fw_boot_hart: /* Sanity checks */ li a1, FW_DYNAMIC_INFO_MAGIC_VALUE REG_L a0, FW_DYNAMIC_INFO_MAGIC_OFFSET(a2) - bne a0, a1, _bad_dynamic_info + bne a0, a1, _start_hang li a1, FW_DYNAMIC_INFO_VERSION_MAX REG_L a0, FW_DYNAMIC_INFO_VERSION_OFFSET(a2) - bgt a0, a1, _bad_dynamic_info + bgt a0, a1, _start_hang /* Read boot HART id */ li a1, FW_DYNAMIC_INFO_VERSION_2 From patchwork Wed Jan 17 10:42:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1887351 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Bxeif8Ja; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=l1UbcPZo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFMsV0tvtz23f3 for ; Wed, 17 Jan 2024 21:42:53 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sv/+JDcOTkm38Cxj2rh4aZn98VX5spOSXiLd03LOglg=; b=Bxeif8Jav+bPK6 jkhq8sGOfZ5yB+6gQJdWcduDVc9laroyTvGr94sD1TZYlFFYtkY4pfrLmQTiTcJPAbCl9NJHRldNE M/LVksk/hLlmptlrzlX6VY09XYnRnciEOhj/nIjRdrQR1UK0aV4QiYYny7fUXR9ettZ+/kvYX2YMI m1ANuvxsFr+Hhwjs6+eCumMNRUtwwQTkA1y+Kop1yrCkQxMCQ7SOGPOZIJbD+9EMEz4ttZnEXxhl0 IzTTC0i6crUfTuzBVQSIS9qCcTnjZjFzNnTb6NI0njFBRVZvDT+zyPhkUzPlQv9vn/uYMsG/Edgi6 c4MKtj8e2cTWCapnwXHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NW-00FJqp-15; Wed, 17 Jan 2024 10:42:38 +0000 Received: from m16.mail.126.com ([220.197.31.7]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NN-00FJlQ-1V for opensbi@lists.infradead.org; Wed, 17 Jan 2024 10:42:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=tIhSz 6LArkGcQ3+8VdH1B5HQFmBwthrEu46MhY8ih0Q=; b=l1UbcPZoZUk0UPxlTxixh jfU6pFBCDr539J4ge5z9t+P9qENHwjvu2uuQEVP3VnznIGLBx6iitHczYzuqvcjj bcepNrc+8mPrQdbnWLFizL0iA4Y5k5vFLkTFh4pl+xlzpkG2CbBAC/ztZaWK0teg 5lMwcHP7GRAtYJxAeGdfOs= Received: from T490.lan (unknown [112.83.182.118]) by gzga-smtp-mta-g0-0 (Coremail) with SMTP id _____wC3_5cLr6dlF6RgAQ--.42458S10; Wed, 17 Jan 2024 18:42:23 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 08/10] firmware: fw_base.S: Remove _relocate_lottery Date: Wed, 17 Jan 2024 18:42:05 +0800 Message-ID: <20240117104212.1055737-9-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117104212.1055737-1-wxjstz@126.com> References: <20240117104212.1055737-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3_5cLr6dlF6RgAQ--.42458S10 X-Coremail-Antispam: 1Uf129KBjvJXoW7tF1fGry8Cr1xWF15WF13XFb_yoW8WFWUpr 17Aa9rKr4rK3s8X3W0ga15Wr15Xw4UWay7u3yIgFn3ZFyfZF4rZFy8Jr95XrWvq348tw4j qa47Ka4UZ3s0kF7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piI38OUUUUU= X-Originating-IP: [112.83.182.118] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBdRJoOmSdLudp-gAAsS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_024229_942608_180C7AF3 X-CRM114-Status: UNSURE ( 5.67 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Remove _relocate_lottery and use _boot_status instead Signed-off-by: Xiang W --- firmware/fw_base.S | 14 ++++ 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index d4a6d3a..56bffe8 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -14,8 +14,8 @@ #include #include List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Remove _relocate_lottery and use _boot_status instead Signed-off-by: Xiang W --- firmware/fw_base.S | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index d4a6d3a..56bffe8 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -14,8 +14,8 @@ #include #include -#define BOOT_STATUS_RELOCATE_DONE 1 -#define BOOT_STATUS_BOOT_HART_DONE 2 +#define BOOT_STATUS_RELOCATE_DONE 2 +#define BOOT_STATUS_BOOT_HART_DONE 3 .macro MOV_3R __d0, __s0, __d1, __s1, __d2, __s2 add \__d0, \__s0, zero @@ -64,9 +64,9 @@ _start: bne a0, a6, _wait_relocate_copy_done _try_lottery: /* Jump to relocation wait loop if we don't get relocation lottery */ - lla a6, _relocate_lottery + lla a6, _boot_status li a7, 1 - amoadd.w a6, a7, (a6) + amoswap.w a6, a7, (a6) bnez a6, _wait_relocate_copy_done #ifdef FW_PIC @@ -100,8 +100,6 @@ _relocate: blt t2, t0, _relocate_copy_to_upper _relocate_copy_to_lower: ble t1, t2, _relocate_copy_to_lower_loop - lla t3, _relocate_lottery - BRANGE t2, t1, t3, _start_hang lla t3, _boot_status BRANGE t2, t1, t3, _start_hang lla t3, _relocate @@ -118,8 +116,6 @@ _relocate_copy_to_lower_loop: jr t4 _relocate_copy_to_upper: ble t3, t0, _relocate_copy_to_upper_loop - lla t2, _relocate_lottery - BRANGE t0, t3, t2, _start_hang lla t2, _boot_status BRANGE t0, t3, t2, _start_hang lla t2, _relocate @@ -470,8 +466,6 @@ _skip_trap_handler_rv32_hyp: .data .align 3 -_relocate_lottery: - RISCV_PTR 0 _boot_status: RISCV_PTR 0 From patchwork Wed Jan 17 10:42:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1887360 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=KsQNfDHO; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=MIJ2SXR/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFMsZ5CqYz1yPg for ; Wed, 17 Jan 2024 21:42:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RmMMvOn94sahMDAQBu00HpVZ866LqzQo+gYzwZ6knr4=; b=KsQNfDHO7bhfGe qer4I1UCoe7xuZtGgTYEeoAgjlKxNN/7uwfYsFvYDC+R9z0Nwsb1NnHcVun5fQWnHosNkDmW0UEkW fRLV7eHjvlklfFfUJpoSFd15b6UZEW7509xCoL2HZCXEbeHlOiuHcejvlBbl0mNOnGDU5KfU/s8h5 zxUXiSlTMZhpOabmtnSfl3g8s8kz3p1z6uWiMBfP5Kmt2SzkOxh504qcivp9IHsa9xkvwSl2ml32j eKKK4sIujhTanbBpCG0y4f+5ZxjcPxlwEG9AGlQjhig1CeMGlYWCz8Oh+r6GaEPGn/UjubVgeRKr8 5dDacGfLWlCKd0ztCdDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NU-00FJpI-33; Wed, 17 Jan 2024 10:42:37 +0000 Received: from m16.mail.126.com ([220.197.31.9]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NL-00FJka-30 for opensbi@lists.infradead.org; Wed, 17 Jan 2024 10:42:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=UNxlv ymO4AaGH87t+ZxvTSHlqxoImeBU7hBZJzUH0jk=; b=MIJ2SXR/K+wmpOIbBo4Zc 9tAzqGtqQURx7SYLvGIculCJuJH1s6nfxIthM+7TkUH1618XtrmZx4orNOtkAeSQ JhIvGLl1e7QKs369dnJf/F5mV4wpIbcn6GNE/pfWfP2HBh0ufPD7DC6Z0+HY+Af4 XWEQtpTXBENHqrC5FXY0OQ= Received: from T490.lan (unknown [112.83.182.118]) by gzga-smtp-mta-g0-0 (Coremail) with SMTP id _____wC3_5cLr6dlF6RgAQ--.42458S11; Wed, 17 Jan 2024 18:42:24 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 09/10] firmware: Use C if possible Date: Wed, 17 Jan 2024 18:42:06 +0800 Message-ID: <20240117104212.1055737-10-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117104212.1055737-1-wxjstz@126.com> References: <20240117104212.1055737-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3_5cLr6dlF6RgAQ--.42458S11 X-Coremail-Antispam: 1Uf129KBjvJXoW3tr4DtF4fAr13CFyrZF4UCFg_yoWDKry3pF 9Ika12k3yvgFy0gr9rJF45Zry5Cr4rJw17GFW3tFyfZ3WUZF13JFW2ya4kAF4DAr95Xa4Y vFZ2y3y8CFsxXaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piI38OUUUUU= X-Originating-IP: [112.83.182.118] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBcxBoOmSQAhyLogABsz X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_024228_306972_374D8A9E X-CRM114-Status: GOOD ( 15.39 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Use C as soon as possible after setting up the stack. Signed-off-by: Xiang W --- firmware/fw_base.S | 206 + include/sbi/sbi_init.h | 3 + lib/sbi/sbi_init.c | 111 +++++++++++++++++++++- 3 files changed, 115 insert [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Use C as soon as possible after setting up the stack. Signed-off-by: Xiang W --- firmware/fw_base.S | 206 +---------------------------------------- include/sbi/sbi_init.h | 3 + lib/sbi/sbi_init.c | 111 +++++++++++++++++++++- 3 files changed, 115 insertions(+), 205 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index 56bffe8..aec683b 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -183,192 +183,7 @@ _bss_zero: li s5, (SBI_SCRATCH_SIZE * 2) add sp, s4, s5 - /* Allow main firmware to save info */ - MOV_5R s0, a0, s1, a1, s2, a2, s3, a3, s4, a4 - call fw_save_info - MOV_5R a0, s0, a1, s1, a2, s2, a3, s3, a4, s4 - -#ifdef FW_FDT_PATH - /* Override previous arg1 */ - lla a1, fw_fdt_bin -#endif - - /* - * Initialize platform - * Note: The a0 to a4 registers passed to the - * firmware are parameters to this function. - */ - MOV_5R s0, a0, s1, a1, s2, a2, s3, a3, s4, a4 - call fw_platform_init - add t0, a0, zero - MOV_5R a0, s0, a1, s1, a2, s2, a3, s3, a4, s4 - add a1, t0, zero - - /* Preload HART details - * s7 -> HART Count - * s8 -> HART Stack Size - * s9 -> Heap Size - * s10 -> Heap Offset - */ - lla a4, platform -#if __riscv_xlen > 32 - lwu s7, SBI_PLATFORM_HART_COUNT_OFFSET(a4) - lwu s8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4) - lwu s9, SBI_PLATFORM_HEAP_SIZE_OFFSET(a4) -#else - lw s7, SBI_PLATFORM_HART_COUNT_OFFSET(a4) - lw s8, SBI_PLATFORM_HART_STACK_SIZE_OFFSET(a4) - lw s9, SBI_PLATFORM_HEAP_SIZE_OFFSET(a4) -#endif - - /* Setup scratch space for all the HARTs*/ - lla tp, _fw_end - mul a5, s7, s8 - add tp, tp, a5 - /* Setup heap base address */ - lla s10, _fw_start - sub s10, tp, s10 - add tp, tp, s9 - /* Keep a copy of tp */ - add t3, tp, zero - /* Counter */ - li t2, 1 - /* hartid 0 is mandated by ISA */ - li t1, 0 -_scratch_init: - /* - * The following registers hold values that are computed before - * entering this block, and should remain unchanged. - * - * t3 -> the firmware end address - * s7 -> HART count - * s8 -> HART stack size - * s9 -> Heap Size - * s10 -> Heap Offset - */ - add tp, t3, zero - sub tp, tp, s9 - mul a5, s8, t1 - sub tp, tp, a5 - li a5, SBI_SCRATCH_SIZE - sub tp, tp, a5 - - /* Initialize scratch space */ - /* Store fw_start and fw_size in scratch space */ - lla a4, _fw_start - sub a5, t3, a4 - REG_S a4, SBI_SCRATCH_FW_START_OFFSET(tp) - REG_S a5, SBI_SCRATCH_FW_SIZE_OFFSET(tp) - - /* Store R/W section's offset in scratch space */ - lla a5, _fw_rw_start - sub a5, a5, a4 - REG_S a5, SBI_SCRATCH_FW_RW_OFFSET(tp) - - /* Store fw_heap_offset and fw_heap_size in scratch space */ - REG_S s10, SBI_SCRATCH_FW_HEAP_OFFSET(tp) - REG_S s9, SBI_SCRATCH_FW_HEAP_SIZE_OFFSET(tp) - - /* Store next arg1 in scratch space */ - MOV_3R s0, a0, s1, a1, s2, a2 - call fw_next_arg1 - REG_S a0, SBI_SCRATCH_NEXT_ARG1_OFFSET(tp) - MOV_3R a0, s0, a1, s1, a2, s2 - /* Store next address in scratch space */ - MOV_3R s0, a0, s1, a1, s2, a2 - call fw_next_addr - REG_S a0, SBI_SCRATCH_NEXT_ADDR_OFFSET(tp) - MOV_3R a0, s0, a1, s1, a2, s2 - /* Store next mode in scratch space */ - MOV_3R s0, a0, s1, a1, s2, a2 - call fw_next_mode - REG_S a0, SBI_SCRATCH_NEXT_MODE_OFFSET(tp) - MOV_3R a0, s0, a1, s1, a2, s2 - /* Store warm_boot address in scratch space */ - lla a4, _start_warm - REG_S a4, SBI_SCRATCH_WARMBOOT_ADDR_OFFSET(tp) - /* Store platform address in scratch space */ - lla a4, platform - REG_S a4, SBI_SCRATCH_PLATFORM_ADDR_OFFSET(tp) - /* Store hartid-to-scratch function address in scratch space */ - lla a4, _hartid_to_scratch - REG_S a4, SBI_SCRATCH_HARTID_TO_SCRATCH_OFFSET(tp) - /* Store trap-exit function address in scratch space */ - lla a4, _trap_exit - REG_S a4, SBI_SCRATCH_TRAP_EXIT_OFFSET(tp) - /* Clear tmp0 in scratch space */ - REG_S zero, SBI_SCRATCH_TMP0_OFFSET(tp) - /* Store firmware options in scratch space */ - MOV_3R s0, a0, s1, a1, s2, a2 -#ifdef FW_OPTIONS - li a0, FW_OPTIONS -#else - call fw_options -#endif - REG_S a0, SBI_SCRATCH_OPTIONS_OFFSET(tp) - MOV_3R a0, s0, a1, s1, a2, s2 - /* Move to next scratch space */ - add t1, t1, t2 - blt t1, s7, _scratch_init - - /* - * Relocate Flatened Device Tree (FDT) - * source FDT address = previous arg1 - * destination FDT address = next arg1 - * - * Note: We will preserve a0 and a1 passed by - * previous booting stage. - */ - beqz a1, _fdt_reloc_done - /* Mask values in a4 */ - li a4, 0xff - /* t1 = destination FDT start address */ - MOV_3R s0, a0, s1, a1, s2, a2 - call fw_next_arg1 - add t1, a0, zero - MOV_3R a0, s0, a1, s1, a2, s2 - beqz t1, _fdt_reloc_done - beq t1, a1, _fdt_reloc_done - /* t0 = source FDT start address */ - add t0, a1, zero - /* t2 = source FDT size in big-endian */ -#if __riscv_xlen > 32 - lwu t2, 4(t0) -#else - lw t2, 4(t0) -#endif - /* t3 = bit[15:8] of FDT size */ - add t3, t2, zero - srli t3, t3, 16 - and t3, t3, a4 - slli t3, t3, 8 - /* t4 = bit[23:16] of FDT size */ - add t4, t2, zero - srli t4, t4, 8 - and t4, t4, a4 - slli t4, t4, 16 - /* t5 = bit[31:24] of FDT size */ - add t5, t2, zero - and t5, t5, a4 - slli t5, t5, 24 - /* t2 = bit[7:0] of FDT size */ - srli t2, t2, 24 - and t2, t2, a4 - /* t2 = FDT size in little-endian */ - or t2, t2, t3 - or t2, t2, t4 - or t2, t2, t5 - /* t2 = destination FDT end address */ - add t2, t1, t2 - /* FDT copy loop */ - ble t2, t1, _fdt_reloc_done -_fdt_reloc_again: - REG_L t3, 0(t0) - REG_S t3, 0(t1) - add t0, t0, __SIZEOF_POINTER__ - add t1, t1, __SIZEOF_POINTER__ - blt t1, t2, _fdt_reloc_again -_fdt_reloc_done: + call fw_coldboot_init /* mark boot hart done */ li t0, BOOT_STATUS_BOOT_HART_DONE @@ -441,24 +256,7 @@ _start_warm: /* Setup stack */ add sp, tp, zero - /* Setup trap handler */ - lla a4, _trap_handler -#if __riscv_xlen == 32 - csrr a5, CSR_MISA - srli a5, a5, ('H' - 'A') - andi a5, a5, 0x1 - beq a5, zero, _skip_trap_handler_rv32_hyp - /* Override trap exit for H-extension */ - csrr a5, CSR_MSCRATCH - lla a4, _trap_exit_rv32_hyp - REG_S a4, SBI_SCRATCH_TRAP_EXIT_OFFSET(a5) - lla a4, _trap_handler_rv32_hyp -_skip_trap_handler_rv32_hyp: -#endif - csrw CSR_MTVEC, a4 - - /* Initialize SBI runtime */ - csrr a0, CSR_MSCRATCH + add a0, tp, zero call sbi_init /* We don't expect to reach here hence just hang */ diff --git a/include/sbi/sbi_init.h b/include/sbi/sbi_init.h index 9640fee..bd07403 100644 --- a/include/sbi/sbi_init.h +++ b/include/sbi/sbi_init.h @@ -14,6 +14,9 @@ struct sbi_scratch; +void fw_coldboot_init(unsigned long arg0, unsigned long arg1, + unsigned long arg2, unsigned long arg3, unsigned long arg4); + void __noreturn sbi_init(struct sbi_scratch *scratch); unsigned long sbi_entry_count(u32 hartid); diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 804b01c..1f6f70c 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -6,7 +6,7 @@ * Authors: * Anup Patel */ - +#include #include #include #include @@ -40,6 +40,104 @@ " | |\n" \ " |_|\n\n" + +extern struct sbi_platform platform; + +extern char _fw_start[]; +extern char _fw_end[]; +extern char _fw_rw_start[]; +extern char _start_warm[]; +extern char fw_fdt_bin[]; +extern char _hartid_to_scratch[]; +extern char _trap_handler[]; +extern char _trap_handler_rv32_hyp[]; +extern char _trap_exit[]; +extern char _trap_exit_rv32_hyp[]; + + +extern void fw_save_info(unsigned long arg0, + unsigned long arg1,unsigned long arg2); +extern unsigned long fw_next_arg1(void); +extern unsigned long fw_next_addr(void); +extern unsigned long fw_next_mode(void); +extern unsigned long fw_options(void); + +extern unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1, + unsigned long arg2, unsigned long arg3, unsigned long arg4); + +void fw_coldboot_init(unsigned long arg0, unsigned long arg1, + unsigned long arg2, unsigned long arg3, unsigned long arg4) +{ + unsigned long top; + unsigned long fw_start; + unsigned long fw_rw_offset; + unsigned long fw_heap_size; + unsigned long fw_heap_offset; + unsigned long fw_size; + unsigned long warmboot_addr; + unsigned long platform_addr; + unsigned long hartid_to_scratch; + unsigned long next_addr; + unsigned long next_arg1; + unsigned long next_mode; + unsigned long options; + + const void * fdt; + void *target_fdt; + + fw_save_info(arg0, arg1, arg2); +#ifdef FW_FDT_PATH + arg1 = (unsigned long)fw_fdt_bin; +#endif + + /* initialization platform */ + arg1 = fw_platform_init(arg0, arg1, arg2, arg3, arg4); + + /* relocate fdt */ + fdt = (const void*)arg1; + target_fdt = (void*)fw_next_arg1(); + fdt_move(fdt, target_fdt, fdt_totalsize(fdt)); + + /* initialization scratch for all harts */ + next_addr = fw_next_addr(); + next_arg1 = fw_next_arg1(); + next_mode = fw_next_mode(); +#ifdef FW_OPTIONS + options = FW_OPTIONS +#else + options = fw_options(); +#endif + top = (unsigned long)_fw_end + + platform.hart_stack_size * platform.hart_count; + fw_start = (unsigned long)_fw_start; + fw_rw_offset = (unsigned long)_fw_rw_start - fw_start; + fw_heap_size = platform.heap_size; + fw_heap_offset = top - fw_start; + fw_size = top + fw_heap_size - fw_start; + warmboot_addr = (unsigned long)_start_warm; + platform_addr = (unsigned long)&platform; + hartid_to_scratch = (unsigned long)_hartid_to_scratch; + + for (u32 i = 0; i < platform.hart_count; i++) { + struct sbi_scratch *scratch = (struct sbi_scratch *)(top + - i * platform.hart_stack_size - SBI_SCRATCH_SIZE); + + scratch->fw_start = fw_start; + scratch->fw_size = fw_size; + scratch->fw_rw_offset = fw_rw_offset; + scratch->fw_heap_size = fw_heap_size; + scratch->fw_heap_offset = fw_heap_offset; + scratch->warmboot_addr = warmboot_addr; + scratch->platform_addr = platform_addr; + scratch->hartid_to_scratch = hartid_to_scratch; + scratch->next_addr = next_addr; + scratch->next_arg1 = next_arg1; + scratch->next_mode = next_mode; + scratch->options = options; + scratch->tmp0 = 0; + } +} + static void sbi_boot_print_banner(struct sbi_scratch *scratch) { if (scratch->options & SBI_SCRATCH_NO_BOOT_PRINTS) @@ -543,6 +641,17 @@ void __noreturn sbi_init(struct sbi_scratch *scratch) u32 hartid = current_hartid(); const struct sbi_platform *plat = sbi_platform_ptr(scratch); + unsigned long trap_handler = (unsigned long)_trap_handler; + unsigned long trap_exit = (unsigned long)_trap_exit; +#if __riscv_xlen == 32 + if (misa_extension('H')) { + trap_handler = (unsigned long)_trap_handler_rv32_hyp; + trap_exit = (unsigned long)_trap_exit_rv32_hyp; + } +#endif + csr_write(CSR_MTVEC, trap_handler); + scratch->trap_exit = trap_exit; + for (i = 0; i < plat->hart_count; i++) { h = (plat->hart_index2id) ? plat->hart_index2id[i] : i; if (h == hartid) From patchwork Wed Jan 17 10:42:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiang W X-Patchwork-Id: 1887358 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=PWuGSC6y; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=126.com header.i=@126.com header.a=rsa-sha256 header.s=s110527 header.b=PmhbsBXl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFMsV2jffz23f5 for ; Wed, 17 Jan 2024 21:42:53 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FAql4z1IdBPu/2AHfL1jeIbnvznUvdzN925GzjiPylM=; b=PWuGSC6yLezRDe ZDYEtxOLVOL3Dw1gp3YvsphIxhyt9VhASNy1yu330/03blxuDEvRZ6E2eDKFKtnk5jHBLECj5OcAi 2EPp7Kl512D23xf81n1ly2H45RvXMkfLyUMQsGLQ7PH4X+kU6zlIFDvlvYlde1o4ccKUhoRCuWzbt 77wB5/y/Y5U/fGwjfKaCpe5Q91XRblTUhdxWVsegmRMwCtHdcJ9C5f4joApxQEaO25EwDiVKNkT6f 2/RVMG4WfYFwct4poj/u9pc+bJDTGGh59MxjrcEaC5sgEQBwJcpkJJpt8M4hB/YL6M1YB0d1mxP5U 2m4BjBVtL1fs/zXYLH1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NV-00FJps-26; Wed, 17 Jan 2024 10:42:37 +0000 Received: from m16.mail.126.com ([220.197.31.8]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQ3NN-00FJkM-1E for opensbi@lists.infradead.org; Wed, 17 Jan 2024 10:42:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-ID:MIME-Version; bh=fKTHd FUg9pdH8f80yBLV+HIOtuR/rZq1Y6XY3cdbdqY=; b=PmhbsBXlnXC5CxIuWbi1B s9D6iDaJa9GE3k/PytYLu7otOj1J/kJudGkjmGCVdGaLxwWFksKUa/HY4Dw/dfyi ssAORptvuQI6Atc9dY21czBkQMlQoI5i5KkG9ZZCO4Gd/eOSpmOKGQToHhJnj5k/ OdyakWSBw050A0LwFsSPoY= Received: from T490.lan (unknown [112.83.182.118]) by gzga-smtp-mta-g0-0 (Coremail) with SMTP id _____wC3_5cLr6dlF6RgAQ--.42458S12; Wed, 17 Jan 2024 18:42:24 +0800 (CST) From: Xiang W To: opensbi@lists.infradead.org Cc: Xiang W Subject: [PATCH v3 10/10] firmware: fw_base.S: Fix arguments passing Date: Wed, 17 Jan 2024 18:42:07 +0800 Message-ID: <20240117104212.1055737-11-wxjstz@126.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240117104212.1055737-1-wxjstz@126.com> References: <20240117104212.1055737-1-wxjstz@126.com> MIME-Version: 1.0 X-CM-TRANSID: _____wC3_5cLr6dlF6RgAQ--.42458S12 X-Coremail-Antispam: 1Uf129KBjvJXoWxXF4rCr4kZw4xAr1DAF1UWrg_yoW5GrWxpF 13Ga43Kwn8J34xXa4fJF45uw4YgayrJFyvgFW2qrs3Aw17ur1fAa4rJF9Yy3yUJ34Yyw4r WF1Iyr1UC390krJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pi4CJLUUUUU= X-Originating-IP: [112.83.182.118] X-CM-SenderInfo: pz0m23b26rjloofrz/xtbBcxBoOmSQAhyLpAAAs0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_024229_843614_1A81BC15 X-CRM114-Status: UNSURE ( 8.32 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The previous code backed up and restored arguments many times. Now back up the arguments to s0-s4 at the entry. Calling functions that conform to the riscv calling convention will not destroy the call [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [wxjstz[at]126.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The previous code backed up and restored arguments many times. Now back up the arguments to s0-s4 at the entry. Calling functions that conform to the riscv calling convention will not destroy the callee save register. As long as s0-s4 is not used in assembly, the arguments can be guaranteed not to be destroyed. Signed-off-by: Xiang W --- firmware/fw_base.S | 51 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/firmware/fw_base.S b/firmware/fw_base.S index aec683b..8117e08 100644 --- a/firmware/fw_base.S +++ b/firmware/fw_base.S @@ -47,27 +47,27 @@ .globl _start .globl _start_warm _start: + /* save previous arguments */ + MOV_5R s0, a0, s1, a1, s2, a2, s3, a3, s4, a4 + /* Find preferred boot HART id */ - MOV_3R s0, a0, s1, a1, s2, a2 call fw_boot_hart - add a6, a0, zero - MOV_3R a0, s0, a1, s1, a2, s2 lla t2, _fw_start /* load start */ lla t0, _link_start REG_L t0, 0(t0) /* link start */ sub t6, t2, t0 /* runtime offset */ - li a7, -1 - beq a6, a7, _try_lottery + li t1, -1 + beq a0, t1, _try_lottery /* Jump to relocation wait loop if we are not boot hart */ - bne a0, a6, _wait_relocate_copy_done + bne s0, a0, _wait_relocate_copy_done _try_lottery: /* Jump to relocation wait loop if we don't get relocation lottery */ - lla a6, _boot_status - li a7, 1 - amoswap.w a6, a7, (a6) - bnez a6, _wait_relocate_copy_done + lla a0, _boot_status + li t1, 1 + amoswap.w a0, t1, (a0) + bnez a0, _wait_relocate_copy_done #ifdef FW_PIC lla t0, __rel_dyn_start @@ -167,22 +167,23 @@ _relocate_done: call _reset_regs /* Zero-out BSS */ - lla s4, _bss_start - lla s5, _bss_end + lla t0, _bss_start + lla t1, _bss_end _bss_zero: - REG_S zero, (s4) - add s4, s4, __SIZEOF_POINTER__ - blt s4, s5, _bss_zero + REG_S zero, (t0) + add t0, t0, __SIZEOF_POINTER__ + blt t0, t1, _bss_zero /* Setup temporary trap handler */ - lla s4, _start_hang - csrw CSR_MTVEC, s4 + lla t0, _start_hang + csrw CSR_MTVEC, t0 /* Setup temporary stack */ - lla s4, _fw_end - li s5, (SBI_SCRATCH_SIZE * 2) - add sp, s4, s5 + lla t0, _fw_end + li t1, (SBI_SCRATCH_SIZE * 2) + add sp, t0, t1 + MOV_5R a0, s0, a1, s1, a2, s2, a3, s3, a4, s4 call fw_coldboot_init /* mark boot hart done */ @@ -543,23 +544,21 @@ _reset_regs: /* flush the instruction cache */ fence.i - /* Reset all registers except ra, a0, a1 and a2 */ + /* Reset all registers except ra, s0-s4 */ li sp, 0 li gp, 0 li tp, 0 li t0, 0 li t1, 0 li t2, 0 - li s0, 0 - li s1, 0 + li a0, 0 + li a1, 0 + li a2, 0 li a3, 0 li a4, 0 li a5, 0 li a6, 0 li a7, 0 - li s2, 0 - li s3, 0 - li s4, 0 li s5, 0 li s6, 0 li s7, 0