From nobody Wed May 15 00:34:18 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+106202+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+106202+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1687255374; cv=none; d=zohomail.com; s=zohoarc; b=bsVTHJvfN6m5ymK7awrTtagrQ3qeR6Z0Byz/uAaCB9oCFoFBTvykIcl/qD009p/RyJ1hZ8NpFckFytazOrQGfO16Y8NKhIIEvrjsIxMB6DK8ayUc3E5CSat+bQwUY5tlJLKHtrQiiF854OwbzoxY9TuEhMSTwKHHtB41wbtOF/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687255374; 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=ugx6BdJZOYhC8oon2NRl5c/72pkd1MLDHXcL9VAlsg8=; b=gEEPXe4iOXf57VzCZwgjyyLASam9V5b5Dn0x8paEwMsWYjxtW7ic+tTwGIygZPwU7lC2Esb3sU0aSVXfyIYW/naVof/cABHkmLfdNqwhrYqG1vswlb52KVlFWj/2IglO1RHUUcA0zaf5drbl1OExHf1tbWCx+5O9SrmDArzIV5E= 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+106202+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 168725537445286.88629755043928; Tue, 20 Jun 2023 03:02:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id KOz7YY1788612xRbMSNOnLQj; Tue, 20 Jun 2023 03:02:54 -0700 X-Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by mx.groups.io with SMTP id smtpd.web11.6716.1687255373039001923 for ; Tue, 20 Jun 2023 03:02:53 -0700 X-Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6687446eaccso1946906b3a.3 for ; Tue, 20 Jun 2023 03:02:52 -0700 (PDT) X-Gm-Message-State: GBaSxpSEVjucFi7EQEvBDmeJx1787277AA= X-Google-Smtp-Source: ACHHUZ7qV2QtVJezAsVNVH2Eco+LyTaC3bsFPGJemdcvFhMng3lb3337t7XYFJs+coa6cYHJPyy0Eg== X-Received: by 2002:a05:6a00:1989:b0:668:8b43:8ded with SMTP id d9-20020a056a00198900b006688b438dedmr3864848pfl.26.1687255372366; Tue, 20 Jun 2023 03:02:52 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id v14-20020aa7808e000000b00666b3b04758sm1033433pff.37.2023.06.20.03.02.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 03:02:52 -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 , Heinrich Schuchardt Subject: [edk2-devel] [PATCH v3 1/4] OvmfPkg/RiscVVirt: Fix couple of issues in VarStore Date: Tue, 20 Jun 2023 15:32:41 +0530 Message-Id: <20230620100244.1404606-2-sunilvl@ventanamicro.com> In-Reply-To: <20230620100244.1404606-1-sunilvl@ventanamicro.com> References: <20230620100244.1404606-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=1687255374; bh=AlQxZFWXo9/PtWYWE/ocdT2TRQODe7cwgmBPK4zqZUE=; h=Cc:Date:From:Reply-To:Subject:To; b=G0nYDt+LJuiYX6+Uv/gK9yCGSAqORHo0zPSza1KtxXFJQaiQpk2rfK/ZYqyzTZtiPNx CCfoFN85y7w1/URrMqFUpuflS3DZ6QLAeJjJxWzMmN3Heip5O+9UmHKc+NdWvdchUMEum 7lTEmOgV22B5fju6QoSnDRPFG/36RekUZTs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1687255375244100006 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 Cc: Heinrich Schuchardt --- 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 (#106202): https://edk2.groups.io/g/devel/message/106202 Mute This Topic: https://groups.io/mt/99641168/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 00:34:18 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+106203+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+106203+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1687255377; cv=none; d=zohomail.com; s=zohoarc; b=j0nQUQTBPLlXWV0vRPgznIO1J5VmWGA+nt6aWSrBorUlK7ygkel6AZ6gwm35jMmwGV5SPv0WdXsVhii2ge/rcwbuXgatDZ90L/8A/37d8zZpZAGHIZL6etJ8PqLusuW0lrUwt9Bu8RY5mT75P0t7WKx/0eBFqXtaezjQ66doTYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687255377; 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=Wab4bmpXCStlRID4p32QDLDyuNI/Z/2XQadnwVJlFnQ=; b=hyVU1zsVsjO//QzAk6l3mg7quNebkuRXO2MDpSXpHqvQl7cGG+566SQYGSK64XK7H8H25WAhSWb3AaY/yJg1SQkpSG+sdflvr3wPqgsQ+WbyS6nvXgs2PSV0o9e1XtTP39Q0zXB3eUHLOIB5+DF3UgKIo+YF5Yf1m5xHHzjn0lI= 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+106203+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1687255377807500.53043354226475; Tue, 20 Jun 2023 03:02:57 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ZOk3YY1788612x3uLl1TwCd5; Tue, 20 Jun 2023 03:02:57 -0700 X-Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) by mx.groups.io with SMTP id smtpd.web10.6811.1687255376119670322 for ; Tue, 20 Jun 2023 03:02:56 -0700 X-Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-6b58439a892so1371844a34.0 for ; Tue, 20 Jun 2023 03:02:56 -0700 (PDT) X-Gm-Message-State: oOOvkrb2bufgvjOhUh16yguJx1787277AA= X-Google-Smtp-Source: ACHHUZ6QL7Uirp6cA7zabq1JV7Sj7AxxSdJf7Lhf8yW4k3Q8bObAc62qYsKDBVWb5DqGBkAhkKeE7w== X-Received: by 2002:a05:6358:6156:b0:12b:c37e:d46b with SMTP id 22-20020a056358615600b0012bc37ed46bmr7129644rwt.21.1687255375116; Tue, 20 Jun 2023 03:02:55 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id v14-20020aa7808e000000b00666b3b04758sm1033433pff.37.2023.06.20.03.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 03:02:54 -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 , Heinrich Schuchardt Subject: [edk2-devel] [PATCH v3 2/4] OvmfPkg/RiscVVirt: Add VirtNorFlashDeviceTreeLib library Date: Tue, 20 Jun 2023 15:32:42 +0530 Message-Id: <20230620100244.1404606-3-sunilvl@ventanamicro.com> In-Reply-To: <20230620100244.1404606-1-sunilvl@ventanamicro.com> References: <20230620100244.1404606-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=1687255377; bh=yyYAoxPANlghjAdbRtY0HO3vbSw0eZJKFcfhBCkzsnw=; h=Cc:Date:From:Reply-To:Subject:To; b=wWbLTAvaDPT63oMwux+ypdlohIbgSVj/6HBh3Au+jU71uZzdYcE8pgdA/HWyWuc2R+g 9F8jtMc4G++85KFuWfv2hEIMlv81GGnl13J1fElrRrXz0bZZnlojSZSJhSU1lfGs9IVVK UZ4ZIIbbj+TyaNGiy10VuaE2vf7gUbNgPBo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1687255379263100014 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 Cc: Heinrich Schuchardt --- .../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 (#106203): https://edk2.groups.io/g/devel/message/106203 Mute This Topic: https://groups.io/mt/99641169/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 00:34:18 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+106204+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+106204+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1687255380; cv=none; d=zohomail.com; s=zohoarc; b=ie18NzWoJmIbFUfFgEwsAbmHiq58H4r1MynujBVvdgOYGL8XpXmV04a6gHv1CSa0zVsJllE788nC8qIiHd2ZSDkUq3Ci/HTD+zDYnRsYKO8CrBHliAxaKXmsK2Si4+G29YX23AFgeUh+wYeoiEaQudT3tg8OvblLm0dar7WBxX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687255380; 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=BAkm2c7UoskuaZalFXPA3iJ++afthmf1xgkQwuYSagc=; b=RABgIv+bUmJXlEvjy6qPmtoU1vWYctEkKDRiNEJB5f5MaY4Zb71+XY4HOnGM7zv6eglZv/pxyia5l6C/gyK1tZNF6ykHtLCZMw7tkfjU5h8HoCNcVTB3hqZz81eV3+Rg9Y0CQ+IBbHiZa1il+B/rV/H05+nWK6ydKsmTABxaAso= 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+106204+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1687255380151927.916077729911; Tue, 20 Jun 2023 03:03:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id URWtYY1788612xDohsGxJwcq; Tue, 20 Jun 2023 03:02:59 -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.web11.6717.1687255378708199268 for ; Tue, 20 Jun 2023 03:02:58 -0700 X-Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-666eba6f3d6so1675044b3a.3 for ; Tue, 20 Jun 2023 03:02:58 -0700 (PDT) X-Gm-Message-State: NjijvgCWVkZnXsEmBxZ67Nayx1787277AA= X-Google-Smtp-Source: ACHHUZ73qhpA05XpTGKObrX/EcjEiLtLzcIjUYyxM4EsmCh/xwqkfXcUQbutqJ0G9zCxmtZUhdoQ7A== X-Received: by 2002:a05:6a20:4288:b0:11f:4412:fc77 with SMTP id o8-20020a056a20428800b0011f4412fc77mr2867831pzj.17.1687255377741; Tue, 20 Jun 2023 03:02:57 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id v14-20020aa7808e000000b00666b3b04758sm1033433pff.37.2023.06.20.03.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 03:02:57 -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 , Heinrich Schuchardt Subject: [edk2-devel] [PATCH v3 3/4] OvmfPkg/RiscVVirt: Add support for separate code and variable store Date: Tue, 20 Jun 2023 15:32:43 +0530 Message-Id: <20230620100244.1404606-4-sunilvl@ventanamicro.com> In-Reply-To: <20230620100244.1404606-1-sunilvl@ventanamicro.com> References: <20230620100244.1404606-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=1687255379; bh=r6gfJfhhsMpvpLkQq9Q6jXu7MBS1LdYlJB6BpgSe0qs=; h=Cc:Date:From:Reply-To:Subject:To; b=MQvq/Uzc5WROpaR9tUzPx8ebCBVCxgEh4JuPtrgjed5zgBozfM+tv+vPTkbVS6EqwcT p1EEvirIYg7afijt7vEoH6giPPX4cI5vwNozi3xuVHRuKhiM5dl7/S88r7B0Wv1MUCLiD oSdqaq+y4WGEZNCwsT+SbfSXzSGxbBKz3tg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1687255381246100017 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 Cc: Heinrich Schuchardt --- 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 (#106204): https://edk2.groups.io/g/devel/message/106204 Mute This Topic: https://groups.io/mt/99641170/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 00:34:18 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+106205+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+106205+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1687255382; cv=none; d=zohomail.com; s=zohoarc; b=GLhEWkV3yt7QtP9EONOFl8o18ErHiCVy4QZW9vV8OVp0bPTTmaYyAk2YEgPUAVTZMMu8mlUPnRRPggtJbzBoW3r13yrqmIjvds1hI2xPPh050Z7bFYRSWxrMkTdsR2dltivh7sviE1dwr2kqFaXX3gxeOfdij/m6xz92nRq8SxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687255382; 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=KbvmMboRgeDDO4RR5UfjuacxoQIGOgNTwLLmdqoN7HU=; b=HS4jUa9I2v0nY4aITtJ+pJgWOSvjPXgcjMhcMie7fWrhsLHO2TbNZ6QVRvCtmjc6ne0Dw0RLLqDNl7E8cm23wglruh4Ka/ST29vA6tYWrxHLBrmlYSK4ET/yA2Ymxb6SWfJ6a1w0w4LxO8HipAlYFcNYQzIwjMLcumLlWd9BxDw= 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+106205+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1687255382797941.8235462506963; Tue, 20 Jun 2023 03:03:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6qWOYY1788612xlSsxQsY0bz; Tue, 20 Jun 2023 03:03:02 -0700 X-Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by mx.groups.io with SMTP id smtpd.web10.6812.1687255381272285454 for ; Tue, 20 Jun 2023 03:03:01 -0700 X-Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-55380677566so2008951a12.3 for ; Tue, 20 Jun 2023 03:03:01 -0700 (PDT) X-Gm-Message-State: PMGeCbKKYvnmldjZOi5yzMqDx1787277AA= X-Google-Smtp-Source: ACHHUZ7z5qhdl2BYkjkdaecW6MUyk03/UhjAAE6D432de1D/jgYHtsHzjvMWlW0a56OCiuCsP1ud7Q== X-Received: by 2002:a05:6a21:329e:b0:10e:d90f:35d5 with SMTP id yt30-20020a056a21329e00b0010ed90f35d5mr9226812pzb.51.1687255380511; Tue, 20 Jun 2023 03:03:00 -0700 (PDT) X-Received: from kerodi.Dlink ([106.51.184.72]) by smtp.gmail.com with ESMTPSA id v14-20020aa7808e000000b00666b3b04758sm1033433pff.37.2023.06.20.03.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 03:03:00 -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 , Heinrich Schuchardt Subject: [edk2-devel] [PATCH v3 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test Date: Tue, 20 Jun 2023 15:32:44 +0530 Message-Id: <20230620100244.1404606-5-sunilvl@ventanamicro.com> In-Reply-To: <20230620100244.1404606-1-sunilvl@ventanamicro.com> References: <20230620100244.1404606-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=1687255382; bh=5ZVUSbEFpb/hMme8oL5xf+XLS6Wky5hcjTou74E+RTU=; h=Cc:Date:From:Reply-To:Subject:To; b=RkmC7p5P62PPRqEeUvGAkXU41zAfvDFiy5zdVn4FnyiuzDvWotCU846fnu77H7va1ot g1dqheZAZQ1vgsqNOzwHwLEoCkxSu+vdSCGlO5Ss/X7jSUsvE8ozXpFS2yTtRKAo9WQnz YBYfxwpx17ao/EZzCWruYeWkjqGrw44zDOk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1687255383295100021 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 Cc: Heinrich Schuchardt --- OvmfPkg/RiscVVirt/README.md | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 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..950694419e8b --- /dev/null +++ b/OvmfPkg/RiscVVirt/README.md @@ -0,0 +1,49 @@ +# 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 the 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 +Below example shows how to boot openSUSE Tumbleweed E20. + +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) Running QEMU + + qemu-system-riscv64 \ + -M virt,pflash0=3Dpflash0,pflash1=3Dpflash1,acpi=3Doff \ + -m 4096 -smp 2 \ + -serial mon:stdio \ + -device virtio-gpu-pci -full-screen \ + -device qemu-xhci \ + -device usb-kbd \ + -device virtio-rng-pci \ + -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 \ + -netdev user,id=3Dnet0 \ + -device virtio-net-pci,netdev=3Dnet0 \ + -device virtio-blk-device,drive=3Dhd0 \ + -drive file=3DopenSUSE-Tumbleweed-RISC-V-E20-efi.riscv64.raw,forma= t=3Draw,id=3Dhd0 --=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 (#106205): https://edk2.groups.io/g/devel/message/106205 Mute This Topic: https://groups.io/mt/99641171/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-