From nobody Sun May 19 14:14:20 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+103016+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+103016+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1681498717; cv=none; d=zohomail.com; s=zohoarc; b=JgzIALJj5gLeBvjLbGfbguQKb3VKMR04aNJ39Iu2w/9X8CVJGqLe3XghR1cVVfNJEEqfMF5We3H32s9Kr1vPE4naKIVoPpQJ1PzrxkxcmuOVkwTCh3hg5oIZMqzdQuHWPkfbi16OXZTf1azbsDjU11RYvDdL1kiE2J7y6DLpJKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681498717; 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=ljoAicsFig38cupVtNz5PZd6woHjKoRtC1a7vtn2Q8A=; b=gFji1d/cZPIij5ofHQplyQiQAv07/BsdsfXIW5j7AsjVTa6QTJ5rxH0UMao/2pDzLSzAp0WpiynUG9zBw6HSg7cnXZN4Kwc/ODc1os0oYCao/pCfqZUgvOSrWkjfCkYG+N0hlU33qX1g5Q0z5ePnDdfUcyp3EgaL5QtTK7dVWwo= 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+103016+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1681498717456559.2973940290166; Fri, 14 Apr 2023 11:58:37 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dYBjYY1788612xYfT5hzYmTW; Fri, 14 Apr 2023 11:58:37 -0700 X-Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mx.groups.io with SMTP id smtpd.web11.19127.1681498716562035141 for ; Fri, 14 Apr 2023 11:58:36 -0700 X-Received: by mail-pj1-f49.google.com with SMTP id pm7-20020a17090b3c4700b00246f00dace2so11722416pjb.2 for ; Fri, 14 Apr 2023 11:58:36 -0700 (PDT) X-Gm-Message-State: soP1nIyda9afbG4gPInVXPdox1787277AA= X-Google-Smtp-Source: AKy350aiTD8qICl6M+L7ydXUvl4JFcfJt0ol2RF+rqKKHmG+2muo+rhjr7gLzelgu/d6Y5pYZCdNuA== X-Received: by 2002:a17:902:d482:b0:1a4:fae1:d6b0 with SMTP id c2-20020a170902d48200b001a4fae1d6b0mr4987922plg.28.1681498715626; Fri, 14 Apr 2023 11:58:35 -0700 (PDT) X-Received: from localhost.localdomain (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id g20-20020a170902869400b001a681d123a0sm3329760plo.297.2023.04.14.11.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 11:58:35 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, sunilvl@ventanamicro.com, git@danielschaefer.me, andrei.warkentin@intel.com, Tuan Phan Subject: [edk2-devel] [PATCH v2 1/6] MdePkg/BaseLib: RISC-V: Support getting satp register value Date: Fri, 14 Apr 2023 11:58:10 -0700 Message-Id: <20230414185815.2994-2-tphan@ventanamicro.com> In-Reply-To: <20230414185815.2994-1-tphan@ventanamicro.com> References: <20230414185815.2994-1-tphan@ventanamicro.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,tphan@ventanamicro.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1681498717; bh=e9eK+wb+slmpeRTIkCfF4oqXmnj1uLhjG6tqxugVqzw=; h=Cc:Date:From:Reply-To:Subject:To; b=bPmldLymiA5N/tQ+HBY7OoAw7F4e3l+uZua7kNI3ETlMQoQhrIQ2VTV7ykYHvBFPYSX NsJNRR/NjGubTHXypBpBXowj7PzucSggdQP65McLGFGcGMQu1fJ+tl+Yw5hV3OveDYQQ2 oGh8NBS/Wsb8X7Nevf/wgHXGEXutoyIcZ18= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1681498719383100012 Content-Type: text/plain; charset="utf-8" Add an API to retrieve satp register value. Signed-off-by: Tuan Phan Reviewed-by: Andrei Warkentin --- MdePkg/Include/Library/BaseLib.h | 5 +++++ MdePkg/Library/BaseLib/RiscV64/RiscVMmu.S | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/Base= Lib.h index 8f2df76c29a3..5d7067ee854e 100644 --- a/MdePkg/Include/Library/BaseLib.h +++ b/MdePkg/Include/Library/BaseLib.h @@ -181,6 +181,11 @@ RiscVSetSupervisorAddressTranslationRegister ( IN UINT64 ); =20 +UINT64 +RiscVGetSupervisorAddressTranslationRegister ( + VOID + ); + UINT64 RiscVReadTimer ( VOID diff --git a/MdePkg/Library/BaseLib/RiscV64/RiscVMmu.S b/MdePkg/Library/Bas= eLib/RiscV64/RiscVMmu.S index ac8f92f38aed..c9cf60c1664b 100644 --- a/MdePkg/Library/BaseLib/RiscV64/RiscVMmu.S +++ b/MdePkg/Library/BaseLib/RiscV64/RiscVMmu.S @@ -21,3 +21,11 @@ ASM_FUNC (RiscVSetSupervisorAddressTranslationRegister) csrw CSR_SATP, a0 ret + +// +// Get the value of Supervisor Address Translation and +// Protection Register. +// +ASM_FUNC (RiscVGetSupervisorAddressTranslationRegister) + csrr a0, CSR_SATP + ret --=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 (#103016): https://edk2.groups.io/g/devel/message/103016 Mute This Topic: https://groups.io/mt/98269072/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 Sun May 19 14:14:20 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+103017+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+103017+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1681498718; cv=none; d=zohomail.com; s=zohoarc; b=ZPSgPaauw/XU8VQ2HXhxgB/zLObh++epJz3SAeiWbz04PiW+aywUvdCZUpFSEhM3Ga7hpQRM5bDUXs0aq6fQHN3pT9PlVOSlWEaUEakQa2RAZp49WH/viUyWmKJ7qY+SksAJmEu5cVJgZR03fh+UD2tyMIbY6NYT/uS3LEetpZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681498718; 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=UITJuAcB9qDnrdblM0DDho3wdXUigjB8mDGDTjAH3K8=; b=JSIFQDxjioxVbAuoL2O8/2q+sTT7cO5Dz+wcedx2oVwRDr33yhWZwcF+P5t5fDtaf+895NRhHNLj/cq+D2GMYDUS1l7KFrfRmjn3Q+g4wuORUta2a8Yz09PuVf8dFLAJZ7pPBCyefnNAlIJ4kRUxOdlwXouVwt8bBrbn1B3fiwc= 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+103017+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1681498718963280.74221963734476; Fri, 14 Apr 2023 11:58:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id cYoLYY1788612xpyfkg4qyKe; Fri, 14 Apr 2023 11:58:38 -0700 X-Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mx.groups.io with SMTP id smtpd.web11.19129.1681498718183543419 for ; Fri, 14 Apr 2023 11:58:38 -0700 X-Received: by mail-pl1-f175.google.com with SMTP id n17so3275988pln.8 for ; Fri, 14 Apr 2023 11:58:38 -0700 (PDT) X-Gm-Message-State: D7ikhGAIAH7vGisasBQ0z5OMx1787277AA= X-Google-Smtp-Source: AKy350b/HmZb0iY9XBBLkCNPmqoiMJFrPyO37VCDD7kfh7SD6eHewZUqgy5e+l7HLv030eLlBifxkw== X-Received: by 2002:a17:902:d507:b0:1a6:275b:9374 with SMTP id b7-20020a170902d50700b001a6275b9374mr4473930plg.67.1681498717299; Fri, 14 Apr 2023 11:58:37 -0700 (PDT) X-Received: from localhost.localdomain (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id g20-20020a170902869400b001a681d123a0sm3329760plo.297.2023.04.14.11.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 11:58:36 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, sunilvl@ventanamicro.com, git@danielschaefer.me, andrei.warkentin@intel.com, Tuan Phan Subject: [edk2-devel] [PATCH v2 2/6] MdePkg/Register: RISC-V: Add satp mode bits shift definition Date: Fri, 14 Apr 2023 11:58:11 -0700 Message-Id: <20230414185815.2994-3-tphan@ventanamicro.com> In-Reply-To: <20230414185815.2994-1-tphan@ventanamicro.com> References: <20230414185815.2994-1-tphan@ventanamicro.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,tphan@ventanamicro.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1681498718; bh=5M55J0XDRXhKCsQN4hJdyeiH/BdqLZCBmZkcdGu5vgM=; h=Cc:Date:From:Reply-To:Subject:To; b=thxXNCNmsDQ9IaEryDcBOMh6Zp9ImjxJ84bCOEU9hsUrGrmC+75V+AotFkswFyay6cM ZY7sps811u867k3Tf+ocjtSiwlFJKcdwUY7jwCqgb8K9x4BXBf+3O0bvetabRWOrmX3Kh gOzbDD4b6r17oaTTWWYnjFlVR94ws7jvVJ4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1681498719381100011 Content-Type: text/plain; charset="utf-8" The satp mode bits shift is used cross modules. It should be defined in one place. Signed-off-by: Tuan Phan Reviewed-by: Andrei Warkentin --- MdePkg/Include/Register/RiscV64/RiscVEncoding.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h b/MdePkg/Inclu= de/Register/RiscV64/RiscVEncoding.h index 5c2989b797bf..2bde8db478ff 100644 --- a/MdePkg/Include/Register/RiscV64/RiscVEncoding.h +++ b/MdePkg/Include/Register/RiscV64/RiscVEncoding.h @@ -58,9 +58,10 @@ #define PRV_S 1UL #define PRV_M 3UL =20 -#define SATP64_MODE 0xF000000000000000ULL -#define SATP64_ASID 0x0FFFF00000000000ULL -#define SATP64_PPN 0x00000FFFFFFFFFFFULL +#define SATP64_MODE 0xF000000000000000ULL +#define SATP64_MODE_SHIFT 60 +#define SATP64_ASID 0x0FFFF00000000000ULL +#define SATP64_PPN 0x00000FFFFFFFFFFFULL =20 #define SATP_MODE_OFF 0UL #define SATP_MODE_SV32 1UL --=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 (#103017): https://edk2.groups.io/g/devel/message/103017 Mute This Topic: https://groups.io/mt/98269075/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 Sun May 19 14:14:20 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+103018+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+103018+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1681498721; cv=none; d=zohomail.com; s=zohoarc; b=dN2X45ssYGmgpQ4Ont3//m7OXmL+otKsoOzbjJaQ96KkwDPBW726TeXTuuFo4UECUt5dFtwHVnHx/wsuQAWl3eVtPU055uVTdSJFQg/z0jehXxgmapkRwRSuu5TAPiCZ0BwJOziA0Gfz4R6JtORa1FbxU0a91skJQ9+R8DLQTRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681498721; 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=w5GV2lTIhWRiRmAhwFhSOlD0NXzsRgJbh+BFU9D2M4w=; b=g6b54u3wJ09jgYZTfR+on8FpNHT4I2+rdsSeoGPnSFATEXk7C0oo4DLZ7fQWP7P3IxJHJCn/XdPXATSMvz06KuUAPhveg2qqrz+ItC1lOdq+Ggp0PlfZP9y13kOXNSWaaKxK8KBqa3fd2mjBTGyl+pCiV9ZUFz8/yPGYhzxjphE= 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+103018+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1681498721557291.81949262374667; Fri, 14 Apr 2023 11:58:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id TyLrYY1788612xneO3UbSzCT; Fri, 14 Apr 2023 11:58:40 -0700 X-Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mx.groups.io with SMTP id smtpd.web11.19132.1681498720289713627 for ; Fri, 14 Apr 2023 11:58:40 -0700 X-Received: by mail-pl1-f181.google.com with SMTP id y6so18156805plp.2 for ; Fri, 14 Apr 2023 11:58:40 -0700 (PDT) X-Gm-Message-State: YszGaHa8LUdqbut63a4nNvmex1787277AA= X-Google-Smtp-Source: AKy350ZWRjQmqKpX90Z7B+BjD9f34dyrko097XCd3sFTj4tDkmu5JzbmI90CaunKZ/DbnEHhf+0sZw== X-Received: by 2002:a17:90b:4a0f:b0:246:94cf:6c26 with SMTP id kk15-20020a17090b4a0f00b0024694cf6c26mr6374486pjb.10.1681498719105; Fri, 14 Apr 2023 11:58:39 -0700 (PDT) X-Received: from localhost.localdomain (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id g20-20020a170902869400b001a681d123a0sm3329760plo.297.2023.04.14.11.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 11:58:38 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, sunilvl@ventanamicro.com, git@danielschaefer.me, andrei.warkentin@intel.com, Tuan Phan Subject: [edk2-devel] [PATCH v2 3/6] UefiCpuPkg: RISC-V: Support MMU with SV39/48/57 mode Date: Fri, 14 Apr 2023 11:58:12 -0700 Message-Id: <20230414185815.2994-4-tphan@ventanamicro.com> In-Reply-To: <20230414185815.2994-1-tphan@ventanamicro.com> References: <20230414185815.2994-1-tphan@ventanamicro.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,tphan@ventanamicro.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1681498720; bh=CRrarS8oQCco31S2nuMz0zqq6u/poAxX9S68j3kDf/8=; h=Cc:Date:From:Reply-To:Subject:To; b=SGa+dXdpHYzji6mR54nw9tf4e5CRsQpEGYPnOJPBOnGmTQme9848QK5yrx4I0oP2etd W+WniGCtSDxdQ2X4oadM2TxqpeRmjxI7ufqodhCR+qsSRkq6FBODyOlkgt1QeysT3nFvV 5IYKkVXXkQS0hFA06np9B13D/GCeedofXsE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1681498722805100019 Content-Type: text/plain; charset="utf-8" During CpuDxe initialization, MMU will be setup with the highest mode that HW supports. Signed-off-by: Tuan Phan Reviewed-by: Andrei Warkentin --- MdePkg/Include/Library/BaseRiscVMmuLib.h | 39 ++ .../Library/BaseRiscVMmuLib/BaseRiscVMmuLib.c | 569 ++++++++++++++++++ .../BaseRiscVMmuLib/BaseRiscVMmuLib.inf | 25 + MdePkg/Library/BaseRiscVMmuLib/RiscVMmuCore.S | 31 + OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc | 1 + OvmfPkg/RiscVVirt/Sec/Memory.c | 18 +- UefiCpuPkg/CpuDxeRiscV64/CpuDxe.c | 9 +- UefiCpuPkg/CpuDxeRiscV64/CpuDxe.h | 2 + UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf | 2 + 9 files changed, 678 insertions(+), 18 deletions(-) create mode 100644 MdePkg/Include/Library/BaseRiscVMmuLib.h create mode 100644 MdePkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.c create mode 100644 MdePkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.inf create mode 100644 MdePkg/Library/BaseRiscVMmuLib/RiscVMmuCore.S diff --git a/MdePkg/Include/Library/BaseRiscVMmuLib.h b/MdePkg/Include/Libr= ary/BaseRiscVMmuLib.h new file mode 100644 index 000000000000..f71d6a4a1e7b --- /dev/null +++ b/MdePkg/Include/Library/BaseRiscVMmuLib.h @@ -0,0 +1,39 @@ +/** @file + + Copyright (c) 2015 - 2016, Linaro Ltd. All rights reserved.
+ Copyright (c) 2023, Ventana Micro Systems Inc. All Rights Reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef BASE_RISCV_MMU_LIB_H_ +#define BASE_RISCV_MMU_LIB_H_ + +VOID +EFIAPI +RiscVLocalTlbFlushAll ( + VOID + ); + +VOID +EFIAPI +RiscVLocalTlbFlush ( + UINTN VirtAddr + ); + +EFI_STATUS +EFIAPI +RiscVSetMemoryAttributes ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Attributes + ); + +EFI_STATUS +EFIAPI +RiscVConfigureMmu ( + VOID + ); + +#endif /* BASE_RISCV_MMU_LIB_H_ */ diff --git a/MdePkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.c b/MdePkg/Libr= ary/BaseRiscVMmuLib/BaseRiscVMmuLib.c new file mode 100644 index 000000000000..230f34261d8b --- /dev/null +++ b/MdePkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.c @@ -0,0 +1,569 @@ +/** @file +* MMU implementation for RISC-V +* +* Copyright (c) 2011-2020, ARM Limited. All rights reserved. +* Copyright (c) 2016, Linaro Limited. All rights reserved. +* Copyright (c) 2017, Intel Corporation. All rights reserved.
+* Copyright (c) 2023, Ventana Micro Systems Inc. All Rights Reserved.
+* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define RISCV_PG_V BIT0 +#define RISCV_PG_R BIT1 +#define RISCV_PG_W BIT2 +#define RISCV_PG_X BIT3 +#define RISCV_PG_G BIT5 +#define RISCV_PG_A BIT6 +#define RISCV_PG_D BIT7 +#define PTE_ATTRIBUTES_MASK 0xE + +#define PTE_PPN_MASK 0x3FFFFFFFFFFC00ULL +#define PTE_PPN_SHIFT 10 +#define RISCV_MMU_PAGE_SHIFT 12 + +STATIC UINTN mMaxRootTableLevel; +STATIC UINTN mBitPerLevel; +STATIC UINTN mTableEntryCount; + +STATIC +BOOLEAN +RiscVMmuEnabled ( + VOID + ) +{ + return ((RiscVGetSupervisorAddressTranslationRegister () & + SATP64_MODE) !=3D (SATP_MODE_OFF << SATP64_MODE_SHIFT)); +} + +STATIC +UINTN +RiscVGetRootTranslateTable ( + VOID + ) +{ + return (RiscVGetSupervisorAddressTranslationRegister () & SATP64_PPN) << + RISCV_MMU_PAGE_SHIFT; +} + +STATIC +BOOLEAN +IsValidPte ( + IN UINTN Entry + ) +{ + if (!(Entry & RISCV_PG_V) || + (((Entry & (RISCV_PG_R | RISCV_PG_W)) =3D=3D RISCV_PG_W))) + { + return FALSE; + } + + return TRUE; +} + +STATIC +UINTN +SetValidPte ( + IN UINTN Entry + ) +{ + /* Set Valid and Global mapping bits */ + return Entry | RISCV_PG_G | RISCV_PG_V; +} + +STATIC +BOOLEAN +IsBlockEntry ( + IN UINTN Entry + ) +{ + return IsValidPte (Entry) && + (Entry & (RISCV_PG_X | RISCV_PG_R)); +} + +STATIC +BOOLEAN +IsTableEntry ( + IN UINTN Entry + ) +{ + return IsValidPte (Entry) && + !IsBlockEntry (Entry); +} + +STATIC +UINTN +SetTableEntry ( + IN UINTN Entry + ) +{ + Entry =3D SetValidPte (Entry); + Entry &=3D ~(RISCV_PG_X | RISCV_PG_W | RISCV_PG_R); + + return Entry; +} + +STATIC +VOID +ReplaceTableEntry ( + IN UINTN *Entry, + IN UINTN Value, + IN UINTN RegionStart, + IN BOOLEAN IsLiveBlockMapping + ) +{ + *Entry =3D Value; + + if (IsLiveBlockMapping && RiscVMmuEnabled ()) { + RiscVLocalTlbFlush (RegionStart); + } +} + +STATIC +UINTN +GetPpnfromPte ( + UINTN Entry, + UINTN Level + ) +{ + return ((Entry & PTE_PPN_MASK) >> PTE_PPN_SHIFT); +} + +STATIC +UINTN +SetPpnToPte ( + UINTN Entry, + UINTN Address, + UINTN Level + ) +{ + UINTN Ppn; + + Ppn =3D ((Address >> RISCV_MMU_PAGE_SHIFT) << PTE_PPN_SHIFT); + ASSERT (~(Ppn & ~PTE_PPN_MASK)); + Entry &=3D ~PTE_PPN_MASK; + return Entry | Ppn; +} + +STATIC +VOID +FreePageTablesRecursive ( + IN UINTN *TranslationTable, + IN UINTN Level + ) +{ + UINTN Index; + + if (Level < mMaxRootTableLevel - 1) { + for (Index =3D 0; Index < mTableEntryCount; Index++) { + if (IsTableEntry (TranslationTable[Index])) { + FreePageTablesRecursive ( + (UINTN *)(GetPpnfromPte ((TranslationTabl= e[Index]), Level) << + RISCV_MMU_PAGE_SHIFT), + Level + 1 + ); + } + } + } + + FreePages (TranslationTable, 1); +} + +STATIC +EFI_STATUS +UpdateRegionMappingRecursive ( + IN UINTN RegionStart, + IN UINTN RegionEnd, + IN UINTN AttributeSetMask, + IN UINTN AttributeClearMask, + IN UINTN *PageTable, + IN UINTN Level, + IN BOOLEAN TableIsLive + ) +{ + EFI_STATUS Status; + UINTN BlockShift; + UINTN BlockMask; + UINTN BlockEnd; + UINTN *Entry; + UINTN EntryValue; + UINTN *TranslationTable; + BOOLEAN NextTableIsLive; + + ASSERT (Level < mMaxRootTableLevel); + ASSERT (((RegionStart | RegionEnd) & EFI_PAGE_MASK) =3D=3D 0); + + BlockShift =3D (mMaxRootTableLevel - Level - 1) * mBitPerLevel + RISCV_M= MU_PAGE_SHIFT; + BlockMask =3D MAX_ADDRESS >> (64 - BlockShift); + + DEBUG ( + ( + DEBUG_VERBOSE, + "%a(%d): %llx - %llx set %lx clr %lx\n", + __func__, + Level, + RegionStart, + RegionEnd, + AttributeSetMask, + AttributeClearMask + ) + ); + + for ( ; RegionStart < RegionEnd; RegionStart =3D BlockEnd) { + BlockEnd =3D MIN (RegionEnd, (RegionStart | BlockMask) + 1); + Entry =3D &PageTable[(RegionStart >> BlockShift) & (mTableEntryCoun= t - 1)]; + + // + // If RegionStart or BlockEnd is not aligned to the block size at this + // level, we will have to create a table mapping in order to map less + // than a block, and recurse to create the block or page entries at + // the next level. No block mappings are allowed at all at level 0, + // so in that case, we have to recurse unconditionally. + // + if ((Level =3D=3D 0) || + (((RegionStart | BlockEnd) & BlockMask) !=3D 0) || IsTableEntry (*= Entry)) + { + ASSERT (Level < mMaxRootTableLevel - 1); + if (!IsTableEntry (*Entry)) { + // + // No table entry exists yet, so we need to allocate a page table + // for the next level. + // + TranslationTable =3D AllocatePages (1); + if (TranslationTable =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + ZeroMem (TranslationTable, EFI_PAGE_SIZE); + + if (IsBlockEntry (*Entry)) { + // + // We are splitting an existing block entry, so we have to popul= ate + // the new table with the attributes of the block entry it repla= ces. + // + Status =3D UpdateRegionMappingRecursive ( + RegionStart & ~BlockMask, + (RegionStart | BlockMask)= + 1, + *Entry & PTE_ATTRIBUTES_M= ASK, + PTE_ATTRIBUTES_MASK, + TranslationTable, + Level + 1, + FALSE + ); + if (EFI_ERROR (Status)) { + // + // The range we passed to UpdateRegionMappingRecursive () is b= lock + // aligned, so it is guaranteed that no further pages were all= ocated + // by it, and so we only have to free the page we allocated he= re. + // + FreePages (TranslationTable, 1); + return Status; + } + } + + NextTableIsLive =3D FALSE; + } else { + TranslationTable =3D (UINTN *)(GetPpnfromPte (*Entry, Level) << RI= SCV_MMU_PAGE_SHIFT); + NextTableIsLive =3D TableIsLive; + } + + // + // Recurse to the next level + // + Status =3D UpdateRegionMappingRecursive ( + RegionStart, + BlockEnd, + AttributeSetMask, + AttributeClearMask, + TranslationTable, + Level + 1, + NextTableIsLive + ); + if (EFI_ERROR (Status)) { + if (!IsTableEntry (*Entry)) { + // + // We are creating a new table entry, so on failure, we can free= all + // allocations we made recursively, given that the whole subhier= archy + // has not been wired into the live page tables yet. (This is not + // possible for existing table entries, since we cannot revert t= he + // modifications we made to the subhierarchy it represents.) + // + FreePageTablesRecursive (TranslationTable, Level + 1); + } + + return Status; + } + + if (!IsTableEntry (*Entry)) { + EntryValue =3D SetPpnToPte (0, (UINTN)TranslationTable, Level); + EntryValue =3D SetTableEntry (EntryValue); + ReplaceTableEntry ( + Entry, + EntryValue, + RegionStart, + TableIsLive + ); + } + } else { + EntryValue =3D (*Entry & ~AttributeClearMask) | AttributeSetMask; + // + // We don't have page fault exception handler when a virtual page is= accessed and + // the A bit is clear, or is written and the D bit is clear. + // So just set A for read and D for write permission. + // + if (AttributeSetMask & RISCV_PG_R) { + EntryValue |=3D RISCV_PG_A; + } + + if (AttributeSetMask & RISCV_PG_W) { + EntryValue |=3D RISCV_PG_D; + } + + EntryValue =3D SetPpnToPte (EntryValue, RegionStart, Level); + EntryValue =3D SetValidPte (EntryValue); + ReplaceTableEntry (Entry, EntryValue, RegionStart, TableIsLive); + } + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +UpdateRegionMapping ( + IN UINTN RegionStart, + IN UINTN RegionLength, + IN UINTN AttributeSetMask, + IN UINTN AttributeClearMask, + IN UINTN *RootTable, + IN BOOLEAN TableIsLive + ) +{ + if (((RegionStart | RegionLength) & EFI_PAGE_MASK) !=3D 0) { + return EFI_INVALID_PARAMETER; + } + + return UpdateRegionMappingRecursive ( + RegionStart, + RegionStart + RegionLength, + AttributeSetMask, + AttributeClearMask, + RootTable, + 0, + TableIsLive + ); +} + +STATIC +UINTN +GcdAttributeToPageAttribute ( + IN UINTN GcdAttributes + ) +{ + UINTN RiscVAttributes =3D RISCV_PG_R | RISCV_PG_W | RISCV_PG_X; + + // Determine protection attributes + if (GcdAttributes & EFI_MEMORY_RO) { + RiscVAttributes &=3D ~(RISCV_PG_W); + } + + // Process eXecute Never attribute + if (GcdAttributes & EFI_MEMORY_XP) { + RiscVAttributes &=3D ~RISCV_PG_X; + } + + return RiscVAttributes; +} + +EFI_STATUS +EFIAPI +RiscVSetMemoryAttributes ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINTN Length, + IN UINTN Attributes + ) +{ + UINTN PageAttributesSet =3D GcdAttributeToPageAttribute (Attributes); + + if (!RiscVMmuEnabled ()) { + return EFI_SUCCESS; + } + + DEBUG ( + ( + DEBUG_VERBOSE, + "%a: Set %llX page attribute 0x%X\n", + __func__, + BaseAddress, + PageAttributesSet + ) + ); + + return UpdateRegionMapping ( + BaseAddress, + Length, + PageAttributesSet, + PTE_ATTRIBUTES_MASK, + (UINTN *)RiscVGetRootTranslateTable (), + TRUE + ); +} + +STATIC +EFI_STATUS +RiscVMmuSetSatpMode ( + UINTN SatpMode + ) +{ + VOID *TranslationTable; + UINTN SatpReg; + UINTN Ppn; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemoryMap; + UINTN NumberOfDescriptors; + UINTN Index; + EFI_STATUS Status; + + switch (SatpMode) { + case SATP_MODE_OFF: + return EFI_SUCCESS; + case SATP_MODE_SV39: + mMaxRootTableLevel =3D 3; + mBitPerLevel =3D 9; + mTableEntryCount =3D 512; + break; + case SATP_MODE_SV48: + mMaxRootTableLevel =3D 4; + mBitPerLevel =3D 9; + mTableEntryCount =3D 512; + break; + case SATP_MODE_SV57: + mMaxRootTableLevel =3D 5; + mBitPerLevel =3D 9; + mTableEntryCount =3D 512; + break; + default: + return EFI_INVALID_PARAMETER; + } + + // Allocate pages for translation table + TranslationTable =3D AllocatePages (1); + if (TranslationTable =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + ZeroMem (TranslationTable, mTableEntryCount * sizeof (UINTN)); + + NumberOfDescriptors =3D 0; + MemoryMap =3D NULL; + Status =3D gDS->GetMemorySpaceMap ( + &NumberOfDescriptors, + &MemoryMap + ); + ASSERT_EFI_ERROR (Status); + + for (Index =3D 0; Index < NumberOfDescriptors; Index++) { + if (MemoryMap[Index].GcdMemoryType =3D=3D EfiGcdMemoryTypeMemoryMapped= Io) { + // Default Read/Write attribute for memory mapped IO + UpdateRegionMapping ( + MemoryMap[Index].BaseAddress, + MemoryMap[Index].Length, + RISCV_PG_R | RISCV_PG_W, + PTE_ATTRIBUTES_MASK, + TranslationTable, + FALSE + ); + } else if (MemoryMap[Index].GcdMemoryType =3D=3D EfiGcdMemoryTypeSyste= mMemory) { + // Default Read/Write/Execute attribute for system memory + UpdateRegionMapping ( + MemoryMap[Index].BaseAddress, + MemoryMap[Index].Length, + RISCV_PG_R | RISCV_PG_W | RISCV_PG_X, + PTE_ATTRIBUTES_MASK, + TranslationTable, + FALSE + ); + } + } + + FreePool ((VOID *)MemoryMap); + + if (GetInterruptState ()) { + DisableInterrupts (); + } + + Ppn =3D (UINTN)TranslationTable >> RISCV_MMU_PAGE_SHIFT; + ASSERT (!(Ppn & ~(SATP64_PPN))); + + SatpReg =3D Ppn; + SatpReg |=3D (SatpMode << + SATP64_MODE_SHIFT) & SATP64_MODE; + RiscVSetSupervisorAddressTranslationRegister (SatpReg); + /* Check if HW support the setup satp mode */ + if (SatpReg !=3D RiscVGetSupervisorAddressTranslationRegister ()) { + DEBUG ( + ( + DEBUG_VERBOSE, + "%a: HW does not support SATP mode:%d\n", + __func__, + SatpMode + ) + ); + FreePageTablesRecursive (TranslationTable, 0); + return EFI_DEVICE_ERROR; + } + + RiscVLocalTlbFlushAll (); + + if (GetInterruptState ()) { + EnableInterrupts (); + } + + return Status; +} + +EFI_STATUS +EFIAPI +RiscVConfigureMmu ( + VOID + ) +{ + EFI_STATUS Status =3D EFI_SUCCESS; + INTN ModeSupport[] =3D { SATP_MODE_SV57, SATP_MODE_SV48, SATP_MOD= E_SV39 }; + INTN Idx; + + /* Try to setup MMU with highest mode as possible */ + for (Idx =3D 0; Idx < ARRAY_SIZE (ModeSupport); Idx++) { + Status =3D RiscVMmuSetSatpMode (ModeSupport[Idx]); + if (Status =3D=3D EFI_DEVICE_ERROR) { + continue; + } else if (EFI_ERROR (Status)) { + return Status; + } + + DEBUG ( + ( + DEBUG_INFO, + "%a: SATP mode %d successfully configured\n", + __func__, + ModeSupport[Idx] + ) + ); + break; + } + + return Status; +} diff --git a/MdePkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.inf b/MdePkg/Li= brary/BaseRiscVMmuLib/BaseRiscVMmuLib.inf new file mode 100644 index 000000000000..8ee0127c2144 --- /dev/null +++ b/MdePkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.inf @@ -0,0 +1,25 @@ +## @file +# +# Copyright (c) 2023, Ventana Micro Systems Inc. All Rights Reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001b + BASE_NAME =3D BaseRiscVMmuLib + FILE_GUID =3D d3bc42ee-c9eb-4339-ba11-06747083d3ae + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RiscVMmuLib + +[Sources] + BaseRiscVMmuLib.c + RiscVMmuCore.S + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib diff --git a/MdePkg/Library/BaseRiscVMmuLib/RiscVMmuCore.S b/MdePkg/Library= /BaseRiscVMmuLib/RiscVMmuCore.S new file mode 100644 index 000000000000..42eec4cbdf83 --- /dev/null +++ b/MdePkg/Library/BaseRiscVMmuLib/RiscVMmuCore.S @@ -0,0 +1,31 @@ +/** @file +* +* Copyright (c) 2023, Ventana Micro Systems Inc. All Rights Reserved.
+* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#include +#include + +.text + .align 3 + +// +// Local tlb flush all. +// +// +ASM_FUNC (RiscVLocalTlbFlushAll) +sfence.vma +ret + +// +// Local tlb flush at a virtual address +// @retval a0 : virtual address. +// +ASM_FUNC ( + RiscVLocalTlbFlush + ) +sfence.vma a0 +ret diff --git a/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc b/OvmfPkg/RiscVVirt/RiscVV= irt.dsc.inc index 731f54f73f81..083a182655d3 100644 --- a/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc +++ b/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc @@ -83,6 +83,7 @@ # RISC-V Architectural Libraries CpuExceptionHandlerLib|UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandler= Lib/BaseRiscV64CpuExceptionHandlerLib.inf RiscVSbiLib|MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.inf + RiscVMmuLib|MdePkg/Library/BaseRiscVMmuLib/BaseRiscVMmuLib.inf PlatformBootManagerLib|OvmfPkg/RiscVVirt/Library/PlatformBootManagerLib/= PlatformBootManagerLib.inf ResetSystemLib|OvmfPkg/RiscVVirt/Library/ResetSystemLib/BaseResetSystemL= ib.inf =20 diff --git a/OvmfPkg/RiscVVirt/Sec/Memory.c b/OvmfPkg/RiscVVirt/Sec/Memory.c index 0e2690c73687..69041f6404a4 100644 --- a/OvmfPkg/RiscVVirt/Sec/Memory.c +++ b/OvmfPkg/RiscVVirt/Sec/Memory.c @@ -85,21 +85,6 @@ AddMemoryRangeHob ( AddMemoryBaseSizeHob (MemoryBase, (UINT64)(MemoryLimit - MemoryBase)); } =20 -/** - Configure MMU -**/ -STATIC -VOID -InitMmu ( - ) -{ - // - // Set supervisor translation mode to Bare mode - // - RiscVSetSupervisorAddressTranslationRegister ((UINT64)SATP_MODE_OFF << 6= 0); - DEBUG ((DEBUG_INFO, "%a: Set Supervisor address mode to bare-metal mode.= \n", __func__)); -} - /** Publish system RAM and reserve memory regions. =20 @@ -327,7 +312,8 @@ MemoryPeimInitialization ( =20 AddReservedMemoryMap (FdtPointer); =20 - InitMmu (); + /* Make sure SEC is booting with bare mode*/ + ASSERT ((RiscVGetSupervisorAddressTranslationRegister () & SATP64_MODE) = =3D=3D (SATP_MODE_OFF << SATP64_MODE_SHIFT)); =20 BuildMemoryTypeInformationHob (); =20 diff --git a/UefiCpuPkg/CpuDxeRiscV64/CpuDxe.c b/UefiCpuPkg/CpuDxeRiscV64/C= puDxe.c index 25fe3f54c325..2af3b6223450 100644 --- a/UefiCpuPkg/CpuDxeRiscV64/CpuDxe.c +++ b/UefiCpuPkg/CpuDxeRiscV64/CpuDxe.c @@ -296,8 +296,7 @@ CpuSetMemoryAttributes ( IN UINT64 Attributes ) { - DEBUG ((DEBUG_INFO, "%a: Set memory attributes not supported yet\n", __f= unc__)); - return EFI_SUCCESS; + return RiscVSetMemoryAttributes (BaseAddress, Length, Attributes); } =20 /** @@ -340,6 +339,12 @@ InitializeCpu ( // DisableInterrupts (); =20 + // + // Enable MMU + // + Status =3D RiscVConfigureMmu (); + ASSERT_EFI_ERROR (Status); + // // Install Boot protocol // diff --git a/UefiCpuPkg/CpuDxeRiscV64/CpuDxe.h b/UefiCpuPkg/CpuDxeRiscV64/C= puDxe.h index 49f4e119665a..68e6d038b66e 100644 --- a/UefiCpuPkg/CpuDxeRiscV64/CpuDxe.h +++ b/UefiCpuPkg/CpuDxeRiscV64/CpuDxe.h @@ -15,11 +15,13 @@ #include #include #include +#include #include #include #include #include #include +#include =20 /** Flush CPU data cache. If the instruction cache is fully coherent diff --git a/UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf b/UefiCpuPkg/CpuDxe= RiscV64/CpuDxeRiscV64.inf index e8fa25446aef..9d9a5ef8f247 100644 --- a/UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf +++ b/UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf @@ -37,6 +37,8 @@ TimerLib PeCoffGetEntryPointLib RiscVSbiLib + RiscVMmuLib + CacheMaintenanceLib =20 [Sources] CpuDxe.c --=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 (#103018): https://edk2.groups.io/g/devel/message/103018 Mute This Topic: https://groups.io/mt/98269076/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 Sun May 19 14:14:20 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+103019+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+103019+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1681498722; cv=none; d=zohomail.com; s=zohoarc; b=LucORN6zwExDo2Jfr0vys5C/k/fUOVdN8DKZYP7S6BDB3CrOBd9W1ATVZaJ1pKvqwUwu76YWzR9luBBgceHYadTan+byfYM8LT/QAacTcfr2GQs6v0eXUvSg6WNGL0oW/7Tqq+VQ0/aa832b6RwXFZ1oLOkATu0GGAEPJcAdpVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681498722; 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=P1q/SZuK/4Twj5wCGAR25hiauC+mciaF52W2p7UQ0CY=; b=jL2ziXZABBYGGOpEy3NOoCskRQ3STK3xfghRfkKwTFDTpDbisuDgbtX0berruf1guX+Q0yHrxbqsuG5v3ZfqWPXXFo2A2p3+2wmuwJJ4aetabcnxqWqW9LP45yOE/ux8lOSsTKyAph9luBfCLzmJT/iTCMlbERXm7sDCJcuCEqw= 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+103019+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1681498722364922.3787472095665; Fri, 14 Apr 2023 11:58:42 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id voW7YY1788612xRgVqiVebve; Fri, 14 Apr 2023 11:58:42 -0700 X-Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) by mx.groups.io with SMTP id smtpd.web11.19127.1681498716562035141 for ; Fri, 14 Apr 2023 11:58:41 -0700 X-Received: by mail-pj1-f49.google.com with SMTP id pm7-20020a17090b3c4700b00246f00dace2so11722659pjb.2 for ; Fri, 14 Apr 2023 11:58:41 -0700 (PDT) X-Gm-Message-State: mGRfXR807QMKsbNGJGEpAoo5x1787277AA= X-Google-Smtp-Source: AKy350acwF21E3FgaR31isG0W7b3TvOdc9OKu4ODoNdNUQ+S27F7OyEozXGFeiQOD3uv8mKO+TZRZA== X-Received: by 2002:a17:902:cec9:b0:1a1:924d:19f6 with SMTP id d9-20020a170902cec900b001a1924d19f6mr4654252plg.66.1681498720752; Fri, 14 Apr 2023 11:58:40 -0700 (PDT) X-Received: from localhost.localdomain (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id g20-20020a170902869400b001a681d123a0sm3329760plo.297.2023.04.14.11.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 11:58:40 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, sunilvl@ventanamicro.com, git@danielschaefer.me, andrei.warkentin@intel.com, Tuan Phan Subject: [edk2-devel] [PATCH v2 4/6] OvmfPkg/RiscVVirt: VirtNorFlashPlatformLib: Fix wrong flash size Date: Fri, 14 Apr 2023 11:58:13 -0700 Message-Id: <20230414185815.2994-5-tphan@ventanamicro.com> In-Reply-To: <20230414185815.2994-1-tphan@ventanamicro.com> References: <20230414185815.2994-1-tphan@ventanamicro.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,tphan@ventanamicro.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1681498722; bh=R011i1Xgk6MQg1eaTR/GqCb+FHa49mPNQ7brugSrq+Q=; h=Cc:Date:From:Reply-To:Subject:To; b=ut792wnjA8oS4HEGhup1UAI8/6Q2178FZaDoaZffbFgpGbhbR4l6pfJsEm7uyy0NzmM G4Y1c6WTYEWiAuqv4G8KcYhDPGe1HRtvvDRyuewBqy85ZalPhWdvCxZ8hvSPzvp+95zwy l7sLqOCLNDIzyh7kJDluG03glv3P7QUtg0I= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1681498724415100023 Content-Type: text/plain; charset="utf-8" The size should be for single region, not the whole firmware FD. Signed-off-by: Tuan Phan Reviewed-by: Andrei Warkentin --- .../Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlash= StaticLib.c b/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlas= hStaticLib.c index fdc2ccb6294e..33f3a01b06f4 100644 --- a/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticL= ib.c +++ b/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticL= ib.c @@ -24,7 +24,8 @@ VIRT_NOR_FLASH_DESCRIPTION mNorFlashDevice =3D { FixedPcdGet32 (PcdOvmfFdBaseAddress), FixedPcdGet64 (PcdFlashNvStorageVariableBase), - FixedPcdGet32 (PcdOvmfFirmwareFdSize), + FixedPcdGet32 (PcdOvmfFirmwareFdSize) - + (FixedPcdGet64 (PcdFlashNvStorageVariableBase) - FixedPcdGet32 (PcdOvmfF= dBaseAddress)), QEMU_NOR_BLOCK_SIZE }; =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 (#103019): https://edk2.groups.io/g/devel/message/103019 Mute This Topic: https://groups.io/mt/98269077/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 Sun May 19 14:14:20 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+103020+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+103020+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1681498723; cv=none; d=zohomail.com; s=zohoarc; b=RzWAo7MhUtOmdM4VHxDjfsG3x4JIRUgAsCTZgvv89/qdWak5yaS5T4+jau8CfB+6vQycZEYsiFQp/CDd6mMGy3CadLd6sB7fjk7OZjwKhrWycOdzG5oSlcIN7KpHR2z6KehefNR8uAp2z4v8ziqowWL5XlCxKv+0FWYFnsGBer0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681498723; 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=5/XU/lZkk1DnSBz3Dt9DBUWBePwm4oXZyukDbVc+Iy0=; b=cJ+r6Hf7nEwo0FrtcK/EYquA82MYI/UuRTjyVd5W6CJAyFqzRMBN6oTV6fqkZ5HBKOlqheRHjMZk+hAc1FbsMFUbaOHcHGcSOTXyeMBOO1zcbr8uwlGNkyeVG+QuBuPwb0iWE/4UA1CC4BpEK1qjcGj8231TJ9zGueqbq66Pi9I= 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+103020+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1681498723897430.04104179499006; Fri, 14 Apr 2023 11:58:43 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qjn0YY1788612xbO519AYdfT; Fri, 14 Apr 2023 11:58:43 -0700 X-Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mx.groups.io with SMTP id smtpd.web11.19132.1681498720289713627 for ; Fri, 14 Apr 2023 11:58:43 -0700 X-Received: by mail-pl1-f181.google.com with SMTP id y6so18156924plp.2 for ; Fri, 14 Apr 2023 11:58:42 -0700 (PDT) X-Gm-Message-State: NXfTH1RfUKBefSS0XXLaH173x1787277AA= X-Google-Smtp-Source: AKy350YnEqrC+F6J01gxAFs3WiHIYZKgDlh8flaPXKg/rkeqoljRR+cIie/K2HCFDJqSQ2aT9ThhgQ== X-Received: by 2002:a17:902:f707:b0:1a2:296:9355 with SMTP id h7-20020a170902f70700b001a202969355mr3818131plo.16.1681498722198; Fri, 14 Apr 2023 11:58:42 -0700 (PDT) X-Received: from localhost.localdomain (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id g20-20020a170902869400b001a681d123a0sm3329760plo.297.2023.04.14.11.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 11:58:41 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, sunilvl@ventanamicro.com, git@danielschaefer.me, andrei.warkentin@intel.com, Tuan Phan Subject: [edk2-devel] [PATCH v2 5/6] OvmfPkg/VirtNorFlashDxe: Not add memory space if it exists Date: Fri, 14 Apr 2023 11:58:14 -0700 Message-Id: <20230414185815.2994-6-tphan@ventanamicro.com> In-Reply-To: <20230414185815.2994-1-tphan@ventanamicro.com> References: <20230414185815.2994-1-tphan@ventanamicro.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,tphan@ventanamicro.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1681498723; bh=DOn36mgWmy7dt/jlcNeAOmVC7+2f9X8+nXuvBdedQq8=; h=Cc:Date:From:Reply-To:Subject:To; b=Qesmc7Ism1MmjyJjgVbwsVgu4ScPUKmZ7LmzWukUSPcCKJg4bPr34LgAUyTesKBek/y SIkqM9yFVQCl9QwEg16fd908mEhML3Dr7daaWflXXMxicuFAYOc3NwOejO6woAVLyQcGe YcxIWj3szaTUnuWcOf0Pm3+YSZuDYZl7bxM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1681498725421100025 Content-Type: text/plain; charset="utf-8" The flash base address can be added to GCD before this driver run. So only add it if it has not been done. Signed-off-by: Tuan Phan Reviewed-by: Andrei Warkentin --- OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c | 25 +++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c b/OvmfPkg/VirtNorFla= shDxe/VirtNorFlashDxe.c index 6b9ef261335e..bbd1697a51dd 100644 --- a/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c +++ b/OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.c @@ -372,10 +372,11 @@ NorFlashFvbInitialize ( IN NOR_FLASH_INSTANCE *Instance ) { - EFI_STATUS Status; - UINT32 FvbNumLba; - EFI_BOOT_MODE BootMode; - UINTN RuntimeMmioRegionSize; + EFI_STATUS Status; + UINT32 FvbNumLba; + EFI_BOOT_MODE BootMode; + UINTN RuntimeMmioRegionSize; + EFI_GCD_MEMORY_SPACE_DESCRIPTOR Desc; =20 DEBUG ((DEBUG_BLKIO, "NorFlashFvbInitialize\n")); ASSERT ((Instance !=3D NULL)); @@ -390,13 +391,19 @@ NorFlashFvbInitialize ( // is written as the base of the flash region (ie: Instance->Devic= eBaseAddress) RuntimeMmioRegionSize =3D (Instance->RegionBaseAddress - Instance->Devic= eBaseAddress) + Instance->Size; =20 - Status =3D gDS->AddMemorySpace ( - EfiGcdMemoryTypeMemoryMappedIo, + Status =3D gDS->GetMemorySpaceDescriptor ( Instance->DeviceBaseAddress, - RuntimeMmioRegionSize, - EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + &Desc ); - ASSERT_EFI_ERROR (Status); + if (Status =3D=3D EFI_NOT_FOUND) { + Status =3D gDS->AddMemorySpace ( + EfiGcdMemoryTypeMemoryMappedIo, + Instance->DeviceBaseAddress, + RuntimeMmioRegionSize, + EFI_MEMORY_UC | EFI_MEMORY_RUNTIME + ); + ASSERT_EFI_ERROR (Status); + } =20 Status =3D gDS->SetMemorySpaceAttributes ( Instance->DeviceBaseAddress, --=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 (#103020): https://edk2.groups.io/g/devel/message/103020 Mute This Topic: https://groups.io/mt/98269078/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 Sun May 19 14:14:20 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+103021+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+103021+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1681498725; cv=none; d=zohomail.com; s=zohoarc; b=XCteI6hTtOHGTyM+pw4b9iQUOOv6zA5rHGWOpgm+KzQhbth+eZ90MH8eHsqSyFwlcTox/YpyG/06phO/Amafu+RHbaj06Rofgkdqw6PZsvnYws3x8CDTa4TILefRt+Q9xU5QcPtvOo0D9dGMsAt4W7SrTMeR+k/kqgClbxDLw0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681498725; 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=U+W3H2ylhwJ1e0MVpAnN9SHxPBsMHAgNn7m2m460EIs=; b=gTw2iLYmFISr0Or5QmZbeLW+AF03DyFHubo7ViXFuiI1JajdN6SYho3LGH45Ncv7Kp+31dlWgdpjVX+ECMHG43iFe4nviFpS5SW1/9LK4GZUXGmo6zDCozGkcSIZQhDkVo2Yat0phhxiTA2zYOVoj89nYo3M0fRU+8AaTL45sJI= 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+103021+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 168149872589054.550606932940696; Fri, 14 Apr 2023 11:58:45 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 2t7CYY1788612xfTl8TdbOV7; Fri, 14 Apr 2023 11:58:45 -0700 X-Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mx.groups.io with SMTP id smtpd.web10.19046.1681498724900000614 for ; Fri, 14 Apr 2023 11:58:44 -0700 X-Received: by mail-pl1-f174.google.com with SMTP id lh8so6260128plb.1 for ; Fri, 14 Apr 2023 11:58:44 -0700 (PDT) X-Gm-Message-State: R2L0C88q4P466M5zq7L29EGkx1787277AA= X-Google-Smtp-Source: AKy350Zyehw4CYUta3psjpLOcOVzrvVXcYSrR9XbFYycwhYo45/B55hXK2nO/9B/Ma+n/CSNNJFYVQ== X-Received: by 2002:a17:903:40c8:b0:1a4:fc40:bf04 with SMTP id t8-20020a17090340c800b001a4fc40bf04mr4229255pld.27.1681498723659; Fri, 14 Apr 2023 11:58:43 -0700 (PDT) X-Received: from localhost.localdomain (c-174-50-177-95.hsd1.ca.comcast.net. [174.50.177.95]) by smtp.gmail.com with ESMTPSA id g20-20020a170902869400b001a681d123a0sm3329760plo.297.2023.04.14.11.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 11:58:43 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: michael.d.kinney@intel.com, gaoliming@byosoft.com.cn, zhiguang.liu@intel.com, sunilvl@ventanamicro.com, git@danielschaefer.me, andrei.warkentin@intel.com, Tuan Phan Subject: [edk2-devel] [PATCH v2 6/6] OvmfPkg/RiscVVirt: SEC: Add IO memory resource hob for platform devices Date: Fri, 14 Apr 2023 11:58:15 -0700 Message-Id: <20230414185815.2994-7-tphan@ventanamicro.com> In-Reply-To: <20230414185815.2994-1-tphan@ventanamicro.com> References: <20230414185815.2994-1-tphan@ventanamicro.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,tphan@ventanamicro.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1681498725; bh=TSB+I687XzNxS3F06DNTm+0CGIvAp/GYLr893/7i9lY=; h=Cc:Date:From:Reply-To:Subject:To; b=KtN1CS+jymx1cC9nlwedQOimSIuBuqP+94zSIzGPt65ovfrL/yF0hvIurZ6mdJ8Fkb+ ElZlqKa6eSlT5c+rkF24iENTt445o7obdGwqHt07u0Xg8VivTR1xKToAdmiKzrb5U9Qj3 U4xHwYhPOfEJ5HgnMT85u8wFcHxOR/BtEmc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1681498727455100029 Content-Type: text/plain; charset="utf-8" Normally, DXE driver would add device resource to GCD before start using. But some key resources such as uart, flash base address are being accessing directly in some core modules. Those resources should be populated to HOB in SEC phase so they are added to GCD before anyone can access them. Signed-off-by: Tuan Phan Reviewed-by: Andrei Warkentin --- OvmfPkg/RiscVVirt/Sec/Platform.c | 62 +++++++++++++++++++++++++++++++ OvmfPkg/RiscVVirt/Sec/SecMain.inf | 1 + 2 files changed, 63 insertions(+) diff --git a/OvmfPkg/RiscVVirt/Sec/Platform.c b/OvmfPkg/RiscVVirt/Sec/Platf= orm.c index 3645c27b0b12..944b82c84a6e 100644 --- a/OvmfPkg/RiscVVirt/Sec/Platform.c +++ b/OvmfPkg/RiscVVirt/Sec/Platform.c @@ -21,6 +21,63 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include =20 +/** + Build memory map I/O range resource HOB using the + base address and size. + + @param MemoryBase Memory map I/O base. + @param MemorySize Memory map I/O size. + +**/ +STATIC +VOID +AddIoMemoryBaseSizeHob ( + EFI_PHYSICAL_ADDRESS MemoryBase, + UINT64 MemorySize + ) +{ + /* Align to EFI_PAGE_SIZE */ + MemorySize =3D ALIGN_VALUE (MemorySize, EFI_PAGE_SIZE); + BuildResourceDescriptorHob ( + EFI_RESOURCE_MEMORY_MAPPED_IO, + EFI_RESOURCE_ATTRIBUTE_PRESENT | + EFI_RESOURCE_ATTRIBUTE_INITIALIZED | + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | + EFI_RESOURCE_ATTRIBUTE_TESTED, + MemoryBase, + MemorySize + ); +} + +/** + Populate IO resources from FDT that not added to GCD by its + driver in the DXE phase.=20 + + @param FdtBase Fdt base address + @param Compatible Compatible string + +**/ +STATIC +VOID +PopulateIoResources ( + VOID *FdtBase, + CONST CHAR8* Compatible + ) +{ + UINT64 *Reg; + INT32 Node, LenP; + + Node =3D fdt_node_offset_by_compatible (FdtBase, -1, Compatible); + while (Node !=3D -FDT_ERR_NOTFOUND) { + Reg =3D (UINT64 *)fdt_getprop (FdtBase, Node, "reg", &LenP); + if (Reg) { + ASSERT (LenP =3D=3D (2 * sizeof (UINT64))); + AddIoMemoryBaseSizeHob (SwapBytes64 (Reg[0]), SwapBytes64 (Reg[1])); + } + Node =3D fdt_node_offset_by_compatible (FdtBase, Node, Compatible); + } +} + /** @retval EFI_SUCCESS The address of FDT is passed in HOB. EFI_UNSUPPORTED Can't locate FDT. @@ -80,5 +137,10 @@ PlatformPeimInitialization ( =20 BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSiz= e)); =20 + PopulateIoResources (Base, "ns16550a"); + PopulateIoResources (Base, "qemu,fw-cfg-mmio"); + PopulateIoResources (Base, "virtio,mmio"); + AddIoMemoryBaseSizeHob (PcdGet32 (PcdOvmfFdBaseAddress), PcdGet32 (PcdOv= mfFirmwareFdSize)); + return EFI_SUCCESS; } diff --git a/OvmfPkg/RiscVVirt/Sec/SecMain.inf b/OvmfPkg/RiscVVirt/Sec/SecM= ain.inf index aed35d3af596..e1f562264eea 100644 --- a/OvmfPkg/RiscVVirt/Sec/SecMain.inf +++ b/OvmfPkg/RiscVVirt/Sec/SecMain.inf @@ -61,6 +61,7 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize =20 [Guids] gFdtHobGuid --=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 (#103021): https://edk2.groups.io/g/devel/message/103021 Mute This Topic: https://groups.io/mt/98269080/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-