* [edk2-devel] [PATCH v1 1/2] OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib
2024-05-17 7:17 [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in Chao Li
@ 2024-05-17 7:17 ` Chao Li
2024-05-24 9:11 ` Marcin Juszkiewicz
2024-05-17 7:17 ` [edk2-devel] [PATCH v1 2/2] ArmVirtPkg: Enable the non-hardcode version FtdNorFlashQemuLib Chao Li
2024-05-17 7:21 ` [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in Ard Biesheuvel
2 siblings, 1 reply; 13+ messages in thread
From: Chao Li @ 2024-05-17 7:17 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar, Gerd Hoffmann,
Jiewen Yao, Xianglai Li
This library is copied from ArmVirtPkg, in the Arm version, the value of
PcdFlashNvStorageVariableBase, PcdFlashNvStorageFtwWorkingBase and
PcdFlashNvStorageFtwSpareBase are hardcoded in INC file.
This version will calculate them from FDT resource and using the set PCD
to store when the NorFlashInitialise is called. By default, the first
available flash(not used for storage UEFI code) as NV variable storage
medium.
In this way, UEFI can better handle the change of flash base address,
which is suitable for different cpu architecture board implementation.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4770
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
---
.../FdtNorFlashQemuLib/FdtNorFlashQemuLib.c | 165 ++++++++++++++++++
.../FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf | 46 +++++
2 files changed, 211 insertions(+)
create mode 100644 OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.c
create mode 100644 OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf
diff --git a/OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.c b/OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.c
new file mode 100644
index 0000000000..e5c7d4cdfa
--- /dev/null
+++ b/OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.c
@@ -0,0 +1,165 @@
+/** @file
+
+ Copyright (c) 2014-2018, Linaro Ltd. All rights reserved.<BR>
+ Copyright (c) 2024 Loongson Technology Corporation Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/VirtNorFlashPlatformLib.h>
+
+#include <Protocol/FdtClient.h>
+#include <stdbool.h>
+
+#define QEMU_NOR_BLOCK_SIZE SIZE_256KB
+#define MAX_FLASH_BANKS 4
+
+STATIC VIRT_NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_BANKS];
+
+EFI_STATUS
+VirtNorFlashPlatformInitialization (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+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;
+ BOOLEAN Found;
+
+ Status = gBS->LocateProtocol (
+ &gFdtClientProtocolGuid,
+ NULL,
+ (VOID **)&FdtClient
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Num = 0;
+ Found = FALSE;
+ for (FindNodeStatus = FdtClient->FindCompatibleNode (
+ FdtClient,
+ "cfi-flash",
+ &Node
+ );
+ !EFI_ERROR (FindNodeStatus) && Num < MAX_FLASH_BANKS;
+ FindNodeStatus = FdtClient->FindNextCompatibleNode (
+ FdtClient,
+ "cfi-flash",
+ Node,
+ &Node
+ ))
+ {
+ Status = FdtClient->GetNodeProperty (
+ FdtClient,
+ Node,
+ "reg",
+ (CONST VOID **)&Reg,
+ &PropSize
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: GetNodeProperty () failed (Status == %r)\n",
+ __func__,
+ Status
+ ));
+ continue;
+ }
+
+ ASSERT ((PropSize % (4 * sizeof (UINT32))) == 0);
+
+ while (PropSize >= (4 * sizeof (UINT32)) && Num < MAX_FLASH_BANKS) {
+ Base = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[0]));
+ Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2]));
+ Reg += 4;
+
+ PropSize -= 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 (PcdOvmfFirmwareFdSize) > Base) &&
+ ((Base + Size) > PcdGet32 (PcdOvmfFdBaseAddress)))
+ {
+ continue;
+ }
+
+ mNorFlashDevices[Num].DeviceBaseAddress = (UINTN)Base;
+ mNorFlashDevices[Num].RegionBaseAddress = (UINTN)Base;
+ mNorFlashDevices[Num].Size = (UINTN)Size;
+ mNorFlashDevices[Num].BlockSize = QEMU_NOR_BLOCK_SIZE;
+ Num++;
+ if (!Found) {
+ //
+ // By default, the second available flash is stored as a non-volatile variable.
+ //
+ Status = PcdSet32S (PcdFlashNvStorageVariableBase, Base);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // The Base is the value of PcdFlashNvStorageVariableBase,
+ // PcdFlashNvStorageFtwWorkingBase can be got by
+ // PcdFlashNvStorageVariableBase + PcdFlashNvStorageVariableSize
+ //
+ Base += PcdGet32 (PcdFlashNvStorageVariableSize);
+ Status = PcdSet32S (PcdFlashNvStorageFtwWorkingBase, Base);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Now, the Base is the value of PcdFlashNvStorageFtwWorkingBase,
+ // PcdFlashNvStorageFtwSpareBase can be got by
+ // PcdFlashNvStorageFtwWorkingBase + PcdFlashNvStorageFtwWorkingSize.
+ //
+ Base += PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
+ Status = PcdSet32S (PcdFlashNvStorageFtwSpareBase, Base);
+ ASSERT_EFI_ERROR (Status);
+ Found = TRUE;
+ }
+ }
+
+ //
+ // UEFI takes ownership of the NOR flash, and exposes its functionality
+ // through the UEFI Runtime Services GetVariable, SetVariable, etc. This
+ // means we need to disable it in the device tree to prevent the OS from
+ // attaching its device driver as well.
+ // Note that this also hides other flash banks, but the only other flash
+ // bank we expect to encounter is the one that carries the UEFI executable
+ // code, which is not intended to be guest updatable, and is usually backed
+ // in a readonly manner by QEMU anyway.
+ //
+ Status = 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 = mNorFlashDevices;
+ *Count = Num;
+
+ return EFI_SUCCESS;
+}
diff --git a/OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf b/OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf
new file mode 100644
index 0000000000..14ddb4c11e
--- /dev/null
+++ b/OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf
@@ -0,0 +1,46 @@
+## @file
+#
+# Copyright (c) 2014-2018, Linaro Ltd. All rights reserved.<BR>
+# Copyright (c) 2024 Loongson Technology Corporation Limited. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 1.29
+ BASE_NAME = NorFlashQemuLib
+ FILE_GUID = E225C90F-6CB9-8AF3-095B-2668FC633A57
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = NorFlashQemuLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION
+
+[Sources]
+ FdtNorFlashQemuLib.c
+
+[Packages]
+ EmbeddedPkg/EmbeddedPkg.dec
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ UefiBootServicesTableLib
+
+[Protocols]
+ gFdtClientProtocolGuid ## CONSUMES
+
+[Depex]
+ gFdtClientProtocolGuid
+
+[Pcd]
+gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress
+gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize
+gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
+gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
+gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
+gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
+gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase
+gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
--
2.27.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118988): https://edk2.groups.io/g/devel/message/118988
Mute This Topic: https://groups.io/mt/106149595/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/2] OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib
2024-05-17 7:17 ` [edk2-devel] [PATCH v1 1/2] OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib Chao Li
@ 2024-05-24 9:11 ` Marcin Juszkiewicz
2024-05-27 3:17 ` xianglai
2024-05-27 6:38 ` Gerd Hoffmann
0 siblings, 2 replies; 13+ messages in thread
From: Marcin Juszkiewicz @ 2024-05-24 9:11 UTC (permalink / raw)
To: devel, lichao
Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar, Gerd Hoffmann,
Jiewen Yao, Xianglai Li
W dniu 17.05.2024 o 09:17, Chao Li via groups.io pisze:
> This library is copied from ArmVirtPkg, in the Arm version, the value of
> PcdFlashNvStorageVariableBase, PcdFlashNvStorageFtwWorkingBase and
> PcdFlashNvStorageFtwSpareBase are hardcoded in INC file.
>
> This version will calculate them from FDT resource and using the set PCD
> to store when the NorFlashInitialise is called. By default, the first
> available flash(not used for storage UEFI code) as NV variable storage
> medium.
>
> In this way, UEFI can better handle the change of flash base address,
> which is suitable for different cpu architecture board implementation.
>
> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4770
>
> Cc: Ard Biesheuvel<ardb+tianocore@kernel.org>
> Cc: Leif Lindholm<quic_llindhol@quicinc.com>
> Cc: Sami Mujawar<sami.mujawar@arm.com>
> Cc: Gerd Hoffmann<kraxel@redhat.com>
> Cc: Jiewen Yao<jiewen.yao@intel.com>
> Signed-off-by: Chao Li<lichao@loongson.cn>
> Signed-off-by: Xianglai Li<lixianglai@loongson.cn>
Can you split it into driver itself and part which uses DT data to setup
parameters?
This way driver can be used on other platforms as well, despite do they
hardcode flash data, read it via Firmware Handoff protocol, SMC calls to
embedded controller or have other way to keep flash data.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119251): https://edk2.groups.io/g/devel/message/119251
Mute This Topic: https://groups.io/mt/106149595/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/2] OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib
2024-05-24 9:11 ` Marcin Juszkiewicz
@ 2024-05-27 3:17 ` xianglai
2024-05-27 6:38 ` Gerd Hoffmann
1 sibling, 0 replies; 13+ messages in thread
From: xianglai @ 2024-05-27 3:17 UTC (permalink / raw)
To: Marcin Juszkiewicz, devel, lichao
Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar, Gerd Hoffmann,
Jiewen Yao
Hi Marcin:
> W dniu 17.05.2024 o 09:17, Chao Li via groups.io pisze:
>> This library is copied from ArmVirtPkg, in the Arm version, the value of
>> PcdFlashNvStorageVariableBase, PcdFlashNvStorageFtwWorkingBase and
>> PcdFlashNvStorageFtwSpareBase are hardcoded in INC file.
>>
>> This version will calculate them from FDT resource and using the set PCD
>> to store when the NorFlashInitialise is called. By default, the first
>> available flash(not used for storage UEFI code) as NV variable storage
>> medium.
>>
>> In this way, UEFI can better handle the change of flash base address,
>> which is suitable for different cpu architecture board implementation.
>>
>> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4770
>>
>> Cc: Ard Biesheuvel<ardb+tianocore@kernel.org>
>> Cc: Leif Lindholm<quic_llindhol@quicinc.com>
>> Cc: Sami Mujawar<sami.mujawar@arm.com>
>> Cc: Gerd Hoffmann<kraxel@redhat.com>
>> Cc: Jiewen Yao<jiewen.yao@intel.com>
>> Signed-off-by: Chao Li<lichao@loongson.cn>
>> Signed-off-by: Xianglai Li<lixianglai@loongson.cn>
>
> Can you split it into driver itself and part which uses DT data to
> setup parameters?
>
> This way driver can be used on other platforms as well, despite do
> they hardcode flash data, read it via Firmware Handoff protocol, SMC
> calls to embedded controller or have other way to keep flash data.
This lib is provided for resolving pfalsh base addresses for virtual
machines emulated by qemu.
The pfash base address of the arm and riscv architectures emulated by
qemu is hardcoded in UEFI.
After this lib is committed, arm and riscv can easily use this lib by
modifying the dsc and VarStore.fdf.inc files.
Later, we will send out the patch of arm and riscv, then arm and riscv
will also be realized by resolving the pflash base address through fdt.
So, what other qemu emulation platforms do you think will hard-code fdt
base addresses?:-)
Or are there specific scenarios that require hard-coded pflash base
addresses?:-)
I admit that there is more flexibility, but do we really need to do
that?:-)
Thanks!
Xianglai.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119271): https://edk2.groups.io/g/devel/message/119271
Mute This Topic: https://groups.io/mt/106149595/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/2] OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib
2024-05-24 9:11 ` Marcin Juszkiewicz
2024-05-27 3:17 ` xianglai
@ 2024-05-27 6:38 ` Gerd Hoffmann
2024-05-28 1:43 ` Chao Li
1 sibling, 1 reply; 13+ messages in thread
From: Gerd Hoffmann @ 2024-05-27 6:38 UTC (permalink / raw)
To: Marcin Juszkiewicz
Cc: devel, lichao, Ard Biesheuvel, Leif Lindholm, Sami Mujawar,
Jiewen Yao, Xianglai Li
On Fri, May 24, 2024 at 11:11:41AM GMT, Marcin Juszkiewicz wrote:
> W dniu 17.05.2024 o 09:17, Chao Li via groups.io pisze:
> > This library is copied from ArmVirtPkg, in the Arm version, the value of
> > PcdFlashNvStorageVariableBase, PcdFlashNvStorageFtwWorkingBase and
> > PcdFlashNvStorageFtwSpareBase are hardcoded in INC file.
> >
> > This version will calculate them from FDT resource and using the set PCD
> > to store when the NorFlashInitialise is called. By default, the first
> > available flash(not used for storage UEFI code) as NV variable storage
> > medium.
> >
> > In this way, UEFI can better handle the change of flash base address,
> > which is suitable for different cpu architecture board implementation.
> >
> > BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4770
> >
> > Cc: Ard Biesheuvel<ardb+tianocore@kernel.org>
> > Cc: Leif Lindholm<quic_llindhol@quicinc.com>
> > Cc: Sami Mujawar<sami.mujawar@arm.com>
> > Cc: Gerd Hoffmann<kraxel@redhat.com>
> > Cc: Jiewen Yao<jiewen.yao@intel.com>
> > Signed-off-by: Chao Li<lichao@loongson.cn>
> > Signed-off-by: Xianglai Li<lixianglai@loongson.cn>
>
> Can you split it into driver itself and part which uses DT data to setup
> parameters?
Hmm? This split exists already. This is a library for flash detection,
which is used by the flash driver (VirtNorFlashDxe) to find flash. If
using fdt doesn't work for sbsa-ref you can implement an alternative
without rewriting the driver itself.
take care,
Gerd
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119275): https://edk2.groups.io/g/devel/message/119275
Mute This Topic: https://groups.io/mt/106149595/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [edk2-devel] [PATCH v1 1/2] OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib
2024-05-27 6:38 ` Gerd Hoffmann
@ 2024-05-28 1:43 ` Chao Li
0 siblings, 0 replies; 13+ messages in thread
From: Chao Li @ 2024-05-28 1:43 UTC (permalink / raw)
To: Gerd Hoffmann, Marcin Juszkiewicz
Cc: devel, Ard Biesheuvel, Leif Lindholm, Sami Mujawar, Jiewen Yao,
Xianglai Li
[-- Attachment #1: Type: text/plain, Size: 2012 bytes --]
Hi Gerd, Ard and other maintainers,
So, Could you help to review this patch set and give me the R-B?
Thanks,
Chao
On 2024/5/27 14:38, Gerd Hoffmann wrote:
> On Fri, May 24, 2024 at 11:11:41AM GMT, Marcin Juszkiewicz wrote:
>> W dniu 17.05.2024 o 09:17, Chao Li via groups.io pisze:
>>> This library is copied from ArmVirtPkg, in the Arm version, the value of
>>> PcdFlashNvStorageVariableBase, PcdFlashNvStorageFtwWorkingBase and
>>> PcdFlashNvStorageFtwSpareBase are hardcoded in INC file.
>>>
>>> This version will calculate them from FDT resource and using the set PCD
>>> to store when the NorFlashInitialise is called. By default, the first
>>> available flash(not used for storage UEFI code) as NV variable storage
>>> medium.
>>>
>>> In this way, UEFI can better handle the change of flash base address,
>>> which is suitable for different cpu architecture board implementation.
>>>
>>> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4770
>>>
>>> Cc: Ard Biesheuvel<ardb+tianocore@kernel.org>
>>> Cc: Leif Lindholm<quic_llindhol@quicinc.com>
>>> Cc: Sami Mujawar<sami.mujawar@arm.com>
>>> Cc: Gerd Hoffmann<kraxel@redhat.com>
>>> Cc: Jiewen Yao<jiewen.yao@intel.com>
>>> Signed-off-by: Chao Li<lichao@loongson.cn>
>>> Signed-off-by: Xianglai Li<lixianglai@loongson.cn>
>> Can you split it into driver itself and part which uses DT data to setup
>> parameters?
> Hmm? This split exists already. This is a library for flash detection,
> which is used by the flash driver (VirtNorFlashDxe) to find flash. If
> using fdt doesn't work for sbsa-ref you can implement an alternative
> without rewriting the driver itself.
>
> take care,
> Gerd
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119285): https://edk2.groups.io/g/devel/message/119285
Mute This Topic: https://groups.io/mt/106149595/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 3970 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* [edk2-devel] [PATCH v1 2/2] ArmVirtPkg: Enable the non-hardcode version FtdNorFlashQemuLib
2024-05-17 7:17 [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in Chao Li
2024-05-17 7:17 ` [edk2-devel] [PATCH v1 1/2] OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib Chao Li
@ 2024-05-17 7:17 ` Chao Li
2024-05-17 7:21 ` [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in Ard Biesheuvel
2 siblings, 0 replies; 13+ messages in thread
From: Chao Li @ 2024-05-17 7:17 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar, Gerd Hoffmann,
Jiewen Yao, Xianglai Li
Enable the non-hardcode version of FtdNorFlashQemuLib in ArmVirtQemu.dsc
and ArmVirtQemuKernel.dsc, and it can work rightly after enabling it.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4770
Build-tested (with "ArmVirtQemu.dsc" and "ArmVirtQemuKernel.dsc").
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
---
ArmVirtPkg/ArmVirtQemu.dsc | 21 +++++++++++++++++++--
ArmVirtPkg/ArmVirtQemuKernel.dsc | 20 ++++++++++++++++++--
ArmVirtPkg/VarStore.fdf.inc | 5 +----
3 files changed, 38 insertions(+), 8 deletions(-)
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 7e2ff33ad1..2ecbb5d041 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -66,7 +66,7 @@ [LibraryClasses.common]
QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
- VirtNorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
+ VirtNorFlashPlatformLib|OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
@@ -152,6 +152,9 @@ [PcdsFixedAtBuild.common]
gArmTokenSpaceGuid.PcdVFPEnabled|1
!endif
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress|0x00000000
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize|$(FD_SIZE)
+
gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase|0x4007c000
gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
@@ -231,6 +234,10 @@ [PcdsFixedAtBuild.common]
# System Memory Size -- 128 MB initially, actual size will be fetched from DT
gArmTokenSpaceGuid.PcdSystemMemorySize|0x8000000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize | 0x40000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize | 0x40000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize | 0x40000
+
[PcdsFixedAtBuild.AARCH64]
# Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS entry point,
# if the entry point version is >= 3.0. AARCH64 OSes cannot assume the
@@ -243,6 +250,13 @@ [PcdsFixedAtBuild.AARCH64]
[PcdsDynamicDefault.common]
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase | 0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 | 0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 | 0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase | 0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase | 0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 | 0
+
## If TRUE, OvmfPkg/AcpiPlatformDxe will not wait for PCI
# enumeration to complete before installing ACPI tables.
gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
@@ -404,7 +418,10 @@ [Components.common]
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
!endif
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf {
+ <LibraryClasses>
+ NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
+ }
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index efe2df97bd..0242413dc8 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -65,7 +65,7 @@ [LibraryClasses.common]
ArmVirtMemInfoLib|ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
- VirtNorFlashPlatformLib|ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf
+ VirtNorFlashPlatformLib|OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
@@ -120,6 +120,8 @@ [PcdsFixedAtBuild.common]
gArmTokenSpaceGuid.PcdVFPEnabled|1
!endif
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress|0x00000000
+ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize|$(FD_SIZE)
gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
@@ -181,6 +183,10 @@ [PcdsFixedAtBuild.common]
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|3
gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x20000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize | 0x40000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize | 0x40000
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize | 0x40000
+
[PcdsPatchableInModule.common]
# we need to provide a resolution for this PCD that supports PcdSet64()
# being called from ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c,
@@ -206,6 +212,13 @@ [PcdsPatchableInModule.common]
[PcdsDynamicDefault.common]
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase | 0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 | 0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 | 0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase | 0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase | 0
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 | 0
+
## If TRUE, OvmfPkg/AcpiPlatformDxe will not wait for PCI
# enumeration to complete before installing ACPI tables.
gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
@@ -311,7 +324,10 @@ [Components.common]
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
!endif
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
+ MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf {
+ <LibraryClasses>
+ NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf
+ }
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {
diff --git a/ArmVirtPkg/VarStore.fdf.inc b/ArmVirtPkg/VarStore.fdf.inc
index b4afaf12b6..1f035a132e 100644
--- a/ArmVirtPkg/VarStore.fdf.inc
+++ b/ArmVirtPkg/VarStore.fdf.inc
@@ -10,7 +10,7 @@
##
[FD.QEMU_VARS]
-BaseAddress = 0x04000000
+BaseAddress = 0x00000000
Size = 0xc0000
ErasePolarity = 1
BlockSize = 0x40000
@@ -18,7 +18,6 @@ [FD.QEMU_VARS]
0x00000000|0x00040000
-gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
#NV_VARIABLE_STORE
DATA = {
## This is the EFI_FIRMWARE_VOLUME_HEADER
@@ -57,7 +56,6 @@ [FD.QEMU_VARS]
0x00040000|0x00040000
-gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
#NV_FTW_WORKING
DATA = {
# EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature = gEdkiiWorkingBlockSignatureGuid =
@@ -71,5 +69,4 @@ [FD.QEMU_VARS]
}
0x00080000|0x00040000
-gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
#NV_FTW_SPARE
--
2.27.0
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118989): https://edk2.groups.io/g/devel/message/118989
Mute This Topic: https://groups.io/mt/106149597/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in
2024-05-17 7:17 [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in Chao Li
2024-05-17 7:17 ` [edk2-devel] [PATCH v1 1/2] OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib Chao Li
2024-05-17 7:17 ` [edk2-devel] [PATCH v1 2/2] ArmVirtPkg: Enable the non-hardcode version FtdNorFlashQemuLib Chao Li
@ 2024-05-17 7:21 ` Ard Biesheuvel
2024-05-17 7:33 ` Chao Li
[not found] ` <17D036583CE2D32E.17823@groups.io>
2 siblings, 2 replies; 13+ messages in thread
From: Ard Biesheuvel @ 2024-05-17 7:21 UTC (permalink / raw)
To: devel, lichao
Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar, Gerd Hoffmann,
Jiewen Yao
Hello Chao Li,
You sent two series in quick succession. Is there any difference
between the two?
On Fri, 17 May 2024 at 09:17, Chao Li <lichao@loongson.cn> wrote:
>
> Patch1: Added a new library called FdtNorFlashQemuLib in OvmfPkg/Library
> which is non-hardcode dependency.
> Patch2: Enable the new library in ArmVirtQemu.dsc and
> ArmVirtQemuKernel.dsc.
>
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4770
>
> I have verified on both of the two platforms:
> Prepare:
> install libvirt, virt-manager, qemu-systemaarch64.
>
> Step 1:
> Built the two platforms with ArmVirtQemu.dsc and
> ArmVirtQemuKernel.dsc, and then using the command create the pflash
> files:
> Build the two platforms firmware using ArmVirtQemu.dsc and
> ArmVirtQemuKernel.dsc, and then create the pflash files using following
> command:
> cat QEMU_EFI.fd /dev/zero | head -c 64m > ./QEMU_EFI-pflash.raw
> cat QEMU_VARS.fd /dev/zero | head -c 64m > ./vars-template-pflash.raw
> qemu-img convert -f raw -O qcow2 -o cluster_size=4096 -S 4096 QEMU_EFI-pflash.raw QEMU_EFI-pflash.qcow2
> qemu-img convert -f raw -O qcow2 -o cluster_size=4096 -S 4096 vars-template-pflash.raw vars-template-pflash.qcow2
>
> Download a AARCH64 QCOW2 image.
> Copy them into /usr/share/edk2/aarch64/.
>
> Step 2:
> Verification the pflash working:
> ArmVirtQemu:
> Run the QEMU ARM virt machine using the following command:
> qemu-system-aarch64 \
> -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/QEMU_EFI-pflash.qcow2","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \
> -blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"qcow2","file":"libvirt-pflash0-storage"}' \
> -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/vars-template-pflash.qcow2","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
> -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"qcow2","file":"libvirt-pflash1-storage"}' \
> -machine virt,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,acpi=on \
> -cpu cortex-a57 \
> -m size=2097152k \
> -serial stdio \
> -net none \
> -device ramfb \
> -device nec-usb-xhci \
> -device usb-mouse \
> -device usb-kbd
>
> ArmVirtQemuKernel:
> Run the QEMU kernel ARM virt machine using the following command:
> qemu-system-aarch64 \
> -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/vars-template-pflash.raw","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
> -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}' \
> -machine virt,usb=off,dump-guest-core=off,gic-version=3,pflash1=libvirt-pflash1-format \
> -cpu cortex-a57 \
> -m 4096 \
> -smp 1,sockets=1,cores=1,threads=1 \
> -no-user-config \
> -nodefaults \
> -device virtio-gpu-pci \
> -kernel /usr/share/edk2/aarch64/QEMU_EFI-pflash.raw \
> -serial stdio \
> -device nec-usb-xhci \
> -device usb-mouse \
> -device usb-kbd \
> -hda /usr/share/edk2/aarch64/openEuler-22.03-LTS-SP3-aarch64.qcow2 \
> -monitor tcp::3333,server,nowait
>
> Step 3:
> After the virt-machines starts, enter "F2" to enter the setup UI, try to
> change the boot order or some ther variables stored in the flash, then
> enter "F10" to save the changes and reboot it.
> After restarting, enter "F2" to enter the setup UI and check whether the
> changes before the restart operation have been saved.
>
>
> Using the above three steps, both platforms will works fine.
>
> I have not created the PR in github yet, I will create it once the edk2
> merge window reopens.
>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Leif Lindholm <quic_llindhol@quicinc.com>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
>
> Chao Li (2):
> OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib
> ArmVirtPkg: Enable the non-hardcode version FtdNorFlashQemuLib
>
> ArmVirtPkg/ArmVirtQemu.dsc | 21 ++-
> ArmVirtPkg/ArmVirtQemuKernel.dsc | 20 ++-
> ArmVirtPkg/VarStore.fdf.inc | 5 +-
> .../FdtNorFlashQemuLib/FdtNorFlashQemuLib.c | 165 ++++++++++++++++++
> .../FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf | 46 +++++
> 5 files changed, 249 insertions(+), 8 deletions(-)
> create mode 100644 OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.c
> create mode 100644 OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf
>
> --
> 2.27.0
>
>
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118990): https://edk2.groups.io/g/devel/message/118990
Mute This Topic: https://groups.io/mt/106149594/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in
2024-05-17 7:21 ` [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in Ard Biesheuvel
@ 2024-05-17 7:33 ` Chao Li
[not found] ` <17D036583CE2D32E.17823@groups.io>
1 sibling, 0 replies; 13+ messages in thread
From: Chao Li @ 2024-05-17 7:33 UTC (permalink / raw)
To: devel, ardb
Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar, Gerd Hoffmann,
Jiewen Yao
[-- Attachment #1: Type: text/plain, Size: 5538 bytes --]
Hi Ard,
No, it's just that my email was bounced just now, the groupio didn't
receive my email when I send the first time, and I sent them again after
it unbounce.
Thanks,
Chao
On 2024/5/17 15:21, Ard Biesheuvel wrote:
> Hello Chao Li,
>
> You sent two series in quick succession. Is there any difference
> between the two?
>
>
> On Fri, 17 May 2024 at 09:17, Chao Li<lichao@loongson.cn> wrote:
>> Patch1: Added a new library called FdtNorFlashQemuLib in OvmfPkg/Library
>> which is non-hardcode dependency.
>> Patch2: Enable the new library in ArmVirtQemu.dsc and
>> ArmVirtQemuKernel.dsc.
>>
>> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4770
>>
>> I have verified on both of the two platforms:
>> Prepare:
>> install libvirt, virt-manager, qemu-systemaarch64.
>>
>> Step 1:
>> Built the two platforms with ArmVirtQemu.dsc and
>> ArmVirtQemuKernel.dsc, and then using the command create the pflash
>> files:
>> Build the two platforms firmware using ArmVirtQemu.dsc and
>> ArmVirtQemuKernel.dsc, and then create the pflash files using following
>> command:
>> cat QEMU_EFI.fd /dev/zero | head -c 64m > ./QEMU_EFI-pflash.raw
>> cat QEMU_VARS.fd /dev/zero | head -c 64m > ./vars-template-pflash.raw
>> qemu-img convert -f raw -O qcow2 -o cluster_size=4096 -S 4096 QEMU_EFI-pflash.raw QEMU_EFI-pflash.qcow2
>> qemu-img convert -f raw -O qcow2 -o cluster_size=4096 -S 4096 vars-template-pflash.raw vars-template-pflash.qcow2
>>
>> Download a AARCH64 QCOW2 image.
>> Copy them into /usr/share/edk2/aarch64/.
>>
>> Step 2:
>> Verification the pflash working:
>> ArmVirtQemu:
>> Run the QEMU ARM virt machine using the following command:
>> qemu-system-aarch64 \
>> -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/QEMU_EFI-pflash.qcow2","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \
>> -blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"qcow2","file":"libvirt-pflash0-storage"}' \
>> -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/vars-template-pflash.qcow2","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
>> -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"qcow2","file":"libvirt-pflash1-storage"}' \
>> -machine virt,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,acpi=on \
>> -cpu cortex-a57 \
>> -m size=2097152k \
>> -serial stdio \
>> -net none \
>> -device ramfb \
>> -device nec-usb-xhci \
>> -device usb-mouse \
>> -device usb-kbd
>>
>> ArmVirtQemuKernel:
>> Run the QEMU kernel ARM virt machine using the following command:
>> qemu-system-aarch64 \
>> -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/vars-template-pflash.raw","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
>> -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}' \
>> -machine virt,usb=off,dump-guest-core=off,gic-version=3,pflash1=libvirt-pflash1-format \
>> -cpu cortex-a57 \
>> -m 4096 \
>> -smp 1,sockets=1,cores=1,threads=1 \
>> -no-user-config \
>> -nodefaults \
>> -device virtio-gpu-pci \
>> -kernel /usr/share/edk2/aarch64/QEMU_EFI-pflash.raw \
>> -serial stdio \
>> -device nec-usb-xhci \
>> -device usb-mouse \
>> -device usb-kbd \
>> -hda /usr/share/edk2/aarch64/openEuler-22.03-LTS-SP3-aarch64.qcow2 \
>> -monitor tcp::3333,server,nowait
>>
>> Step 3:
>> After the virt-machines starts, enter "F2" to enter the setup UI, try to
>> change the boot order or some ther variables stored in the flash, then
>> enter "F10" to save the changes and reboot it.
>> After restarting, enter "F2" to enter the setup UI and check whether the
>> changes before the restart operation have been saved.
>>
>>
>> Using the above three steps, both platforms will works fine.
>>
>> I have not created the PR in github yet, I will create it once the edk2
>> merge window reopens.
>>
>> Cc: Ard Biesheuvel<ardb+tianocore@kernel.org>
>> Cc: Leif Lindholm<quic_llindhol@quicinc.com>
>> Cc: Sami Mujawar<sami.mujawar@arm.com>
>> Cc: Gerd Hoffmann<kraxel@redhat.com>
>> Cc: Jiewen Yao<jiewen.yao@intel.com>
>>
>> Chao Li (2):
>> OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib
>> ArmVirtPkg: Enable the non-hardcode version FtdNorFlashQemuLib
>>
>> ArmVirtPkg/ArmVirtQemu.dsc | 21 ++-
>> ArmVirtPkg/ArmVirtQemuKernel.dsc | 20 ++-
>> ArmVirtPkg/VarStore.fdf.inc | 5 +-
>> .../FdtNorFlashQemuLib/FdtNorFlashQemuLib.c | 165 ++++++++++++++++++
>> .../FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf | 46 +++++
>> 5 files changed, 249 insertions(+), 8 deletions(-)
>> create mode 100644 OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.c
>> create mode 100644 OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf
>>
>> --
>> 2.27.0
>>
>>
>>
>>
>>
>>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118992): https://edk2.groups.io/g/devel/message/118992
Mute This Topic: https://groups.io/mt/106149594/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 7090 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
[parent not found: <17D036583CE2D32E.17823@groups.io>]
* Re: [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in
[not found] ` <17D036583CE2D32E.17823@groups.io>
@ 2024-05-24 8:38 ` Chao Li
2024-05-29 9:09 ` Gerd Hoffmann
0 siblings, 1 reply; 13+ messages in thread
From: Chao Li @ 2024-05-24 8:38 UTC (permalink / raw)
To: devel, ardb
Cc: Ard Biesheuvel, Leif Lindholm, Sami Mujawar, Gerd Hoffmann,
Jiewen Yao
[-- Attachment #1: Type: text/plain, Size: 5772 bytes --]
Hi Ard and other maintainers,
Could you help to review this patch set?
Thanks,
Chao
On 2024/5/17 15:33, Chao Li wrote:
>
> Hi Ard,
>
> No, it's just that my email was bounced just now, the groupio didn't
> receive my email when I send the first time, and I sent them again
> after it unbounce.
>
> On 2024/5/17 15:21, Ard Biesheuvel wrote:
>> Hello Chao Li,
>>
>> You sent two series in quick succession. Is there any difference
>> between the two?
>>
>>
>> On Fri, 17 May 2024 at 09:17, Chao Li<lichao@loongson.cn> wrote:
>>> Patch1: Added a new library called FdtNorFlashQemuLib in OvmfPkg/Library
>>> which is non-hardcode dependency.
>>> Patch2: Enable the new library in ArmVirtQemu.dsc and
>>> ArmVirtQemuKernel.dsc.
>>>
>>> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4770
>>>
>>> I have verified on both of the two platforms:
>>> Prepare:
>>> install libvirt, virt-manager, qemu-systemaarch64.
>>>
>>> Step 1:
>>> Built the two platforms with ArmVirtQemu.dsc and
>>> ArmVirtQemuKernel.dsc, and then using the command create the pflash
>>> files:
>>> Build the two platforms firmware using ArmVirtQemu.dsc and
>>> ArmVirtQemuKernel.dsc, and then create the pflash files using following
>>> command:
>>> cat QEMU_EFI.fd /dev/zero | head -c 64m > ./QEMU_EFI-pflash.raw
>>> cat QEMU_VARS.fd /dev/zero | head -c 64m > ./vars-template-pflash.raw
>>> qemu-img convert -f raw -O qcow2 -o cluster_size=4096 -S 4096 QEMU_EFI-pflash.raw QEMU_EFI-pflash.qcow2
>>> qemu-img convert -f raw -O qcow2 -o cluster_size=4096 -S 4096 vars-template-pflash.raw vars-template-pflash.qcow2
>>>
>>> Download a AARCH64 QCOW2 image.
>>> Copy them into /usr/share/edk2/aarch64/.
>>>
>>> Step 2:
>>> Verification the pflash working:
>>> ArmVirtQemu:
>>> Run the QEMU ARM virt machine using the following command:
>>> qemu-system-aarch64 \
>>> -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/QEMU_EFI-pflash.qcow2","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \
>>> -blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"qcow2","file":"libvirt-pflash0-storage"}' \
>>> -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/vars-template-pflash.qcow2","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
>>> -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"qcow2","file":"libvirt-pflash1-storage"}' \
>>> -machine virt,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format,acpi=on \
>>> -cpu cortex-a57 \
>>> -m size=2097152k \
>>> -serial stdio \
>>> -net none \
>>> -device ramfb \
>>> -device nec-usb-xhci \
>>> -device usb-mouse \
>>> -device usb-kbd
>>>
>>> ArmVirtQemuKernel:
>>> Run the QEMU kernel ARM virt machine using the following command:
>>> qemu-system-aarch64 \
>>> -blockdev '{"driver":"file","filename":"/usr/share/edk2/aarch64/vars-template-pflash.raw","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
>>> -blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}' \
>>> -machine virt,usb=off,dump-guest-core=off,gic-version=3,pflash1=libvirt-pflash1-format \
>>> -cpu cortex-a57 \
>>> -m 4096 \
>>> -smp 1,sockets=1,cores=1,threads=1 \
>>> -no-user-config \
>>> -nodefaults \
>>> -device virtio-gpu-pci \
>>> -kernel /usr/share/edk2/aarch64/QEMU_EFI-pflash.raw \
>>> -serial stdio \
>>> -device nec-usb-xhci \
>>> -device usb-mouse \
>>> -device usb-kbd \
>>> -hda /usr/share/edk2/aarch64/openEuler-22.03-LTS-SP3-aarch64.qcow2 \
>>> -monitor tcp::3333,server,nowait
>>>
>>> Step 3:
>>> After the virt-machines starts, enter "F2" to enter the setup UI, try to
>>> change the boot order or some ther variables stored in the flash, then
>>> enter "F10" to save the changes and reboot it.
>>> After restarting, enter "F2" to enter the setup UI and check whether the
>>> changes before the restart operation have been saved.
>>>
>>>
>>> Using the above three steps, both platforms will works fine.
>>>
>>> I have not created the PR in github yet, I will create it once the edk2
>>> merge window reopens.
>>>
>>> Cc: Ard Biesheuvel<ardb+tianocore@kernel.org>
>>> Cc: Leif Lindholm<quic_llindhol@quicinc.com>
>>> Cc: Sami Mujawar<sami.mujawar@arm.com>
>>> Cc: Gerd Hoffmann<kraxel@redhat.com>
>>> Cc: Jiewen Yao<jiewen.yao@intel.com>
>>>
>>> Chao Li (2):
>>> OvmfPkg: Add no hardcode version of FtdNorFlashQemuLib
>>> ArmVirtPkg: Enable the non-hardcode version FtdNorFlashQemuLib
>>>
>>> ArmVirtPkg/ArmVirtQemu.dsc | 21 ++-
>>> ArmVirtPkg/ArmVirtQemuKernel.dsc | 20 ++-
>>> ArmVirtPkg/VarStore.fdf.inc | 5 +-
>>> .../FdtNorFlashQemuLib/FdtNorFlashQemuLib.c | 165 ++++++++++++++++++
>>> .../FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf | 46 +++++
>>> 5 files changed, 249 insertions(+), 8 deletions(-)
>>> create mode 100644 OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.c
>>> create mode 100644 OvmfPkg/Library/FdtNorFlashQemuLib/FdtNorFlashQemuLib.inf
>>>
>>> --
>>> 2.27.0
>>>
>>>
>>>
>>>
>>>
>>>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119250): https://edk2.groups.io/g/devel/message/119250
Mute This Topic: https://groups.io/mt/106149594/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 7718 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in
2024-05-24 8:38 ` Chao Li
@ 2024-05-29 9:09 ` Gerd Hoffmann
2024-05-30 3:10 ` Chao Li
0 siblings, 1 reply; 13+ messages in thread
From: Gerd Hoffmann @ 2024-05-29 9:09 UTC (permalink / raw)
To: devel, lichao
Cc: ardb, Ard Biesheuvel, Leif Lindholm, Sami Mujawar, Jiewen Yao
On Fri, May 24, 2024 at 04:38:26PM GMT, Chao Li wrote:
> Hi Ard and other maintainers,
>
> Could you help to review this patch set?
Looks good to me and survived a quick smoke test.
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
take care,
Gerd
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119336): https://edk2.groups.io/g/devel/message/119336
Mute This Topic: https://groups.io/mt/106149594/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [edk2-devel] [PATCH v1 0/2] Add a new FdtNorFalshQemuLib and enable it in
2024-05-29 9:09 ` Gerd Hoffmann
@ 2024-05-30 3:10 ` Chao Li
2024-05-30 12:35 ` Ard Biesheuvel
0 siblings, 1 reply; 13+ messages in thread
From: Chao Li @ 2024-05-30 3:10 UTC (permalink / raw)
To: devel, kraxel
Cc: ardb, Ard Biesheuvel, Leif Lindholm, Sami Mujawar, Jiewen Yao
[-- Attachment #1: Type: text/plain, Size: 884 bytes --]
Hi Ard,
Gerd has reviewed and tested this patch set, so can you give me the R-B
or should I create the PR on github?
Thanks,
Chao
On 2024/5/29 17:09, Gerd Hoffmann wrote:
> On Fri, May 24, 2024 at 04:38:26PM GMT, Chao Li wrote:
>> Hi Ard and other maintainers,
>>
>> Could you help to review this patch set?
> Looks good to me and survived a quick smoke test.
>
> Tested-by: Gerd Hoffmann<kraxel@redhat.com>
> Acked-by: Gerd Hoffmann<kraxel@redhat.com>
>
> take care,
> Gerd
>
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119376): https://edk2.groups.io/g/devel/message/119376
Mute This Topic: https://groups.io/mt/106149594/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 2315 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread