From nobody Tue May 14 23:55:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+112921+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112921+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1703600068; cv=none; d=zohomail.com; s=zohoarc; b=JhkZXySiXnCmWhnT/0eJVCHSEHGRITSk4XcYEj8rudPNa83o5e1/rx6uKfwMRHw22VSDVed7C0+4fyBwUFhd0FRGdUW82kZwwm1hinolUHoTXE04mHIpFA48Il2wDyF6kJOsbIbDyhutFqZ0uIptFTOPyuYm08hU4d7JAG3aCEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703600068; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id:Cc; bh=R7hn8RcORRlPekaWWT5SIwc3y/IqAC6qXkmvb9lb/GU=; b=KHSI0KgfGHNfu5fs7eHxA/5p8Xw9OAKjcCdU4WAdWvZrjTF9idIRFEy7Cal8tBm+Wy2f4gdiB6Eekpueoc1ZwYtAGhvigjsqCktYdh0YVr5swhbHaVANDwEh2osAAp5H0rdVnTdX88NDkBrHsDoi6nwpUi+WFIGu+gJgOPcNHgw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+112921+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1703600068476407.16440857426187; Tue, 26 Dec 2023 06:14:28 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=R7hn8RcORRlPekaWWT5SIwc3y/IqAC6qXkmvb9lb/GU=; c=relaxed/simple; d=groups.io; h=Date:From:To:Subject:MIME-Version:Message-ID:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1703600068; v=1; b=WUwDitgM9TAbi8y0G4HxW6TreaAXuR2DIrulaelj6xp8A1vciM0n4OxUlRkFcPPu3B+zDmpp HMxGOE+OWXpGTso3rrBkE3La+/qDH96j2+A+6DPl4C7afdshUrNrhKLH6pXHzYXjek56J7WttEB wZUfkvCp+HEjB8bVrABDsDME= X-Received: by 127.0.0.2 with SMTP id kV2tYY1788612x6QPKGVdbXt; Tue, 26 Dec 2023 06:14:28 -0800 X-Received: from zg8tmtyylji0my4xnjqumte4.icoremail.net (zg8tmtyylji0my4xnjqumte4.icoremail.net [162.243.164.118]) by mx.groups.io with SMTP id smtpd.web10.48329.1703472395687824676 for ; Sun, 24 Dec 2023 18:46:37 -0800 X-Received: from wangyang$bosc.ac.cn ( [123.114.53.210] ) by ajax-webmail-mail (Coremail) ; Mon, 25 Dec 2023 10:46:30 +0800 (GMT+08:00) X-Originating-IP: [123.114.53.210] Date: Mon, 25 Dec 2023 10:46:30 +0800 (GMT+08:00) X-CM-HeaderCharset: UTF-8 From: =?UTF-8?B?546L5rSL?= To: devel@edk2.groups.io, sunilvl@ventanamicro.com, andrei.warkentin@intel.com, gaoliming@byosoft.com.cn, michael.d.kinney@intel.com, zhiguang.liu@intel.com Subject: [edk2-devel] [Resend PATCH] MdePkg/BaseLib:Fix boot DxeCore hang on riscv platform X-Priority: 3 MIME-Version: 1.0 Message-ID: <7ba1f115.42.18c9edddfd2.Coremail.wangyang@bosc.ac.cn> X-Coremail-Locale: zh_CN X-CM-TRANSID: AQAAfwCnj9kG7YhlWMBRAA--.1278W X-CM-SenderInfo: 5zdqw5hdqjquxrvfhtffof0/1tbiAQARE2WIK70CRgABs9 X-Coremail-Antispam: 1Ur529EdanIXcx71UUUUU7IcSsGvfJ3iIAIbVAYjsxI4VWxJw CS07vEb4IE77IF4wCS07vE1I0E4x80FVAKz4kxMIAIbVAFxVCaYxvI4VCIwcAKzIAtYxBI daVFxhVjvjDU= Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,wangyang@bosc.ac.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: aHqppKyLOAge2soWSyzi5L93x1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1703600070378100030 Content-Type: text/plain; charset="utf-8" From f15d405067860a8087c5eb4080bc3e08ca5e0e21 Mon Sep 17 00:00:00 2001 From: wangyang Date: Wed, 20 Dec 2023 20:27:42 +0800 Subject: [PATCH] MdePkg/BaseLib:Fix boot DxeCore hang on riscv platform For scene of HandOffToDxeCore()->SwitchStack(DxeCoreEntryPoint)-> InternalSwitchStack()->LongJump(),Variable HobList.Raw will be passed (from *Context1 to register a0) to DxeMain() in parameter *HobStart. However, meanwhile the function LongJump() overrides register a0 with a1 (-1) due to commit (ea628f28e5 "RISCV: Fix InternalLongJump to return correct value"), then cause hang. Replacing calling LongJump() with new InternalSwitchStackAsm() to pass addres data in register s0 to register a0 could fix this issue (just like the solution in MdePkg/Library/BaseLib/LoongArch64/SwitchStack.S) Signed-off-by: Yang Wang Reviewed-by: Ran Wang Cc:Andrei Warkentin Cc:Liming Gao Cc:Michael D Kinney Cc:Sunil V L Cc:Zhiguang Liu --- .../BaseLib/RiscV64/InternalSwitchStack.c | 7 +++- MdePkg/Library/BaseLib/RiscV64/SwitchStack.S | 40 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 MdePkg/Library/BaseLib/RiscV64/SwitchStack.S diff --git a/MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c b/MdePkg/= Library/BaseLib/RiscV64/InternalSwitchStack.c index b78424c163..c60fbdb896 100644 --- a/MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c +++ b/MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c @@ -8,6 +8,11 @@ #include "BaseLibInternals.h" +UINTN +EFIAPI +InternalSwitchStackAsm ( + IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer + ); /** Transfers control to a function starting with a new stack. @@ -48,6 +53,6 @@ InternalSwitchStack ( JumpBuffer.SP =3D (UINTN)NewStack - sizeof (VOID *); JumpBuffer.S0 =3D (UINT64)(UINTN)Context1; JumpBuffer.S1 =3D (UINT64)(UINTN)Context2; - LongJump (&JumpBuffer, (UINTN)-1); + InternalSwitchStackAsm (&JumpBuffer); ASSERT (FALSE); } diff --git a/MdePkg/Library/BaseLib/RiscV64/SwitchStack.S b/MdePkg/Library/= BaseLib/RiscV64/SwitchStack.S new file mode 100644 index 0000000000..59b8d60e7e --- /dev/null +++ b/MdePkg/Library/BaseLib/RiscV64/SwitchStack.S @@ -0,0 +1,40 @@ +//------------------------------------------------------------------------= ------ +// +// InternalSwitchStackAsm for RISC-V +// +// Copyright (c) 2023, Bosc Corporation. All rights reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +//------------------------------------------------------------------------= ------ +# define REG_S sd +# define REG_L ld +# define SZREG 8 +.align 3 + +/** + This allows the caller to switch the stack and goes to the new entry poi= nt + + @param JumpBuffer A pointer to CPU context buffer. +**/ + + .globl InternalSwitchStackAsm +InternalSwitchStackAsm: + REG_L ra, 0*SZREG(a0) + REG_L s0, 1*SZREG(a0) + REG_L s1, 2*SZREG(a0) + REG_L s2, 3*SZREG(a0) + REG_L s3, 4*SZREG(a0) + REG_L s4, 5*SZREG(a0) + REG_L s5, 6*SZREG(a0) + REG_L s6, 7*SZREG(a0) + REG_L s7, 8*SZREG(a0) + REG_L s8, 9*SZREG(a0) + REG_L s9, 10*SZREG(a0) + REG_L s10, 11*SZREG(a0) + REG_L s11, 12*SZREG(a0) + REG_L sp, 13*SZREG(a0) + + add a0, s0, 0 + add a1, s1, 0 + ret -- 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112921): https://edk2.groups.io/g/devel/message/112921 Mute This Topic: https://groups.io/mt/103369618/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-