From nobody Wed May 8 05:52:02 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+100760+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+100760+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1678137987; cv=none; d=zohomail.com; s=zohoarc; b=XEMe3RRKyiGmYeyE8V11dQYpH8d9NGPda6g92zFM1pXuTpwWu/WVEqrAMQGqIOaMSD58XB7ccw2g/sfIWYFZop9mBBDcDZ35zZbFhdvPplZI3allTB6xZJDvSdXv85mvVHAyMLEs/B/kkdvDR5t2np+OqW2WBcG0sVuuIfFxMmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678137987; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=jortF48YCvOgIjTsx5mjzOx5u74AY3FE6l6UfzaPVls=; b=RCumKTK4k1Ya0DOg9W21ix3O5ck0hPcUkNHC/u3qqpo9+zBa4gg0toTV3FziANrJuGpPiIX6gU49e56DCO38swIyN8B474ghAzpcXOFD9FD2NqpQgk8IyaiFsZIjFWO+fG7r1TaFzb/wsi2bhzF0Bfba2oEa3RprKkEtAMgPgbs= 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+100760+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1678137987567464.4421004551899; Mon, 6 Mar 2023 13:26:27 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id llgAYY1788612xfqXrrGH3Qr; Mon, 06 Mar 2023 13:26:27 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.1898.1678137984252750213 for ; Mon, 06 Mar 2023 13:26:26 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="315335533" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="315335533" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819444253" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="819444253" X-Received: from awarkent-mobl1.amr.corp.intel.com ([10.212.90.17]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:26 -0800 From: "Andrei Warkentin" To: devel@edk2.groups.io Cc: Andrei Warkentin , Sunil V L , Jiewen Yao , Ard Biesheuvel Subject: [edk2-devel] [edk2 1/7] OvmfPkg: RiscVVirt: add SATA support Date: Mon, 6 Mar 2023 15:26:09 -0600 Message-Id: <20230306212615.7400-2-andrei.warkentin@intel.com> In-Reply-To: <20230306212615.7400-1-andrei.warkentin@intel.com> References: <20230306212615.7400-1-andrei.warkentin@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,andrei.warkentin@intel.com X-Gm-Message-State: 5kJXxV8fZCpOsiQXCX75NY2Fx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678137987; bh=u8bclutK7+W77B8DFcB6mHCEI2YIullzsQ/1kQLcN08=; h=Cc:Date:From:Reply-To:Subject:To; b=fcO7LQ+ZUPk4oOhPUQz/s0dPbSqmEL8nNpGLod08a8Xojod0lSclYsAvx4ZXfzimqK3 Q/u0mdO3YJ1WAYbeCot+tHQZmV5q+N3uzcQVZegcgY3Cb/Yq+rjSY3sbVimicqYycY6SV Xr36KSp149WdZ4uegB/4c6cKrMsCzJ9WVOc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678137989521100007 Content-Type: text/plain; charset="utf-8" Tested with a PCIe pass-thru'd AHCI controller. Cc: Sunil V L Cc: Jiewen Yao Cc: Ard Biesheuvel Signed-off-by: Andrei Warkentin --- OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc | 7 +++++++ OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc b/OvmfPkg/RiscVVirt/RiscVV= irtQemu.dsc index 054d511138c3..28d9af4d79b9 100644 --- a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc +++ b/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc @@ -426,6 +426,13 @@ [Components] MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf =20 + # + # SATA + # + MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf + MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf + MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf + # # NVME Driver # diff --git a/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf b/OvmfPkg/RiscVVirt/RiscVV= irtQemu.fdf index 6072c37af03d..354c9271d10c 100644 --- a/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf +++ b/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf @@ -137,6 +137,13 @@ [FV.DXEFV] INF MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf INF MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf =20 +# +# SATA +# +INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf +INF MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf +INF MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf + # # NVME Driver # --=20 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 (#100760): https://edk2.groups.io/g/devel/message/100760 Mute This Topic: https://groups.io/mt/97436046/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- From nobody Wed May 8 05:52:02 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+100761+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+100761+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1678137988; cv=none; d=zohomail.com; s=zohoarc; b=XDQS4P/1igVapCDqtW7eX5bESZohj5xfmeqG+K4pKRqPUcVBZjrc4PCwNFkEYKuONTxifZ+MzmMX8B93At43R3ZKVYulKE9sihAeh/XzqdxLB0K32ymounx6QKhxqBMcJbOePGA3ZLXCcXJBoTMgDzn0DN2RKvQv1u++ZGA1lu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678137988; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=3lABi5OnMvg+MjUioZ5jxlAysbmHBSS+n+INbkJk5+g=; b=g3NdYmHoea5E1hRx65CmknBRGfFvZfS5wAevAD9NjYaYpCN10opaJXsMLwd4brcxQJJYs1IttbrCiNcH/iMSKlfCLQG/bYUsIczilrQ36y6e2CYPkLP4OjV1uMR6IF6/k+97eExHbTDeGw8HfMTZVUfvOlDoU0x6cDKqaksYBcE= 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+100761+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1678137988304780.1050915677638; Mon, 6 Mar 2023 13:26:28 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id gTJ7YY1788612xDGFYjCd16J; Mon, 06 Mar 2023 13:26:28 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.1898.1678137984252750213 for ; Mon, 06 Mar 2023 13:26:27 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="315335542" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="315335542" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819444257" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="819444257" X-Received: from awarkent-mobl1.amr.corp.intel.com ([10.212.90.17]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:26 -0800 From: "Andrei Warkentin" To: devel@edk2.groups.io Cc: Andrei Warkentin , Sunil V L , Daniel Schaefer , Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [edk2-devel] [edk2 2/7] MdePkg: BasePeCoffLib: Allow AArch64 and x64 images in ImageFormatSupported Date: Mon, 6 Mar 2023 15:26:10 -0600 Message-Id: <20230306212615.7400-3-andrei.warkentin@intel.com> In-Reply-To: <20230306212615.7400-1-andrei.warkentin@intel.com> References: <20230306212615.7400-1-andrei.warkentin@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,andrei.warkentin@intel.com X-Gm-Message-State: RAPEMw6DxrHPnUkNexL29wHDx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678137988; bh=dwNkvWuQEJxbkbmwg7yGQXfPTCygAXBoQdOavUmYK70=; h=Cc:Date:From:Reply-To:Subject:To; b=VinyMkHMufdyoZEU3OKstNQI3e5vAJYI5Su4iR2dcEG/ROHr5zHBpI6gNwYzx0+jNsa v9Z+0hR/FOBaadscEfnjh3GN3+M/qIizVsId7acUXcUljnlagc0CCLNyCdAteeovxJtKg 6Mn70sASgWiZeh3TCPutKemUf1yiPdrBN9Y= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678137989514100005 Content-Type: text/plain; charset="utf-8" ARM64 and X64 may allow such foreign images to be used when driver implementing EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL is present. Cc: Sunil V L Cc: Daniel Schaefer Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Andrei Warkentin --- MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c b/MdePkg/L= ibrary/BasePeCoffLib/RiscV/PeCoffLoaderEx.c index adbfe9ccf580..0e9ee395dc26 100644 --- a/MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c +++ b/MdePkg/Library/BasePeCoffLib/RiscV/PeCoffLoaderEx.c @@ -104,7 +104,14 @@ PeCoffLoaderImageFormatSupported ( IN UINT16 Machine ) { - if (Machine =3D=3D IMAGE_FILE_MACHINE_RISCV64) { + /* + * ARM64 and X64 may allow such foreign images to be used when + * a driver implementing EDKII_PECOFF_IMAGE_EMULATOR_PROTOCOL is + * present. + */ + if (Machine =3D=3D IMAGE_FILE_MACHINE_RISCV64 || + Machine =3D=3D IMAGE_FILE_MACHINE_ARM64 || + Machine =3D=3D IMAGE_FILE_MACHINE_X64) { return TRUE; } =20 --=20 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 (#100761): https://edk2.groups.io/g/devel/message/100761 Mute This Topic: https://groups.io/mt/97436049/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- From nobody Wed May 8 05:52:02 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+100762+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+100762+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1678137989; cv=none; d=zohomail.com; s=zohoarc; b=DhMBoWIkVJAOf9gkyzHEHwE9Q7f8iUtVsCz293TMiY7+wvwV8HM80M8nSQ2Cnm0AayZsPR7gLB79znDz3O9eXPnTv9NQp0h9K1p21iXDMKVdmdo7SPRu8XjSM4IHzP2ecmBMq2PW89VsNlg3MELLO1+P0/w0AHL3zher0Bz8kDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678137989; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Tq/zc7vjAy2RAWM0ZWxD03X1HzeOONtfw6JZUJSyNEI=; b=numzCcC7vOszeYNZpxzs3uxb5r9Pbi5gKXfoArvds20DrvtuMpxdAwnVSDYBNqXqx9HjyFUWqCLQsLKqyInS4H11YErfbB8AD1iQJuzb/SBQJjimv3NzdAM0GVn+Ne5GBuaI5KCMF0DyzmLmgN+6I3P4t0cbbjbTL/9K6PUkY80= 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+100762+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1678137989856273.20903241946974; Mon, 6 Mar 2023 13:26:29 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id RETIYY1788612xohKKXRGT1D; Mon, 06 Mar 2023 13:26:29 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.1898.1678137984252750213 for ; Mon, 06 Mar 2023 13:26:28 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="315335559" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="315335559" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819444260" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="819444260" X-Received: from awarkent-mobl1.amr.corp.intel.com ([10.212.90.17]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:27 -0800 From: "Andrei Warkentin" To: devel@edk2.groups.io Cc: Andrei Warkentin , Daniel Schaefer , Michael D Kinney , Liming Gao , Zhiguang Liu , Sunil V L Subject: [edk2-devel] [edk2 3/7] MdePkg: BaseLib: don't log in RISCV InternalSwitchStack Date: Mon, 6 Mar 2023 15:26:11 -0600 Message-Id: <20230306212615.7400-4-andrei.warkentin@intel.com> In-Reply-To: <20230306212615.7400-1-andrei.warkentin@intel.com> References: <20230306212615.7400-1-andrei.warkentin@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,andrei.warkentin@intel.com X-Gm-Message-State: qv7ygqeTRkBaNePjFW5IolrKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678137989; bh=f8XaLXmuQLtQy9QeErzgZdeFKMsFV7gXwIznFO11cXQ=; h=Cc:Date:From:Reply-To:Subject:To; b=Tj2SXzeADaruycDSeQydTj0pCTb+rOdVAd8LZ+Vz2V6bXv2K2aaM7vNLrEqBeWOR6dA kTXQ/jkhZ0A58F5Il83YX9ccyNjbMEARaN2wIHscLqx7vayYHyGcQ9DDJDw1S/BuCAQUb WUWtJgnqPTVaWfln30VjCk293NDbmFTBI8U= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678137991524100012 Content-Type: text/plain; charset="utf-8" InternalSwitchStack may be called with a TPL high enough for a DebugLib implementation to assert. Other arch implementations don't log either. Cc: Daniel Schaefer Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Reviewed-by: Sunil V L Signed-off-by: Andrei Warkentin --- MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c b/MdePkg/= Library/BaseLib/RiscV64/InternalSwitchStack.c index cf646e498aba..b78424c16383 100644 --- a/MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c +++ b/MdePkg/Library/BaseLib/RiscV64/InternalSwitchStack.c @@ -44,14 +44,6 @@ InternalSwitchStack ( { BASE_LIBRARY_JUMP_BUFFER JumpBuffer; =20 - DEBUG (( - DEBUG_INFO, - "RISC-V InternalSwitchStack Entry:%x Context1:%x Context2:%x NewStack%= x\n", \ - EntryPoint, - Context1, - Context2, - NewStack - )); JumpBuffer.RA =3D (UINTN)EntryPoint; JumpBuffer.SP =3D (UINTN)NewStack - sizeof (VOID *); JumpBuffer.S0 =3D (UINT64)(UINTN)Context1; --=20 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 (#100762): https://edk2.groups.io/g/devel/message/100762 Mute This Topic: https://groups.io/mt/97436050/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- From nobody Wed May 8 05:52:02 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+100763+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+100763+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1678137990; cv=none; d=zohomail.com; s=zohoarc; b=aaCo3Mb/Ver7UzKYnV+WeBYekxSyl3xkelMReu34trngFvQ54Su9RbA9xYhAh35wi/EUhR8zh/Xn+GxRHAtaOmxdIYG4ZgrTVKvQX9+VZc0X7KT0bMusYD46e2bYP9uRqODdGAU2UIoXXYIqHN8OmfyLhUrw9GoY6OTXSB6rry0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678137990; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=JArilGT6+oQEuBJnmWhthEXfwez0scphvxaIimkR7vI=; b=myjAecGvUG19AmvlRbFPHX9GlRYEIsiWBdhU0gUM8kqN+BWsddCbHKjFgj0JEkgmX42yPyAYP72R7MqXWI13dbypZfBF4I5mQhkDvr7oLUdTnjeTdTU4Kw8Pk+G2KvCQLos186yZkQWuQTsUA7U0BiIxzLXsU91TvzAcQlnyb78= 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+100763+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1678137990645605.1519477629718; Mon, 6 Mar 2023 13:26:30 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id tsShYY1788612xQd84W3Hjo1; Mon, 06 Mar 2023 13:26:30 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.1898.1678137984252750213 for ; Mon, 06 Mar 2023 13:26:28 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="315335571" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="315335571" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819444264" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="819444264" X-Received: from awarkent-mobl1.amr.corp.intel.com ([10.212.90.17]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:27 -0800 From: "Andrei Warkentin" To: devel@edk2.groups.io Cc: Andrei Warkentin , Daniel Schaefer , Michael D Kinney , Liming Gao , Zhiguang Liu , Sunil V L Subject: [edk2-devel] [edk2 4/7] MdePkg: BaseCpuLib: Fix RISCV CpuSleep symbol name. Date: Mon, 6 Mar 2023 15:26:12 -0600 Message-Id: <20230306212615.7400-5-andrei.warkentin@intel.com> In-Reply-To: <20230306212615.7400-1-andrei.warkentin@intel.com> References: <20230306212615.7400-1-andrei.warkentin@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,andrei.warkentin@intel.com X-Gm-Message-State: 7cYklgTWsTlKO9e3yxys6utKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678137990; bh=a/J/qrf7SSm53kyZizCJExCvv5ShBa0obH2BUdFQmmM=; h=Cc:Date:From:Reply-To:Subject:To; b=w7DuZ+H5kjNNCvaLjMj8RdCxyryBlBIejbON7fYAzlFyB4o+x8KVl+7vcfX+kZujkCQ yj4d2WLOo9HDDFmnCN35gSE5YaFSSbhHzFFfXttGM5yyUGo8GhBYa5IkY5hBrOXLUXNyz RJPQjJ5tsm85Ww0K1vCOQYhJ3OCbei5+5cs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678137991527100015 Content-Type: text/plain; charset="utf-8" CpuSleep, not _CpuSleep. Cc: Daniel Schaefer Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Reviewed-by: Sunil V L Signed-off-by: Andrei Warkentin --- MdePkg/Library/BaseCpuLib/RiscV/Cpu.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MdePkg/Library/BaseCpuLib/RiscV/Cpu.S b/MdePkg/Library/BaseCpu= Lib/RiscV/Cpu.S index 375b91d31427..d6560087e080 100644 --- a/MdePkg/Library/BaseCpuLib/RiscV/Cpu.S +++ b/MdePkg/Library/BaseCpuLib/RiscV/Cpu.S @@ -10,9 +10,9 @@ .align 3 .section .text =20 -.global ASM_PFX(_CpuSleep) +.global ASM_PFX(CpuSleep) =20 -ASM_PFX(_CpuSleep): +ASM_PFX(CpuSleep): wfi ret =20 --=20 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 (#100763): https://edk2.groups.io/g/devel/message/100763 Mute This Topic: https://groups.io/mt/97436051/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- From nobody Wed May 8 05:52:02 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+100764+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+100764+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1678137991; cv=none; d=zohomail.com; s=zohoarc; b=c9Qoe+Q9U4W256kBKyYdWUP0KB4qnNmZxdp3giB9/2hwpHv7MU5c4//+ZXhYte63Bb5nmfTaL9EEqjvg6xkaeWK6eVBSrreAfr1Q1XHg22DrCPCNsEbj21qvrgaR7rsMuIrpnHaH0TC7zlbbhQNotdFlT4Y+XytGJb6SfNjJyE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678137991; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=1bb/xJO4u+WUpdVsckjTO0fOwjqPg0Lm9Rqltb6UR5s=; b=WarUL98NPfuLPVQ16cYjfVn67sfvH1Ff/5Y+SHNxrHkmaCToQMkSS/yyx1HqBSX1a43uhAlf1HxhqB84TIOar7N+mHZYj3hHBoCVng8uH0iPP7sKBY547c+/YAIpzh0HYnMGe2hDjejoQ5DD6dys9oh1MdbeQOLT9O8qCOgrWnE= 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+100764+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16781379910601012.5690867531066; Mon, 6 Mar 2023 13:26:31 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id m939YY1788612xdlinWf5cau; Mon, 06 Mar 2023 13:26:30 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.1898.1678137984252750213 for ; Mon, 06 Mar 2023 13:26:29 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="315335585" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="315335585" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819444270" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="819444270" X-Received: from awarkent-mobl1.amr.corp.intel.com ([10.212.90.17]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:28 -0800 From: "Andrei Warkentin" To: devel@edk2.groups.io Cc: Andrei Warkentin , Daniel Schaefer , Liming Gao , Jian J Wang , Sunil V L Subject: [edk2-devel] [edk2 5/7] MdeModulePkg: Dxe: add RISCV64 to mMachineTypeInfo Date: Mon, 6 Mar 2023 15:26:13 -0600 Message-Id: <20230306212615.7400-6-andrei.warkentin@intel.com> In-Reply-To: <20230306212615.7400-1-andrei.warkentin@intel.com> References: <20230306212615.7400-1-andrei.warkentin@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,andrei.warkentin@intel.com X-Gm-Message-State: QRcneCjxOrZUqWe3WzhIzIRkx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678137990; bh=njfkIV/3CLNbqvKY7B6Xc7UjIaPGSfFJLGWN1mRjOz8=; h=Cc:Date:From:Reply-To:Subject:To; b=O+sj9qHxbSZZJnWBVQAt1zG7p/5p7vaL3OCx43g7NsRC5xm2ivxxrHqxNUPehbmRY9x y66iGaJJWNshxTW3+Jalb7BA5bfKvpNLqfWQru15bW2kFJzgGgDO3wKyhQVh+de/Srhy4 kgXF/I7oikbAQS4+jcwJt5AcgevwqHnw5Cg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678137993536100021 Content-Type: text/plain; charset="utf-8" This fixes messages like: "Image type AARCH64 can't be loaded on UEFI system" Cc: Daniel Schaefer Cc: Liming Gao Cc: Jian J Wang Reviewed-by: Sunil V L Signed-off-by: Andrei Warkentin --- MdeModulePkg/Core/Dxe/Image/Image.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Im= age/Image.c index 06cc6744b8c6..8704ebea9a7c 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -81,7 +81,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED MACHINE_TYPE_INFO mMachine= TypeInfo[] =3D { { EFI_IMAGE_MACHINE_IA64, L"IA64" }, { EFI_IMAGE_MACHINE_X64, L"X64" }, { EFI_IMAGE_MACHINE_ARMTHUMB_MIXED, L"ARM" }, - { EFI_IMAGE_MACHINE_AARCH64, L"AARCH64" } + { EFI_IMAGE_MACHINE_AARCH64, L"AARCH64" }, + { EFI_IMAGE_MACHINE_RISCV64, L"RISCV64" }, }; =20 UINT16 mDxeCoreImageMachineType =3D 0; --=20 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 (#100764): https://edk2.groups.io/g/devel/message/100764 Mute This Topic: https://groups.io/mt/97436052/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- From nobody Wed May 8 05:52:02 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+100765+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+100765+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1678137991; cv=none; d=zohomail.com; s=zohoarc; b=Aa1uEGd3Ft7oaGK4FDGsb+nq+csAnxeSAEJClQoHEGNvCwrm+yhH7NxKjBM6m3ATtIuOVzU1QLKQm/truOclbnrEnllg+bAvvlVDWifDAY0n79e2535qmzEZoPex+l+uyaQhiXtZC01DMtEfCsjBx8S31ECqF47eAohnWDRS0dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678137991; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=4lrZmj7EOAZXUU3MpGJwlZjA6WTxbeD35MyajY5dXwY=; b=MChISjU8TlN0T+J6bEkVPCaU+raLEoUwTYFQlgsUvpnEgpUH7sjJvxUoAL4NIqgWYsfzvZJ2u1F6JJ+5P99S3RQqx8S31p17SqPKNUWs/zcXaMqrW9pIAxyaLesivZtze+w5TXaVepQXjmFg+B7aSXQQmAGnVFtsNJGhOQzzT9c= 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+100765+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 167813799191085.12307412359053; Mon, 6 Mar 2023 13:26:31 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id UsAqYY1788612xq2iBMMaNJN; Mon, 06 Mar 2023 13:26:31 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.1898.1678137984252750213 for ; Mon, 06 Mar 2023 13:26:29 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="315335591" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="315335591" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819444273" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="819444273" X-Received: from awarkent-mobl1.amr.corp.intel.com ([10.212.90.17]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:29 -0800 From: "Andrei Warkentin" To: devel@edk2.groups.io Cc: Andrei Warkentin , Daniel Schaefer , Sunil V L Subject: [edk2-devel] [edk2 6/7] [PATCH v2] UefiCpuPkg: CpuTimerDxeRiscV64: fix tick duration accounting Date: Mon, 6 Mar 2023 15:26:14 -0600 Message-Id: <20230306212615.7400-7-andrei.warkentin@intel.com> In-Reply-To: <20230306212615.7400-1-andrei.warkentin@intel.com> References: <20230306212615.7400-1-andrei.warkentin@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,andrei.warkentin@intel.com X-Gm-Message-State: d1YUgT0Xx8LZu1SxjJbeMy4xx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678137991; bh=9h+FSTN9gVuoM1HjtFvdR1fzUQoW222QLhSAQIKoJaA=; h=Cc:Date:From:Reply-To:Subject:To; b=ixQAtYTVZT8UsUgtE0La6nYFFicDad4aTVlpECLHfA47UcPREyMHCtNpRIldu0R0hN0 Di1ElTF4UVHGjHrSjZts3dbolcMKvsP//QhqS+PCjjyVDa7rhFGmziPEKJjwBF8vcVBEK 4t9/jX9KuKin3xDsKSvw3pCV4OjEW4zCH0o= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678137993557100024 Content-Type: text/plain; charset="utf-8" The TimerDxe implementation doesn't account for the physical time passed due to timer handler execution or (perhaps even more importantly) time spent with interrupts masked. Other implementations (e.g. like the Arm one) do. If the timer tick is always incremented at a fixed rate, then you can slow down UEFI's perception of time by running long sections of code in a critical section. Cc: Daniel Schaefer Reviewed-by: Sunil V L Signed-off-by: Andrei Warkentin --- UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c | 33 +++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c b/UefiCpuPkg/CpuTimerDxe= RiscV64/Timer.c index db153f715e60..50f57a9780f0 100644 --- a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c @@ -40,7 +40,8 @@ STATIC EFI_TIMER_NOTIFY mTimerNotifyFunction; // // The current period of the timer interrupt // -STATIC UINT64 mTimerPeriod =3D 0; +STATIC UINT64 mTimerPeriod =3D 0; +STATIC UINT64 mLastPeriodStart =3D 0; =20 /** Timer Interrupt Handler. @@ -56,25 +57,31 @@ TimerInterruptHandler ( ) { EFI_TPL OriginalTPL; - UINT64 RiscvTimer; + UINT64 PeriodStart =3D RiscVReadTimer (); =20 OriginalTPL =3D gBS->RaiseTPL (TPL_HIGH_LEVEL); if (mTimerNotifyFunction !=3D NULL) { - mTimerNotifyFunction (mTimerPeriod); + // + // For any number of reasons, the ticks could be coming + // in slower than mTimerPeriod. For example, some code + // is doing a *lot* of stuff inside an EFI_TPL_HIGH + // critical section, and this should not cause the EFI + // time to increment slower. So when we take an interrupt, + // account for the actual time passed. + // + mTimerNotifyFunction (PeriodStart - mLastPeriodStart); } =20 - RiscVDisableTimerInterrupt (); // Disable SMode timer int - RiscVClearPendingTimerInterrupt (); if (mTimerPeriod =3D=3D 0) { + RiscVDisableTimerInterrupt (); gBS->RestoreTPL (OriginalTPL); - RiscVDisableTimerInterrupt (); // Disable SMode timer int return; } =20 - RiscvTimer =3D RiscVReadTimer (); - SbiSetTimer (RiscvTimer +=3D mTimerPeriod); + mLastPeriodStart =3D PeriodStart; + SbiSetTimer (PeriodStart +=3D mTimerPeriod); + RiscVEnableTimerInterrupt (); // enable SMode timer int gBS->RestoreTPL (OriginalTPL); - RiscVEnableTimerInterrupt (); // enable SMode timer int } =20 /** @@ -154,8 +161,6 @@ TimerDriverSetTimerPeriod ( IN UINT64 TimerPeriod ) { - UINT64 RiscvTimer; - DEBUG ((DEBUG_INFO, "TimerDriverSetTimerPeriod(0x%lx)\n", TimerPeriod)); =20 if (TimerPeriod =3D=3D 0) { @@ -164,9 +169,9 @@ TimerDriverSetTimerPeriod ( return EFI_SUCCESS; } =20 - mTimerPeriod =3D TimerPeriod / 10; // convert unit from 100ns to 1us - RiscvTimer =3D RiscVReadTimer (); - SbiSetTimer (RiscvTimer + mTimerPeriod); + mTimerPeriod =3D TimerPeriod / 10; // convert unit from 100ns to 1us + mLastPeriodStart =3D RiscVReadTimer (); + SbiSetTimer (mLastPeriodStart + mTimerPeriod); =20 mCpu->EnableInterrupt (mCpu); RiscVEnableTimerInterrupt (); // enable SMode timer int --=20 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 (#100765): https://edk2.groups.io/g/devel/message/100765 Mute This Topic: https://groups.io/mt/97436053/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- From nobody Wed May 8 05:52:02 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+100766+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+100766+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1678137992; cv=none; d=zohomail.com; s=zohoarc; b=Ame/lPiyaaH5GbLeL8zseh+BibMAN7zDWzSQXyMq33oXYQTPG3cmhhED2xrW5R9TOxpn93d3K4+wbRG+3IZGBwkJnyGJikuHmLhcwnaQyxPlEFZucPlP/JGlS2eBD5QYw8+3E4TVvs5WzqQBJCCXdiQhX8vipiU71lNiI6VfvPY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678137992; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=eIcWBCJj4jxq2DMPwYwlS2mBtoQoMnKyKFWfgiKq4fg=; b=firyUs6u66kuxViWR62bssOw9fvHrqHs0bbsU+cq9/K3PeszgjneNySCtrH0YBEQ8sooF5DnSrG3Z6i0B43HKP2R4WZzsS3Ox2YBeAUc4RX8NcsqPYm4r+ZJYFk8FuGvJpTV7YLjCVwqvRyx6tTJHpnx4yFL/rZJVZeSEZwjiTk= 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+100766+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1678137992583881.487990397701; Mon, 6 Mar 2023 13:26:32 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id zzgdYY1788612xnwkkMlQOKG; Mon, 06 Mar 2023 13:26:32 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.1898.1678137984252750213 for ; Mon, 06 Mar 2023 13:26:30 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="315335600" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="315335600" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10641"; a="819444276" X-IronPort-AV: E=Sophos;i="5.98,238,1673942400"; d="scan'208";a="819444276" X-Received: from awarkent-mobl1.amr.corp.intel.com ([10.212.90.17]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2023 13:26:29 -0800 From: "Andrei Warkentin" To: devel@edk2.groups.io Cc: Andrei Warkentin , Daniel Schaefer , Sunil V L Subject: [edk2-devel] [edk2 7/7] [PATCH v3] UefiCpuPkg: BaseRiscV64CpuExceptionHandlerLib: clean up exception handling Date: Mon, 6 Mar 2023 15:26:15 -0600 Message-Id: <20230306212615.7400-8-andrei.warkentin@intel.com> In-Reply-To: <20230306212615.7400-1-andrei.warkentin@intel.com> References: <20230306212615.7400-1-andrei.warkentin@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,andrei.warkentin@intel.com X-Gm-Message-State: 9mVSVFrt9ADvyFo0tKuCOC57x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678137992; bh=/6NtVyvj5W9dtHemK+jvtpymvq573InBlZjSjt5KBYA=; h=Cc:Date:From:Reply-To:Subject:To; b=ju+55X/AIC/D5/LZen3Zv/jZV9jjNaGUINSFMAzc4K6BnOrqcdsxQgf9NqrsJO8lmsz qbb5rnbfxYSp/Xf0nvciQwW7PruhxYqKrYXh6dXks43c1xa34zC+yQ7JzDyr7EsC/AI+t 095xH4fVPc/7fElRdrFLILJ2tSp5Z7IJ9rI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678137993615100028 Content-Type: text/plain; charset="utf-8" RegisterCpuInterruptHandler did not allow setting exception handlers for anything beyond the timer IRQ. Beyond that, it didn't meet the spec around handling of inputs. RiscVSupervisorModeTrapHandler now will invoke set handlers for both exceptions and interrupts. Two arrays of handlers are maintained - one for exceptions and one for interrupts. For unhandled traps, RiscVSupervisorModeTrapHandler dumps state using the now implemented DumpCpuContext. For EFI_SYSTEM_CONTEXT_RISCV64, extend this with the trapped PC address (SEPC), just like on AArch64 (ELR). This is necessary for X86EmulatorPkg to work as it allows a trap handler to return execution to a different place. Add SSTATUS/STVAL as well, at least for debugging purposes. There is no value in hiding this. Fix nested exception handling. Handler code should not be saving SIE (the value is saved in SSTATUS.SPIE) or directly restored (that's done by SRET). Save and restore the entire SSTATUS and STVAL, too. Cc: Daniel Schaefer Reviewed-by: Sunil V L Signed-off-by: Andrei Warkentin --- MdePkg/Include/Protocol/DebugSupport.h = | 32 ++- UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuExceptionHandlerLi= b.h | 11 +- UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c = | 6 +- UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuExceptionHandlerLi= b.c | 235 ++++++++++++++++++-- UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/SupervisorTrapHandler= .S | 17 +- 5 files changed, 257 insertions(+), 44 deletions(-) diff --git a/MdePkg/Include/Protocol/DebugSupport.h b/MdePkg/Include/Protoc= ol/DebugSupport.h index 2b0ae2d1577b..9742663619c5 100644 --- a/MdePkg/Include/Protocol/DebugSupport.h +++ b/MdePkg/Include/Protocol/DebugSupport.h @@ -613,11 +613,34 @@ typedef struct { #define EXCEPT_RISCV_STORE_AMO_ACCESS_FAULT 7 #define EXCEPT_RISCV_ENV_CALL_FROM_UMODE 8 #define EXCEPT_RISCV_ENV_CALL_FROM_SMODE 9 -#define EXCEPT_RISCV_ENV_CALL_FROM_HMODE 10 +#define EXCEPT_RISCV_ENV_CALL_FROM_VS_MODE 10 #define EXCEPT_RISCV_ENV_CALL_FROM_MMODE 11 +#define EXCEPT_RISCV_INST_ACCESS_PAGE_FAULT 12 +#define EXCEPT_RISCV_LOAD_ACCESS_PAGE_FAULT 13 +#define EXCEPT_RISCV_14 14 +#define EXCEPT_RISCV_STORE_ACCESS_PAGE_FAULT 15 +#define EXCEPT_RISCV_16 16 +#define EXCEPT_RISCV_17 17 +#define EXCEPT_RISCV_18 18 +#define EXCEPT_RISCV_19 19 +#define EXCEPT_RISCV_INST_GUEST_PAGE_FAULT 20 +#define EXCEPT_RISCV_LOAD_GUEST_PAGE_FAULT 21 +#define EXCEPT_RISCV_VIRTUAL_INSTRUCTION 22 +#define EXCEPT_RISCV_STORE_GUEST_PAGE_FAULT 23 +#define EXCEPT_RISCV_MAX_EXCEPTIONS (EXCEPT_RISCV_STORE_GUE= ST_PAGE_FAULT) =20 -#define EXCEPT_RISCV_SOFTWARE_INT 0x0 -#define EXCEPT_RISCV_TIMER_INT 0x1 +/// +/// RISC-V processor exception types for interrupts. +/// +#define EXCEPT_RISCV_IS_IRQ(x) ((x & 0x8000000000000000UL) !=3D 0) +#define EXCEPT_RISCV_IRQ_INDEX(x) (x & 0x7FFFFFFFFFFFFFFFUL) +#define EXCEPT_RISCV_IRQ_0 0x8000000000000000UL +#define EXCEPT_RISCV_IRQ_SOFT_FROM_SMODE 0x8000000000000001UL +#define EXCEPT_RISCV_IRQ_SOFT_FROM_VSMODE 0x8000000000000002UL +#define EXCEPT_RISCV_IRQ_SOFT_FROM_MMODE 0x8000000000000003UL +#define EXCEPT_RISCV_IRQ_4 0x8000000000000004UL +#define EXCEPT_RISCV_IRQ_TIMER_FROM_SMODE 0x8000000000000005UL +#define EXCEPT_RISCV_MAX_IRQS (EXCEPT_RISCV_IRQ_INDEX(EXCEPT_= RISCV_IRQ_TIMER_FROM_SMODE)) =20 typedef struct { UINT64 X0; @@ -652,6 +675,9 @@ typedef struct { UINT64 X29; UINT64 X30; UINT64 X31; + UINT64 SEPC; + UINT32 SSTATUS; + UINT32 STVAL; } EFI_SYSTEM_CONTEXT_RISCV64; =20 // diff --git a/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuExcept= ionHandlerLib.h b/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuE= xceptionHandlerLib.h index 30f47e87552b..9b7e1304dd3b 100644 --- a/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuExceptionHand= lerLib.h +++ b/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuExceptionHand= lerLib.h @@ -59,7 +59,7 @@ SupervisorModeTrap ( #define SMODE_TRAP_REGS_t6 31 #define SMODE_TRAP_REGS_sepc 32 #define SMODE_TRAP_REGS_sstatus 33 -#define SMODE_TRAP_REGS_sie 34 +#define SMODE_TRAP_REGS_stval 34 #define SMODE_TRAP_REGS_last 35 =20 #define SMODE_TRAP_REGS_OFFSET(x) ((SMODE_TRAP_REGS_##x) * __SIZEOF_POINT= ER__) @@ -68,7 +68,7 @@ SupervisorModeTrap ( #pragma pack(1) typedef struct { // - // Below are follow the format of EFI_SYSTEM_CONTEXT + // Below follow the format of EFI_SYSTEM_CONTEXT. // UINT64 zero; UINT64 ra; @@ -102,14 +102,9 @@ typedef struct { UINT64 t4; UINT64 t5; UINT64 t6; - // - // Below are the additional information to - // EFI_SYSTEM_CONTEXT, private to supervisor mode trap - // and not public to EFI environment. - // UINT64 sepc; UINT64 sstatus; - UINT64 sie; + UINT64 stval; } SMODE_TRAP_REGISTERS; #pragma pack() =20 diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c b/UefiCpuPkg/CpuTimerDxe= RiscV64/Timer.c index 50f57a9780f0..ab280d3b2d7d 100644 --- a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c +++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c @@ -276,7 +276,11 @@ TimerDriverInitialize ( // // Install interrupt handler for RISC-V Timer. // - Status =3D mCpu->RegisterInterruptHandler (mCpu, EXCEPT_RISCV_TIMER_INT,= TimerInterruptHandler); + Status =3D mCpu->RegisterInterruptHandler ( + mCpu, + EXCEPT_RISCV_IRQ_TIMER_FROM_SMODE, + TimerInterruptHandler + ); ASSERT_EFI_ERROR (Status); =20 // diff --git a/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuExcept= ionHandlerLib.c b/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuE= xceptionHandlerLib.c index f1ee7d236aec..80869a1c1bff 100644 --- a/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuExceptionHand= lerLib.c +++ b/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/CpuExceptionHand= lerLib.c @@ -11,11 +11,166 @@ #include #include #include +#include +#include #include - #include "CpuExceptionHandlerLib.h" =20 -STATIC EFI_CPU_INTERRUPT_HANDLER mInterruptHandlers[2]; +// +// Define the maximum message length +// +#define MAX_DEBUG_MESSAGE_LENGTH 0x100 + +STATIC EFI_CPU_INTERRUPT_HANDLER mExceptionHandlers[EXCEPT_RISCV_MAX_EXCE= PTIONS + 1]; +STATIC EFI_CPU_INTERRUPT_HANDLER mIrqHandlers[EXCEPT_RISCV_MAX_IRQS + 1]; + +STATIC CONST CHAR8 mExceptionOrIrqUnknown[] = =3D "Unknown"; +STATIC CONST CHAR8 *mExceptionNameStr[EXCEPT_RISCV_MAX_EXCEPTIONS + 1] = =3D { + "EXCEPT_RISCV_INST_MISALIGNED", + "EXCEPT_RISCV_INST_ACCESS_FAULT", + "EXCEPT_RISCV_ILLEGAL_INST", + "EXCEPT_RISCV_BREAKPOINT", + "EXCEPT_RISCV_LOAD_ADDRESS_MISALIGNED", + "EXCEPT_RISCV_LOAD_ACCESS_FAULT", + "EXCEPT_RISCV_STORE_AMO_ADDRESS_MISALIGNED", + "EXCEPT_RISCV_STORE_AMO_ACCESS_FAULT", + "EXCEPT_RISCV_ENV_CALL_FROM_UMODE", + "EXCEPT_RISCV_ENV_CALL_FROM_SMODE", + "EXCEPT_RISCV_ENV_CALL_FROM_VS_MODE", + "EXCEPT_RISCV_ENV_CALL_FROM_MMODE", + "EXCEPT_RISCV_INST_ACCESS_PAGE_FAULT", + "EXCEPT_RISCV_LOAD_ACCESS_PAGE_FAULT", + "EXCEPT_RISCV_14", + "EXCEPT_RISCV_STORE_ACCESS_PAGE_FAULT", + "EXCEPT_RISCV_16", + "EXCEPT_RISCV_17", + "EXCEPT_RISCV_18", + "EXCEPT_RISCV_19", + "EXCEPT_RISCV_INST_GUEST_PAGE_FAULT", + "EXCEPT_RISCV_LOAD_GUEST_PAGE_FAULT", + "EXCEPT_RISCV_VIRTUAL_INSTRUCTION", + "EXCEPT_RISCV_STORE_GUEST_PAGE_FAULT" +}; + +STATIC CONST CHAR8 *mIrqNameStr[EXCEPT_RISCV_MAX_IRQS + 1] =3D { + "EXCEPT_RISCV_IRQ_0", + "EXCEPT_RISCV_IRQ_SOFT_FROM_SMODE", + "EXCEPT_RISCV_IRQ_SOFT_FROM_VSMODE", + "EXCEPT_RISCV_IRQ_SOFT_FROM_MMODE", + "EXCEPT_RISCV_IRQ_4", + "EXCEPT_RISCV_IRQ_TIMER_FROM_SMODE", +}; + +/** + Prints a message to the serial port. + + @param Format Format string for the message to print. + @param ... Variable argument list whose contents are accessed + based on the format string specified by Format. + +**/ +STATIC +VOID +EFIAPI +InternalPrintMessage ( + IN CONST CHAR8 *Format, + ... + ) +{ + CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH]; + VA_LIST Marker; + + // + // Convert the message to an ASCII String + // + VA_START (Marker, Format); + AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker); + VA_END (Marker); + + // + // Send the print string to a Serial Port + // + SerialPortWrite ((UINT8 *)Buffer, AsciiStrLen (Buffer)); +} + +/** + Get ASCII format string exception name by exception type. + + @param ExceptionType Exception type. + + @return ASCII format string exception name. +**/ +STATIC +CONST CHAR8 * +GetExceptionNameStr ( + IN EFI_EXCEPTION_TYPE ExceptionType + ) +{ + if (EXCEPT_RISCV_IS_IRQ (ExceptionType)) { + if (EXCEPT_RISCV_IRQ_INDEX (ExceptionType) > EXCEPT_RISCV_MAX_IRQS) { + return mExceptionOrIrqUnknown; + } + + return mIrqNameStr[EXCEPT_RISCV_IRQ_INDEX (ExceptionType)]; + } + + if (ExceptionType > EXCEPT_RISCV_MAX_EXCEPTIONS) { + return mExceptionOrIrqUnknown; + } + + return mExceptionNameStr[ExceptionType]; +} + +/** + Display CPU information. This can be called by 3rd-party handlers + set by RegisterCpuInterruptHandler. + + @param ExceptionType Exception type. + @param SystemContext Pointer to EFI_SYSTEM_CONTEXT. +**/ +VOID +EFIAPI +DumpCpuContext ( + IN EFI_EXCEPTION_TYPE ExceptionType, + IN EFI_SYSTEM_CONTEXT SystemContext + ) +{ + UINTN Printed =3D 0; + SMODE_TRAP_REGISTERS *Regs =3D (SMODE_TRAP_REGISTERS *) + SystemContext.SystemContextRiscV64; + + InternalPrintMessage ( + "!!!! RISCV64 Exception Type - %016x(%a) !!!!\n", + ExceptionType, + GetExceptionNameStr (ExceptionType) + ); + + DEBUG_CODE_BEGIN (); + + #define REGS() \ + REG (t0); REG (t1); REG (t2); REG (t3); REG (t4); REG (t5); REG (t6); \ + REG (s0); REG (s1); REG (s2); REG (s3); REG (s4); REG (s5); REG (s6); \ + REG (s7); REG (s8); REG (s9); REG (s10); REG (s11); \ + REG (a0); REG (a1); REG (a2); REG (a3); REG (a4); REG (a5); REG (a6); \ + REG (a7); \ + REG (zero); REG (ra); REG (sp); REG (gp); REG (tp); \ + REG (sepc); REG (sstatus); REG (stval); + + #define REG(x) do { \ + InternalPrintMessage ("%7a =3D 0x%017lx%c", #x, Regs->x, \ + (++Printed % 2) ? L'\t' : L'\n'); \ + } while (0); + + REGS (); + if (Printed % 2) { + InternalPrintMessage ("\n"); + } + + #undef REG + #undef REGS + + DEBUG_CODE_END (); +} =20 /** Initializes all CPU exceptions entries and provides the default exceptio= n handlers. @@ -47,34 +202,59 @@ InitializeCpuExceptionHandlers ( Registers a function to be called from the processor interrupt handler. =20 This function registers and enables the handler specified by InterruptHa= ndler for a processor - interrupt or exception type specified by InterruptType. If InterruptHand= ler is NULL, then the - handler for the processor interrupt or exception type specified by Inter= ruptType is uninstalled. + interrupt or exception type specified by ExceptionType. If InterruptHand= ler is NULL, then the + handler for the processor interrupt or exception type specified by Excep= tionType is uninstalled. The installed handler is called once for each processor interrupt or exc= eption. NOTE: This function should be invoked after InitializeCpuExceptionHandle= rs() or InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED retu= rned. =20 - @param[in] InterruptType Defines which interrupt or exception to ho= ok. + @param[in] ExceptionType Defines which interrupt or exception to ho= ok. @param[in] InterruptHandler A pointer to a function of type EFI_CPU_IN= TERRUPT_HANDLER that is called when a processor interrupt occurs. If this= parameter is NULL, then the handler will be uninstalled. =20 @retval EFI_SUCCESS The handler for the processor interrupt wa= s successfully installed or uninstalled. - @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handle= r for InterruptType was + @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handle= r for ExceptionType was previously installed. - @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler fo= r InterruptType was not + @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler fo= r ExceptionType was not previously installed. - @retval EFI_UNSUPPORTED The interrupt specified by InterruptType i= s not supported, + @retval EFI_UNSUPPORTED The interrupt specified by ExceptionType i= s not supported, or this function is not supported. **/ EFI_STATUS EFIAPI RegisterCpuInterruptHandler ( - IN EFI_EXCEPTION_TYPE InterruptType, + IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler ) { - DEBUG ((DEBUG_INFO, "%a: Type:%x Handler: %x\n", __FUNCTION__, Interrupt= Type, InterruptHandler)); - mInterruptHandlers[InterruptType] =3D InterruptHandler; + DEBUG ((DEBUG_INFO, "%a: Type:%x Handler: %x\n", __FUNCTION__, Exception= Type, InterruptHandler)); + if (EXCEPT_RISCV_IS_IRQ (ExceptionType)) { + if (EXCEPT_RISCV_IRQ_INDEX (ExceptionType) > EXCEPT_RISCV_MAX_IRQS) { + return EFI_UNSUPPORTED; + } + + if (mIrqHandlers[EXCEPT_RISCV_IRQ_INDEX (ExceptionType)] !=3D NULL) { + return EFI_ALREADY_STARTED; + } else if (InterruptHandler =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + mIrqHandlers[EXCEPT_RISCV_IRQ_INDEX (ExceptionType)] =3D InterruptHand= ler; + } else { + if (ExceptionType > EXCEPT_RISCV_MAX_EXCEPTIONS) { + return EFI_UNSUPPORTED; + } + + if (mExceptionHandlers[ExceptionType] !=3D NULL) { + return EFI_ALREADY_STARTED; + } else if (InterruptHandler =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + mExceptionHandlers[ExceptionType] =3D InterruptHandler; + } + return EFI_SUCCESS; } =20 @@ -113,21 +293,30 @@ RiscVSupervisorModeTrapHandler ( SMODE_TRAP_REGISTERS *SmodeTrapReg ) { - UINTN SCause; + EFI_EXCEPTION_TYPE ExceptionType; EFI_SYSTEM_CONTEXT RiscVSystemContext; =20 RiscVSystemContext.SystemContextRiscV64 =3D (EFI_SYSTEM_CONTEXT_RISCV64 = *)SmodeTrapReg; - // - // Check scasue register. - // - SCause =3D (UINTN)RiscVGetSupervisorTrapCause (); - if ((SCause & (1UL << (sizeof (UINTN) * 8- 1))) !=3D 0) { - // - // This is interrupt event. - // - SCause &=3D ~(1UL << (sizeof (UINTN) * 8- 1)); - if ((SCause =3D=3D IRQ_S_TIMER) && (mInterruptHandlers[EXCEPT_RISCV_TI= MER_INT] !=3D NULL)) { - mInterruptHandlers[EXCEPT_RISCV_TIMER_INT](EXCEPT_RISCV_TIMER_INT, R= iscVSystemContext); + ExceptionType =3D (UINTN)RiscVGetSupervisorTra= pCause (); + + if (EXCEPT_RISCV_IS_IRQ (ExceptionType)) { + UINTN IrqIndex =3D EXCEPT_RISCV_IRQ_INDEX (ExceptionType); + + if ((IrqIndex <=3D EXCEPT_RISCV_MAX_IRQS) && + (mIrqHandlers[IrqIndex] !=3D NULL)) + { + mIrqHandlers[IrqIndex](ExceptionType, RiscVSystemContext); + return; + } + } else { + if ((ExceptionType <=3D EXCEPT_RISCV_MAX_EXCEPTIONS) && + (mExceptionHandlers[ExceptionType] !=3D 0)) + { + mExceptionHandlers[ExceptionType](ExceptionType, RiscVSystemContext); + return; } } + + DumpCpuContext (ExceptionType, RiscVSystemContext); + CpuDeadLoop (); } diff --git a/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/Superviso= rTrapHandler.S b/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/Super= visorTrapHandler.S index 649c4c5becf4..45070b5cda04 100644 --- a/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/SupervisorTrapHa= ndler.S +++ b/UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/SupervisorTrapHa= ndler.S @@ -20,14 +20,14 @@ SupervisorModeTrap: sd t0, SMODE_TRAP_REGS_OFFSET(t0)(sp) =20 csrr t0, CSR_SSTATUS - and t0, t0, (SSTATUS_SIE | SSTATUS_SPIE) sd t0, SMODE_TRAP_REGS_OFFSET(sstatus)(sp) csrr t0, CSR_SEPC sd t0, SMODE_TRAP_REGS_OFFSET(sepc)(sp) - csrr t0, CSR_SIE - sd t0, SMODE_TRAP_REGS_OFFSET(sie)(sp) + csrr t0, CSR_STVAL + sd t0, SMODE_TRAP_REGS_OFFSET(stval)(sp) ld t0, SMODE_TRAP_REGS_OFFSET(t0)(sp) =20 + sd zero, SMODE_TRAP_REGS_OFFSET(zero)(sp) sd ra, SMODE_TRAP_REGS_OFFSET(ra)(sp) sd gp, SMODE_TRAP_REGS_OFFSET(gp)(sp) sd tp, SMODE_TRAP_REGS_OFFSET(tp)(sp) @@ -59,6 +59,7 @@ SupervisorModeTrap: sd t6, SMODE_TRAP_REGS_OFFSET(t6)(sp) =20 /* Call to Supervisor mode trap handler in CpuExceptionHandlerLib.c */ + mv a0, sp call RiscVSupervisorModeTrapHandler =20 /* Restore all general regisers except SP */ @@ -66,6 +67,7 @@ SupervisorModeTrap: ld gp, SMODE_TRAP_REGS_OFFSET(gp)(sp) ld tp, SMODE_TRAP_REGS_OFFSET(tp)(sp) ld t2, SMODE_TRAP_REGS_OFFSET(t2)(sp) + ld t1, SMODE_TRAP_REGS_OFFSET(t1)(sp) ld s0, SMODE_TRAP_REGS_OFFSET(s0)(sp) ld s1, SMODE_TRAP_REGS_OFFSET(s1)(sp) ld a0, SMODE_TRAP_REGS_OFFSET(a0)(sp) @@ -93,13 +95,10 @@ SupervisorModeTrap: =20 ld t0, SMODE_TRAP_REGS_OFFSET(sepc)(sp) csrw CSR_SEPC, t0 - ld t0, SMODE_TRAP_REGS_OFFSET(sie)(sp) - csrw CSR_SIE, t0 - csrr t0, CSR_SSTATUS - ld t1, SMODE_TRAP_REGS_OFFSET(sstatus)(sp) - or t0, t0, t1 + ld t0, SMODE_TRAP_REGS_OFFSET(sstatus)(sp) csrw CSR_SSTATUS, t0 - ld t1, SMODE_TRAP_REGS_OFFSET(t1)(sp) + ld t0, SMODE_TRAP_REGS_OFFSET(stval)(sp) + csrw CSR_STVAL, t0 ld t0, SMODE_TRAP_REGS_OFFSET(t0)(sp) addi sp, sp, SMODE_TRAP_REGS_SIZE sret --=20 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 (#100766): https://edk2.groups.io/g/devel/message/100766 Mute This Topic: https://groups.io/mt/97436055/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-