From nobody Wed May 15 11:29:23 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+106092+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+106092+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1686762121; cv=none; d=zohomail.com; s=zohoarc; b=fun+RAPis70oatDLDbPEDtF0mm0sf8lcrOhosiCFXaqqrc6ILLOCdPj1LEH2my8T5b2c2HuXPkn/emt8DnHr9Wk1RV1vx7/KVam5EOTc7AqHJsFIfAZ5hG0gAVuhqkFFcHycAVFj8zEJGRZw8x1I8zUw6qlJ7ywLrKClFL0QjJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686762121; 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=b6W+XKsin7CrqkQcyVUzU5x4XxQcHBexnOOEpiic3Tg=; b=lMmbBOwQU52Gix/AF1lEupxAUyo0WKGdNMLHImIQxK7ViAXtHW9LqV6Roz+mRqzFChwlJo6rvvvwmpedUD4s2vzBMphWvU8XY9WyEMrpHDxyYLnF9gvTKNrbkrCwCp5BfJ4wkQ7Kkev5BMH+VH8EYBz7/JTGNfXl6L8ECplIFqM= 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+106092+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1686762121344168.71756455112518; Wed, 14 Jun 2023 10:02:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id rFxxYY1788612xCEjRhLSA5M; Wed, 14 Jun 2023 10:02:00 -0700 X-Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mx.groups.io with SMTP id smtpd.web11.18271.1686762120017339764 for ; Wed, 14 Jun 2023 10:02:00 -0700 X-Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1b4f8523197so8333645ad.1 for ; Wed, 14 Jun 2023 10:01:59 -0700 (PDT) X-Gm-Message-State: bX6xmmlpN6cOekHuHau5RJwfx1787277AA= X-Google-Smtp-Source: ACHHUZ40EqqlM0IyunYpjrO53V2PeA6jvto7/jJdSSqJj6n9+IdqCrMn44rZHpZeeqfD58hLkjfE8g== X-Received: by 2002:a17:902:e744:b0:1b3:c4c1:ec4e with SMTP id p4-20020a170902e74400b001b3c4c1ec4emr3030244plf.30.1686762119307; Wed, 14 Jun 2023 10:01:59 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id s7-20020a170902988700b001b3ef11d8fdsm1850424plp.201.2023.06.14.10.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 10:01:59 -0700 (PDT) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann , Andrei Warkentin Subject: [edk2-devel] [PATCH 1/4] OvmfPkg/RiscVVirt: Fix couple of issues in VarStore Date: Wed, 14 Jun 2023 22:31:48 +0530 Message-Id: <20230614170151.1204982-2-sunilvl@ventanamicro.com> In-Reply-To: <20230614170151.1204982-1-sunilvl@ventanamicro.com> References: <20230614170151.1204982-1-sunilvl@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,sunilvl@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=1686762120; bh=XOlEXcae7jbj7o8Fg4LEXDmmkhcOHx/er7B3lqCOB9M=; h=Cc:Date:From:Reply-To:Subject:To; b=YO0dF+o76R60yle0TbDpWphO2wuJkyvXyamvwZD+RipbjV6Y7DBdlN6vmaaGRfCMe2e uFN9h47jM5lhNh2sOehOCORpuW6Be6muw38Z7vpRF49FjhUlqPMPnGASvoi6apFJyygOv rOZPa/IH7nd94EMjTYqNL7MvuB09uYLT8mw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686762123745100001 Content-Type: text/plain; charset="utf-8" The size of the FV and the WriteQueueSize is incorrect which causes the flash to be re-written during boot. Fix them and update the new checksum value. Signed-off-by: Sunil V L Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Cc: Andrei Warkentin --- OvmfPkg/RiscVVirt/VarStore.fdf.inc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OvmfPkg/RiscVVirt/VarStore.fdf.inc b/OvmfPkg/RiscVVirt/VarStor= e.fdf.inc index 30b170d77997..6bc619e50c1a 100644 --- a/OvmfPkg/RiscVVirt/VarStore.fdf.inc +++ b/OvmfPkg/RiscVVirt/VarStore.fdf.inc @@ -25,12 +25,12 @@ # { 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50 }} 0x8D, 0x2B, 0xF1, 0xFF, 0x96, 0x76, 0x8B, 0x4C, 0xA9, 0x85, 0x27, 0x47, 0x07, 0x5B, 0x4F, 0x50, - # FvLength: 0x20000 - 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + # FvLength: 0xC0000 + 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, # Signature "_FVH" # Attributes 0x5f, 0x46, 0x56, 0x48, 0xff, 0xfe, 0x04, 0x00, # HeaderLength # CheckSum # ExtHeaderOffset #Reserved #Revision - 0x48, 0x00, 0x39, 0xF1, 0x00, 0x00, 0x00, 0x02, + 0x48, 0x00, 0x2F, 0xF1, 0x00, 0x00, 0x00, 0x02, # Blockmap[0]: 0x20 Blocks * 0x1000 Bytes / Block 0x00, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, # Blockmap[1]: End @@ -60,7 +60,7 @@ $(VARS_FTW_WORKING_OFFSET)|$(VARS_FTW_WORKING_SIZE) gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|gEfiMdeModu= lePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize # -#NV_FTW_WROK +#NV_FTW_WORK # DATA =3D { # EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature =3D gEdkiiWorkingBl= ockSignatureGuid =3D @@ -68,9 +68,9 @@ 0x2b, 0x29, 0x58, 0x9e, 0x68, 0x7c, 0x7d, 0x49, 0xa0, 0xce, 0x65, 0x0, 0xfd, 0x9f, 0x1b, 0x95, # Crc:UINT32 #WorkingBlockValid:1, WorkingBlockInvalid:1, Res= erved - 0x2c, 0xaf, 0x2c, 0x64, 0xFE, 0xFF, 0xFF, 0xFF, + 0x5b, 0xe7, 0xc6, 0x86, 0xFE, 0xFF, 0xFF, 0xFF, # WriteQueueSize: UINT64 - 0xE0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + 0xE0, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 } =20 $(VARS_FTW_SPARE_OFFSET)|$(VARS_FTW_SPARE_SIZE) --=20 2.34.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 (#106092): https://edk2.groups.io/g/devel/message/106092 Mute This Topic: https://groups.io/mt/99532022/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 15 11:29:23 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+106093+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+106093+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1686762123; cv=none; d=zohomail.com; s=zohoarc; b=lD/7bODdUIpjtkYEink+rwAxyqqhhHOUtBwcoaSYE1PygyFAQTreUgYy6ArYCIeVTL/35LEffJhTKJ0yxGkXRyXDLv0vuvL/duoAam6/VOemOEaLeUkhxBmmmP+No7lvtGjMQrPabDVkRFvMwMiTeUTwfu47FleQdmEe/AdyBjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686762123; 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=oDBPGlARMv4+sHaMSf5mOz1IvKYMYcDWH7aIMqp0bok=; b=T9IN2xypdhK9leRTz8ICSa1sd2yCzMajDNtipmIC0dqrm3m8BjBw3asoIHeCN9SGpH/xsgLl7TvznsC98Nk8NoUh5ivNvb4lk9stvdkb/3tHRzfBPQ4tu6lIZ0LvtQ18J5jtDPLfWK9yiQEChFmfhUmqIYIzPHPl+CNSA9XmmxA= 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+106093+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1686762123499548.5374012748315; Wed, 14 Jun 2023 10:02:03 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6l7DYY1788612xuBdTO23gv8; Wed, 14 Jun 2023 10:02:03 -0700 X-Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mx.groups.io with SMTP id smtpd.web11.18278.1686762122529910620 for ; Wed, 14 Jun 2023 10:02:02 -0700 X-Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-666683eb028so527019b3a.0 for ; Wed, 14 Jun 2023 10:02:02 -0700 (PDT) X-Gm-Message-State: d8VGGJswS96fL6P0dChVgl0Ax1787277AA= X-Google-Smtp-Source: ACHHUZ5R9e39oCiM2yeQltWYVhF4Md5W/hdtxQKQCtMp13/JPvGSEZeyFqOnJytYuBaTLTMN1XJ3OQ== X-Received: by 2002:a05:6a20:431f:b0:10b:2f5a:83af with SMTP id h31-20020a056a20431f00b0010b2f5a83afmr2034911pzk.16.1686762121759; Wed, 14 Jun 2023 10:02:01 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id s7-20020a170902988700b001b3ef11d8fdsm1850424plp.201.2023.06.14.10.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 10:02:01 -0700 (PDT) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann , Andrei Warkentin Subject: [edk2-devel] [PATCH 2/4] OvmfPkg/RiscVVirt: Add VirtNorFlashDeviceTreeLib library Date: Wed, 14 Jun 2023 22:31:49 +0530 Message-Id: <20230614170151.1204982-3-sunilvl@ventanamicro.com> In-Reply-To: <20230614170151.1204982-1-sunilvl@ventanamicro.com> References: <20230614170151.1204982-1-sunilvl@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,sunilvl@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=1686762123; bh=qaQQAOsT/24KI2AsHwsfA1cSZQtWYCQ81FyD3rXAtlo=; h=Cc:Date:From:Reply-To:Subject:To; b=oopst1TO1tn22j3TAUCFOE+TPnyowIGF9DwXDjzCoFgAdg9XtWv4MDpOy4fq01XO4X1 2vzED+QDyllqqF4FvfHKvqNkHW4defVQ7LxT7D4ZYXDyM+R9tT7gvkG7o73tSAXHUeSE1 Tw32Gh/zCCZMghTUlexlSHsby/hoU5FeAj0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686762124879100004 Content-Type: text/plain; charset="utf-8" This library is required to support separate code and variable store images. Signed-off-by: Sunil V L Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Cc: Andrei Warkentin --- .../VirtNorFlashDeviceTreeLib.inf | 40 +++++ .../VirtNorFlashDeviceTreeLib.c | 137 ++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtN= orFlashDeviceTreeLib.inf create mode 100644 OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtN= orFlashDeviceTreeLib.c diff --git a/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlash= DeviceTreeLib.inf b/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtN= orFlashDeviceTreeLib.inf new file mode 100644 index 000000000000..90df756e79a9 --- /dev/null +++ b/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceT= reeLib.inf @@ -0,0 +1,40 @@ +#/** @file +# +# Component description file for VirtNorFlashDeviceTreeLib module +# +# 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 VirtNorFlashDeviceTreeLib + FILE_GUID =3D 1D74E65F-A468-4FA6-ACB6-E4E941EB79D6 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D VirtNorFlashPlatformLib + +[Sources.common] + VirtNorFlashDeviceTreeLib.c + +[Packages] + MdePkg/MdePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + OvmfPkg/OvmfPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + UefiBootServicesTableLib + +[Protocols] + gFdtClientProtocolGuid ## CONSUMES + +[Depex] + gFdtClientProtocolGuid + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize diff --git a/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlash= DeviceTreeLib.c b/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNor= FlashDeviceTreeLib.c new file mode 100644 index 000000000000..73534a866430 --- /dev/null +++ b/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceT= reeLib.c @@ -0,0 +1,137 @@ +/** @file + + Copyright (c) 2014-2018, Linaro Ltd. 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 + +#define QEMU_NOR_BLOCK_SIZE SIZE_256KB + +#define MAX_FLASH_BANKS 4 + +EFI_STATUS +VirtNorFlashPlatformInitialization ( + VOID + ) +{ + return EFI_SUCCESS; +} + +STATIC VIRT_NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_BANKS]; + +EFI_STATUS +VirtNorFlashPlatformGetDevices ( + OUT VIRT_NOR_FLASH_DESCRIPTION **NorFlashDescriptions, + OUT UINT32 *Count + ) +{ + FDT_CLIENT_PROTOCOL *FdtClient; + INT32 Node; + EFI_STATUS Status; + EFI_STATUS FindNodeStatus; + CONST UINT32 *Reg; + UINT32 PropSize; + UINT32 Num; + UINT64 Base; + UINT64 Size; + + Status =3D gBS->LocateProtocol ( + &gFdtClientProtocolGuid, + NULL, + (VOID **)&FdtClient + ); + ASSERT_EFI_ERROR (Status); + + Num =3D 0; + for (FindNodeStatus =3D FdtClient->FindCompatibleNode ( + FdtClient, + "cfi-flash", + &Node + ); + !EFI_ERROR (FindNodeStatus) && Num < MAX_FLASH_BANKS; + FindNodeStatus =3D FdtClient->FindNextCompatibleNode ( + FdtClient, + "cfi-flash", + Node, + &Node + )) + { + Status =3D FdtClient->GetNodeProperty ( + FdtClient, + Node, + "reg", + (CONST VOID **)&Reg, + &PropSize + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: GetNodeProperty () failed (Status =3D=3D %r)\n", + __func__, + Status + )); + continue; + } + + ASSERT ((PropSize % (4 * sizeof (UINT32))) =3D=3D 0); + + while (PropSize >=3D (4 * sizeof (UINT32)) && Num < MAX_FLASH_BANKS) { + Base =3D SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[0])); + Size =3D SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2])); + Reg +=3D 4; + + PropSize -=3D 4 * sizeof (UINT32); + + // + // Disregard any flash devices that overlap with the primary FV. + // The firmware is not updatable from inside the guest anyway. + // + if ((PcdGet32 (PcdOvmfFdBaseAddress) + PcdGet32 (PcdOvmfFirmwareFdSi= ze) > Base) && + ((Base + Size) > PcdGet32 (PcdOvmfFdBaseAddress))) + { + continue; + } + + mNorFlashDevices[Num].DeviceBaseAddress =3D (UINTN)Base; + mNorFlashDevices[Num].RegionBaseAddress =3D (UINTN)Base; + mNorFlashDevices[Num].Size =3D (UINTN)Size; + mNorFlashDevices[Num].BlockSize =3D QEMU_NOR_BLOCK_SIZE; + Num++; + } + + // + // UEFI takes ownership of the NOR flash, and exposes its functionality + // through the UEFI Runtime Services GetVariable, SetVariable, etc. Th= is + // means we need to disable it in the device tree to prevent the OS fr= om + // attaching its device driver as well. + // Note that this also hides other flash banks, but the only other fla= sh + // bank we expect to encounter is the one that carries the UEFI execut= able + // code, which is not intended to be guest updatable, and is usually b= acked + // in a readonly manner by QEMU anyway. + // + Status =3D FdtClient->SetNodeProperty ( + FdtClient, + Node, + "status", + "disabled", + sizeof ("disabled") + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "Failed to set NOR flash status to 'disabled'\n"= )); + } + } + + *NorFlashDescriptions =3D mNorFlashDevices; + *Count =3D Num; + + return EFI_SUCCESS; +} --=20 2.34.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 (#106093): https://edk2.groups.io/g/devel/message/106093 Mute This Topic: https://groups.io/mt/99532023/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 15 11:29:23 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+106094+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+106094+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1686762126; cv=none; d=zohomail.com; s=zohoarc; b=GMX9XbGFPcHvBlnp98Z6bf6MMfXmp38c5aj8KFpFjFA0CAU9pd5850ymliXB3k4KIFA5LEcLStJ7PsQafxLkQypvZJ/ReNXYtOjzJNGpb0lUrZM0ktVC/9bJG6AsH7zg65CbpRpFlKhG+8Jw+uP2PUn6o6WgAXK9zYcF3X1YvZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686762126; 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=lpmnzkk4FFErEtJ3c/n0C4EsLA4dYqgYxqdVzjGKCII=; b=dn1VMnUCalJpypnn+DYR68F2nrr2Ls/6hNpHGdo1TtCrNN4AGbXq/ch//rdAnfwxGsb6y0/ATp5V+aTZvHyHNsf6s+KBQrHef7cLMXEUl701Waceg1EbKrgMwlkle6oNWVcaZ3fl2FkGw5G+hzUcJQqWwidwH6O4C0uzB7OfPto= 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+106094+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1686762126269109.3177278057193; Wed, 14 Jun 2023 10:02:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id MIiyYY1788612xkPmDkVfFj5; Wed, 14 Jun 2023 10:02:05 -0700 X-Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by mx.groups.io with SMTP id smtpd.web10.18169.1686762124978230603 for ; Wed, 14 Jun 2023 10:02:05 -0700 X-Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-66577752f05so2893200b3a.0 for ; Wed, 14 Jun 2023 10:02:04 -0700 (PDT) X-Gm-Message-State: wlhzSK6TGfYh4zbfDozqWD0ax1787277AA= X-Google-Smtp-Source: ACHHUZ7MfX4gJs0nq0XXhl5fSrFGOLb13MEUiw7+MyDgh+geNDr62ehnqMhkF+l1m+83J9s3FjoZhA== X-Received: by 2002:a17:902:d4cf:b0:1af:d213:668c with SMTP id o15-20020a170902d4cf00b001afd213668cmr14562316plg.12.1686762124252; Wed, 14 Jun 2023 10:02:04 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id s7-20020a170902988700b001b3ef11d8fdsm1850424plp.201.2023.06.14.10.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 10:02:03 -0700 (PDT) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann , Andrei Warkentin Subject: [edk2-devel] [PATCH 3/4] OvmfPkg/RiscVVirt: Add support for separate code and variable store Date: Wed, 14 Jun 2023 22:31:50 +0530 Message-Id: <20230614170151.1204982-4-sunilvl@ventanamicro.com> In-Reply-To: <20230614170151.1204982-1-sunilvl@ventanamicro.com> References: <20230614170151.1204982-1-sunilvl@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,sunilvl@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=1686762125; bh=BjU1A7749Tk7ErT1er+REkvzKsSKHmySXGDwLdIQOg4=; h=Cc:Date:From:Reply-To:Subject:To; b=Je+32OjuvXMzc1PBcIY99uMt2thf2SLLtUEHfR1GrBRkmHVvSMgit8AZu6tlqpGi28t pkm3ED86PJZJ5nJ2DnGtj6KNPVfdtKh+i/0kMNEnkv4p1b/QRr+6WrPi5tOnQVa2pI6Lp jwwswzI1fMU4yBsCr0c78zKONTSZP1KBKwU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686762127111100009 Content-Type: text/plain; charset="utf-8" Currently, RiscVVirtQemu supports unified code and variable store mainly because only one pflash devices was available in qemu for EDK2. However, this doesn't allow to map the code part as read-only. With recent qemu enhancements, it is now possible for EDK2 to make use of both pflash devices in RISC-V virt machine. So, add support to create code and vars images separately. This also allows easy firmware code updates without losing the variable store. Signed-off-by: Sunil V L Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Cc: Andrei Warkentin --- OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc | 2 +- OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf | 9 +++++---- OvmfPkg/RiscVVirt/RiscVVirt.fdf.inc | 12 +++++------- OvmfPkg/RiscVVirt/VarStore.fdf.inc | 13 ++++++++++--- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc b/OvmfPkg/RiscVVirt/RiscVV= irtQemu.dsc index 414d186179fb..04573bc0f32e 100644 --- a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc +++ b/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc @@ -85,7 +85,7 @@ [LibraryClasses.common] QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoad= ImageLib.inf =20 TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLi= b.inf - VirtNorFlashPlatformLib|OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLi= b/VirtNorFlashStaticLib.inf + VirtNorFlashPlatformLib|OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLi= b/VirtNorFlashDeviceTreeLib.inf =20 CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf diff --git a/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf b/OvmfPkg/RiscVVirt/RiscVV= irtQemu.fdf index 354c9271d10c..dbe38a135395 100644 --- a/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf +++ b/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf @@ -12,17 +12,18 @@ !include RiscVVirt.fdf.inc =20 ##########################################################################= ###### -[FD.RISCV_VIRT] -BaseAddress =3D $(FW_BASE_ADDRESS)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdB= aseAddress -Size =3D $(FW_SIZE)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdS= ize +[FD.RISCV_VIRT_CODE] +BaseAddress =3D $(CODE_BASE_ADDRESS)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfF= dBaseAddress +Size =3D $(CODE_SIZE)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareF= dSize ErasePolarity =3D 1 BlockSize =3D $(BLOCK_SIZE) -NumBlocks =3D $(FW_BLOCKS) +NumBlocks =3D $(CODE_BLOCKS) =20 0x00000000|$(CODE_SIZE) gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.= PcdOvmfDxeMemFvSize FV =3D FVMAIN_COMPACT =20 +##########################################################################= ###### !include VarStore.fdf.inc ##########################################################################= ###### =20 diff --git a/OvmfPkg/RiscVVirt/RiscVVirt.fdf.inc b/OvmfPkg/RiscVVirt/RiscVV= irt.fdf.inc index b0a1c3293f33..7e8165d85778 100644 --- a/OvmfPkg/RiscVVirt/RiscVVirt.fdf.inc +++ b/OvmfPkg/RiscVVirt/RiscVVirt.fdf.inc @@ -10,16 +10,14 @@ [Defines] DEFINE BLOCK_SIZE =3D 0x1000 =20 +DEFINE PFLASH0_BASE =3D 0x20000000 DEFINE PFLASH1_BASE =3D 0x22000000 =20 -DEFINE FW_BASE_ADDRESS =3D $(PFLASH1_BASE) -DEFINE FW_SIZE =3D 0x00800000 -DEFINE FW_BLOCKS =3D 0x800 - -DEFINE CODE_BASE_ADDRESS =3D $(FW_BASE_ADDRESS) -DEFINE CODE_SIZE =3D 0x00740000 -DEFINE CODE_BLOCKS =3D 0x740 +DEFINE CODE_BASE_ADDRESS =3D $(PFLASH0_BASE) +DEFINE CODE_SIZE =3D 0x00800000 +DEFINE CODE_BLOCKS =3D 0x800 =20 +DEFINE VARS_BASE_ADDRESS =3D $(PFLASH1_BASE) DEFINE VARS_SIZE =3D 0x000C0000 DEFINE VARS_BLOCK_SIZE =3D 0x40000 DEFINE VARS_BLOCKS =3D 0x3 diff --git a/OvmfPkg/RiscVVirt/VarStore.fdf.inc b/OvmfPkg/RiscVVirt/VarStor= e.fdf.inc index 6bc619e50c1a..49293c742b56 100644 --- a/OvmfPkg/RiscVVirt/VarStore.fdf.inc +++ b/OvmfPkg/RiscVVirt/VarStore.fdf.inc @@ -10,7 +10,14 @@ # ## =20 -$(VARS_OFFSET)|$(VARS_LIVE_SIZE) +[FD.RISCV_VIRT_VARS] +BaseAddress =3D $(VARS_BASE_ADDRESS) +Size =3D $(VARS_SIZE) +ErasePolarity =3D 1 +BlockSize =3D $(VARS_BLOCK_SIZE) +NumBlocks =3D $(VARS_BLOCKS) + +0x00000000|$(VARS_LIVE_SIZE) gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|gEfiMdeModule= PkgTokenSpaceGuid.PcdFlashNvStorageVariableSize # # NV_VARIABLE_STORE @@ -57,7 +64,7 @@ 0x5A, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } =20 -$(VARS_FTW_WORKING_OFFSET)|$(VARS_FTW_WORKING_SIZE) +0x00040000|$(VARS_FTW_WORKING_SIZE) gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|gEfiMdeModu= lePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize # #NV_FTW_WORK @@ -73,7 +80,7 @@ 0xE0, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 } =20 -$(VARS_FTW_SPARE_OFFSET)|$(VARS_FTW_SPARE_SIZE) +0x00080000|$(VARS_FTW_SPARE_SIZE) gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|gEfiMdeModule= PkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize # #NV_FTW_SPARE --=20 2.34.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 (#106094): https://edk2.groups.io/g/devel/message/106094 Mute This Topic: https://groups.io/mt/99532024/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 15 11:29:23 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+106095+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+106095+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1686762129; cv=none; d=zohomail.com; s=zohoarc; b=E9JssdsoBzxbFnMkfIiGgun/1M3swGbIWlzWH1qFwFHowJCyCX27bypn5bpLwxWmMjMj0T5HD/QgwKn2iJRyDt9f6MhsMchMCvdKGJbkhOQ1Oz4XiaDtRhC9+tqQjX7Th8Q+H1sjW6L7uiKASwF6vEyW5ycoRY5JvD8WgKYpk44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686762129; 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=854meDkgHPx/EBongzvsGl7lDEMZYphBarXgLvPxlR8=; b=ZMIl2V2mkgGdD69ZKdvgXnXb2KDEonKu1AinLlmQLMJurXYVLmaMAUrBb5V+iH9L5TcPQxM9ecbIBAeH/auvuWLT+NFHXFRIPoZIecHOxyy6z5MEwbpfxI44epwU4dpDJ9dewnN67lrri4MyBaeDiHoYmdzSUaivwHo1Kz1nF58= 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+106095+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1686762128929997.9304028231395; Wed, 14 Jun 2023 10:02:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Zh4QYY1788612xcACfIbNLYh; Wed, 14 Jun 2023 10:02:08 -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.18171.1686762127896801207 for ; Wed, 14 Jun 2023 10:02:07 -0700 X-Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1b4f95833c7so6531555ad.1 for ; Wed, 14 Jun 2023 10:02:07 -0700 (PDT) X-Gm-Message-State: HOLrpKNm4xeiGmTaLSjDZcvRx1787277AA= X-Google-Smtp-Source: ACHHUZ6MZTjFlGai1QvFJBfCBOGcPfKzOc66VAektasT0T1r1a89CyyaP1myCJj5djtvYV/G0W9zlg== X-Received: by 2002:a17:902:7684:b0:1b3:9d13:34b3 with SMTP id m4-20020a170902768400b001b39d1334b3mr9981008pll.37.1686762126913; Wed, 14 Jun 2023 10:02:06 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id s7-20020a170902988700b001b3ef11d8fdsm1850424plp.201.2023.06.14.10.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 10:02:06 -0700 (PDT) From: "Sunil V L" To: devel@edk2.groups.io Cc: Sunil V L , Ard Biesheuvel , Jiewen Yao , Jordan Justen , Gerd Hoffmann , Andrei Warkentin Subject: [edk2-devel] [PATCH 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test Date: Wed, 14 Jun 2023 22:31:51 +0530 Message-Id: <20230614170151.1204982-5-sunilvl@ventanamicro.com> In-Reply-To: <20230614170151.1204982-1-sunilvl@ventanamicro.com> References: <20230614170151.1204982-1-sunilvl@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,sunilvl@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=1686762128; bh=API/au3cXxCuhxpKYmHdiexKvY+jDUuJyWkbWh/EJg0=; h=Cc:Date:From:Reply-To:Subject:To; b=rotcDcPnwGRIi6J2cjvnbaNrIPxmzIPyrDEgRYyrIdQFceIaU5pcbyLGqJoAm1iKKXD Mle70lE2NYVv0Pb42JLcSftSLVk2ahmsnMK5gEuJKBU2mBi8XU2Ey0v6v7scQe30fmJTU wlcNGd3i1WZpdgI/JPjwoSlxzi6ga5u2KKQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686762131226100005 Content-Type: text/plain; charset="utf-8" Add a readme file which provides information regarding how to build and test EDK2 on RISC-V qemu virt platform. Signed-off-by: Sunil V L Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Gerd Hoffmann Cc: Andrei Warkentin --- OvmfPkg/RiscVVirt/README.md | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 OvmfPkg/RiscVVirt/README.md diff --git a/OvmfPkg/RiscVVirt/README.md b/OvmfPkg/RiscVVirt/README.md new file mode 100644 index 000000000000..a1738658318d --- /dev/null +++ b/OvmfPkg/RiscVVirt/README.md @@ -0,0 +1,41 @@ +# Support for RISC-V qemu virt platform + +## Overview +RISC-V qemu 'virt' is a generic platform which does not correspond to any = real +hardware. + +EDK2 for RISC-V virt platform is a payload (S-mode) for a previous stage M= -mode +firmware like opensbi. It follows PEI less design. + +## Build + export WORKSPACE=3D`pwd` + export GCC5_RISCV64_PREFIX=3Driscv64-linux-gnu- + export PACKAGES_PATH=3D$WORKSPACE/edk2 + export EDK_TOOLS_PATH=3D$WORKSPACE/edk2/BaseTools + source edk2/edksetup.sh + make -C edk2/BaseTools + source edk2/edksetup.sh BaseTools + build -a RISCV64 --buildtarget RELEASE -p OvmfPkg/RiscVVirt/RiscVVirtQ= emu.dsc -t GCC5 + +## Test +1) RISC-V qemu pflash devices should be of of size 32MiB. + + `truncate -s 32M Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_CODE.f= d` + + `truncate -s 32M Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_VARS.f= d` + +2) Run qemu + + qemu-system-riscv64 \ + -accel tcg -m 4096 -smp 2 \ + -serial mon:stdio \ + -device virtio-gpu-pci -full-screen \ + -device qemu-xhci \ + -device usb-kbd \ + -blockdev node-name=3Dpflash0,driver=3Dfile,read-only=3Don,filenam= e=3DRISCV_VIRT_CODE.fd \ + -blockdev node-name=3Dpflash1,driver=3Dfile,filename=3DRISCV_VIRT_= VARS.fd \ + -M virt,pflash0=3Dpflash0,pflash1=3Dpflash1,acpi=3Doff \ + -kernel linux/arch/riscv/boot/Image \ + -initrd buildroot/output/images/rootfs.cpio \ + -netdev user,id=3Dnet0 -device virtio-net-pci,netdev=3Dnet0 \ + -append "root=3D/dev/ram rw console=3DttyS0 earlycon=3Duart8250,mm= io,0x10000000" --=20 2.34.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 (#106095): https://edk2.groups.io/g/devel/message/106095 Mute This Topic: https://groups.io/mt/99532027/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-