From nobody Thu May 16 22:30: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+106144+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+106144+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1686910622; cv=none; d=zohomail.com; s=zohoarc; b=OS2UozpmT2rBd1GsRuNzPGGcCwZYlLx6MkKXSYvMmcP4Hk9CtWr/RRjvdcPZWiECWlnBqJlg1apwr7YUugxdVGSplnhV/6ZPIUETluBnSCwScJ8iv2MIDJV82t/gXTTX5mvIkWoGUYpr06YTmGtKhytkoOMaWJ3T/AL4WSeCpPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686910622; 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=3PHxAWCrpgan3BWYgHOvUHn7RGtsTTLCZMB/Z0wED+Y=; b=LljAWGtv3PY4NRUp27FDYZgYIV8ZH7z8njqE/TVpXfwoBSTI5VjqHA7MbPkhBuDf0+igmV85QBvp+m//e+QncI1OoPVCHm0JscmJ6WUR8wRN2s/igGDRPZ8tIx6UxHLdZcP79rSQi8AX03PdX68YnV+GQXT6CmsG0HK5eD7fO9o= 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+106144+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1686910621995555.3265673843424; Fri, 16 Jun 2023 03:17:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id cmzZYY1788612xEHtkiNetTV; Fri, 16 Jun 2023 03:17:01 -0700 X-Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mx.groups.io with SMTP id smtpd.web10.5093.1686910620415585390 for ; Fri, 16 Jun 2023 03:17:00 -0700 X-Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1b5018cb4dcso3574055ad.2 for ; Fri, 16 Jun 2023 03:17:00 -0700 (PDT) X-Gm-Message-State: Pp9QNpps6tvUr14WkaGbvyMFx1787277AA= X-Google-Smtp-Source: ACHHUZ50PvGwmNv7op0iGU79vGiLKZ10N1XeSj8vkywtphkyIewQqtjr8jdiKB8sHa8o7XZL3CObvA== X-Received: by 2002:a17:902:bb96:b0:1ac:8837:de9 with SMTP id m22-20020a170902bb9600b001ac88370de9mr1099128pls.3.1686910619705; Fri, 16 Jun 2023 03:16:59 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001a1a82fc6d3sm15435565plf.268.2023.06.16.03.16.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jun 2023 03:16: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 v2 1/4] OvmfPkg/RiscVVirt: Fix couple of issues in VarStore Date: Fri, 16 Jun 2023 15:46:48 +0530 Message-Id: <20230616101651.1319722-2-sunilvl@ventanamicro.com> In-Reply-To: <20230616101651.1319722-1-sunilvl@ventanamicro.com> References: <20230616101651.1319722-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=1686910621; bh=jwWeqbBem6uPNKbl+KGfR+q8JvajeOi+DZXG/CQ3wns=; h=Cc:Date:From:Reply-To:Subject:To; b=h4X6pCXdwBwnpSEFsz2he8FK5+6S3pxDPP5p9EOtOSp0KIMM+Nn8FL3ooT3BIUy2RH6 QNj04vxfND3dNJZFAlaU1ueIOCgMbZmWnLS7pXw6kA0vbgM3RCeKoBV0DaVl8Yb93Ptjs JCFuC6F/Whe54VeuNegeBUPhiAaoLCufjgA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686910623930100003 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 (#106144): https://edk2.groups.io/g/devel/message/106144 Mute This Topic: https://groups.io/mt/99567397/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 Thu May 16 22:30: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+106145+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+106145+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1686910624; cv=none; d=zohomail.com; s=zohoarc; b=gauarGdUh+AxnRozymr0OheufjJ+MGCitp1D7B0d/sEfs6A1u9V00Ky+mkLl7utYlCMXyDF3xOhUZvXxWfVUNrqGk1n3VMiLOHLjhBAqL1YKjF/57Qtbbv1U7BX4c0Ygw4CtQUumEMgr7WgXTtQR7L0rBZhH/OWps8ISDntrMAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686910624; 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=VDK4aYPG9WvAatgaib/TtVNvzOcBWVRudU6/U8OU9wo=; b=hJ3DC+Kx9nO/tunH4MHl7jalvnU6c8QvmC8naq+w7jnDvpyoFVYXkPaFBVTLAtztDruNQAznNhfU7iWRIlME3WgYhhWa5wF3NkFlgbNLyJpKiy3kSex7qtX6znemuiubsXREBi2X0IWn0J43MB66NcS6syRwU+tCVoH+HiAoBmQ= 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+106145+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1686910624556573.948035346218; Fri, 16 Jun 2023 03:17:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id dJsQYY1788612xemAaYVcz5k; Fri, 16 Jun 2023 03:17:03 -0700 X-Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mx.groups.io with SMTP id smtpd.web11.5097.1686910623021961851 for ; Fri, 16 Jun 2023 03:17:03 -0700 X-Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1b52864b701so4270885ad.3 for ; Fri, 16 Jun 2023 03:17:02 -0700 (PDT) X-Gm-Message-State: QFx7r6a5rro4QGXMfO9UeFd4x1787277AA= X-Google-Smtp-Source: ACHHUZ6UQXiSN7NyfIFilCUEauEZzp5J7LhlmRRO2pMc5AAXt3DgDOeM3MOqbStaJJACGH2JM4dKCA== X-Received: by 2002:a17:902:9f97:b0:1b0:637e:e25a with SMTP id g23-20020a1709029f9700b001b0637ee25amr1304364plq.67.1686910622161; Fri, 16 Jun 2023 03:17:02 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001a1a82fc6d3sm15435565plf.268.2023.06.16.03.17.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jun 2023 03:17: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 v2 2/4] OvmfPkg/RiscVVirt: Add VirtNorFlashDeviceTreeLib library Date: Fri, 16 Jun 2023 15:46:49 +0530 Message-Id: <20230616101651.1319722-3-sunilvl@ventanamicro.com> In-Reply-To: <20230616101651.1319722-1-sunilvl@ventanamicro.com> References: <20230616101651.1319722-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=1686910623; bh=jQi3a5RIJ5Yys7o6bhqIA9HYdMdn37Rx3JVtTHqtIwo=; h=Cc:Date:From:Reply-To:Subject:To; b=CqPa/OtS7yREmkVuOPLS7NEpSCk58L0lwKopfi842jWcMwHLsl1Wo1Zv9IWsepMIK+1 NRyKwnHvSuYYJD1L47950lny4lDTxsznaNxCJhTBaFIgkfW1eAQoeyeU5Lh5PNl3jNWWw 32mNDTjx/CpdTVULcHi12N+eQ/dDClQOQj4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686910625295100005 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 (#106145): https://edk2.groups.io/g/devel/message/106145 Mute This Topic: https://groups.io/mt/99567398/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 Thu May 16 22:30: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+106146+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+106146+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1686910626; cv=none; d=zohomail.com; s=zohoarc; b=XoxMHMZuaRPzNACESzZ1Krt0hkOAlV77syw61C3TI50J146AMZFjcreTZqmG5e1RYTmWyCvPZOWvp0kGWzII45nuu3ehgroCzR5h4NkfjRxjnUtT2l/9Dx9wKdAuZHaJFIQuKkEs5Sr/gmbE5Bxw6BT7+ZH85/SnYIATDSJ/dgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686910626; 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=267gzXRpiWd75rGVAN3WTupdBD8UgNrmSv6pJDFwFMk=; b=axzM+dzeYP5XMyvDtif+dYu5DKR+UiSfVEgFpZvo5yLyMYTpnAV8yHrMrBjz7xOsND+dsCh0KpRSkGZuwiETo1xfZ7byYtJwkTBe5+m5PeaSdzikRxNTzL9isp+g0OHcH27DLO4h2zy4kNwBI71VNQNzwloqdutLGCQkckDQQG8= 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+106146+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1686910626617268.8029816666857; Fri, 16 Jun 2023 03:17:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ilOhYY1788612xV1qhTeXGyP; Fri, 16 Jun 2023 03:17:06 -0700 X-Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mx.groups.io with SMTP id smtpd.web10.5097.1686910625304848699 for ; Fri, 16 Jun 2023 03:17:05 -0700 X-Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-666748c1edfso521383b3a.2 for ; Fri, 16 Jun 2023 03:17:05 -0700 (PDT) X-Gm-Message-State: MwhKVOY0Z4Tvu6oRPbfMLDGvx1787277AA= X-Google-Smtp-Source: ACHHUZ7xKVslcSrK+kc6VL92QcjRjBPIqcQKjim6p/eb+Ac9EQMOGk5baZFnfUfszZNAVk3JC9detw== X-Received: by 2002:a05:6a20:7d87:b0:110:f65a:13fb with SMTP id v7-20020a056a207d8700b00110f65a13fbmr2104842pzj.15.1686910624605; Fri, 16 Jun 2023 03:17:04 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001a1a82fc6d3sm15435565plf.268.2023.06.16.03.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jun 2023 03:17:04 -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 v2 3/4] OvmfPkg/RiscVVirt: Add support for separate code and variable store Date: Fri, 16 Jun 2023 15:46:50 +0530 Message-Id: <20230616101651.1319722-4-sunilvl@ventanamicro.com> In-Reply-To: <20230616101651.1319722-1-sunilvl@ventanamicro.com> References: <20230616101651.1319722-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=1686910626; bh=JETnPRIOHu5nlXN1mKvaLf98slB+/MBhTt5zDj6Up6g=; h=Cc:Date:From:Reply-To:Subject:To; b=rc8ZJB4Yfpzx+OkXw2Dmmaq6u4vlvfkdCddyPSMC303s2Iv5AMPFw0EVNEMSgLz330e BLlwsQSNtZTcVNHVM/g8zZ0zzA7t0ciyBeMHws+GMClJz07lyizAo297F3nVURCON7Hvd UnKPBlhGRYcYuNrJhVoT+OD84/P45um14wk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686910627423100009 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 | 16 ++++++++++++---- OvmfPkg/RiscVVirt/RiscVVirt.fdf.inc | 14 ++++++-------- 3 files changed, 19 insertions(+), 13 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..21e4ba67379f 100644 --- a/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf +++ b/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf @@ -12,17 +12,25 @@ !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 +##########################################################################= ###### +[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) + !include VarStore.fdf.inc ##########################################################################= ###### =20 diff --git a/OvmfPkg/RiscVVirt/RiscVVirt.fdf.inc b/OvmfPkg/RiscVVirt/RiscVV= irt.fdf.inc index b0a1c3293f33..eba612372fee 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 @@ -29,7 +27,7 @@ [Defines] # The total size of EFI Variable FD must include # all of sub regions of EFI Variable # -DEFINE VARS_OFFSET =3D $(CODE_SIZE) +DEFINE VARS_OFFSET =3D 0x00000000 DEFINE VARS_LIVE_SIZE =3D 0x00040000 DEFINE VARS_FTW_WORKING_OFFSET =3D $(VARS_OFFSET) + $(VARS_LIVE_SIZE) DEFINE VARS_FTW_WORKING_SIZE =3D 0x00040000 --=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 (#106146): https://edk2.groups.io/g/devel/message/106146 Mute This Topic: https://groups.io/mt/99567400/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 Thu May 16 22:30: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+106147+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+106147+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1686910628; cv=none; d=zohomail.com; s=zohoarc; b=UcKMc7JpGVEnNjc3bbA1DVJRle2QUiycZ0ZO71LxvaDYRG39uulPvZMF+UawxLvCmaBGZkYucn72An4kCub7z0iyCFLHbK+MdAX7GbP8fzaY3Pjej92v/i4zaXLzVyFKYdsrJ+C2pPJH5kU08u/kazTQ8inudRXlRXAA+75moW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686910628; 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=5sA8PZIWqnbu8I5xyV47u0ZLpl4x+zRry3i0/wWeYMk=; b=RQlGUmujiyAKwmNjjTMSDN4v7tHCIeVZWpGNLpPk+HbFqhUzuwPVdFUmo+ifhG3Q4CxZfzUQ8fWSWNGLbDgZyKW1McngKkCSwAFWtGC57rGX+xEioL0jsh0fJkPa5puV9Ad8mHz0W3gdvkNNt8sBLlZryK+b6jRkTD3aeaa5eMQ= 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+106147+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1686910628619535.7978698947925; Fri, 16 Jun 2023 03:17:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id RAVmYY1788612xTjNd9MqNWP; Fri, 16 Jun 2023 03:17:08 -0700 X-Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mx.groups.io with SMTP id smtpd.web10.5098.1686910627743188291 for ; Fri, 16 Jun 2023 03:17:07 -0700 X-Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6664a9f0b10so521635b3a.0 for ; Fri, 16 Jun 2023 03:17:07 -0700 (PDT) X-Gm-Message-State: akPbgTAwk0bosbo0W6JqnubTx1787277AA= X-Google-Smtp-Source: ACHHUZ7eGgrk+yZ5p0X/ItAoHGStwKySK3Av9+LkrK27KspMPY3gzux6zFUZgdQsLlukZGKGm/sUMA== X-Received: by 2002:a05:6a20:7295:b0:11e:7ced:3391 with SMTP id o21-20020a056a20729500b0011e7ced3391mr1864787pzk.43.1686910627064; Fri, 16 Jun 2023 03:17:07 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id h12-20020a170902f54c00b001a1a82fc6d3sm15435565plf.268.2023.06.16.03.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jun 2023 03:17: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 v2 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test Date: Fri, 16 Jun 2023 15:46:51 +0530 Message-Id: <20230616101651.1319722-5-sunilvl@ventanamicro.com> In-Reply-To: <20230616101651.1319722-1-sunilvl@ventanamicro.com> References: <20230616101651.1319722-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=1686910628; bh=nUWCm2qPhd4Vgu1a5mMwinQ0b78YDeG6pCi0duDSKEI=; h=Cc:Date:From:Reply-To:Subject:To; b=sfegrbUaoRkWirbixAht0tbHJVzyH0sraqj2ZHrLJ8RXIoG1FrtCQlkp7uDazTbr29h TVJuimhSZwzznWSTDiliNSdyZdjwu4vgKffkoxklyk8c4lUcZ/Ox62SoM10rGtX7fX6Sz h9bC/tIanb7RegWk6gixKVxgN1pqu1r5KiQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686910629427100013 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 | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 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..b07d5b6d3bf9 --- /dev/null +++ b/OvmfPkg/RiscVVirt/README.md @@ -0,0 +1,46 @@ +# 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. + +The minimum qemu version required is +**[8.1](https://wiki.qemu.org/Planning/8.1)** or with commit +[7efd65423a](https://github.com/qemu/qemu/commit/7efd65423ab22e6f5890ca08a= e40c84d6660242f) +which supports separate pflash devices for EDK2 code and variable storage. + +## 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 (#106147): https://edk2.groups.io/g/devel/message/106147 Mute This Topic: https://groups.io/mt/99567401/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-