public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v3 0/4] OvmfPkg/RiscVVirt: Separate code and variable storage
@ 2023-06-20 10:02 Sunil V L
  2023-06-20 10:02 ` [PATCH v3 1/4] OvmfPkg/RiscVVirt: Fix couple of issues in VarStore Sunil V L
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sunil V L @ 2023-06-20 10:02 UTC (permalink / raw)
  To: devel
  Cc: Sunil V L, Ard Biesheuvel, Jiewen Yao, Jordan Justen,
	Gerd Hoffmann, Andrei Warkentin, Heinrich Schuchardt,
	Dann Frazier

Recent updates to RISC-V qemu virt platform merged today (07/14),
have enabled both pflash devices for the S-mode payload like EDK2.
These updates also aligned the design similar to other architectures
where pflash0 is for read-only code and pflash1 for variable store.
Previously only pflash1 was available for S-mode use. 

Current EDK2 will not work with this latest qemu changes since it always
assumed to boot from pflash1. So, separate the code and variable
store and use pflash0 to keep the code.

Add 'readme' about build and test as per these changes.

The changes are available in the branch :
https://github.com/vlsunil/edk2/tree/separate_code_vars

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Cc: Dann Frazier <dann.frazier@canonical.com>

Changes since v2:
	1) Addressed Heinrich's comments in readme.

Changes since v1:
	1) Updated readme to add minimum qemu version required.

Sunil V L (4):
  OvmfPkg/RiscVVirt: Fix couple of issues in VarStore
  OvmfPkg/RiscVVirt: Add VirtNorFlashDeviceTreeLib library
  OvmfPkg/RiscVVirt: Add support for separate code and variable store
  OvmfPkg/RiscVVirt: Add a readme for build and test

 OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc           |   2 +-
 OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf           |  16 +-
 .../VirtNorFlashDeviceTreeLib.inf             |  40 +++++
 .../VirtNorFlashDeviceTreeLib.c               | 137 ++++++++++++++++++
 OvmfPkg/RiscVVirt/README.md                   |  49 +++++++
 OvmfPkg/RiscVVirt/RiscVVirt.fdf.inc           |  14 +-
 OvmfPkg/RiscVVirt/VarStore.fdf.inc            |  12 +-
 7 files changed, 251 insertions(+), 19 deletions(-)
 create mode 100644 OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf
 create mode 100644 OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.c
 create mode 100644 OvmfPkg/RiscVVirt/README.md

-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/4] OvmfPkg/RiscVVirt: Fix couple of issues in VarStore
  2023-06-20 10:02 [PATCH v3 0/4] OvmfPkg/RiscVVirt: Separate code and variable storage Sunil V L
@ 2023-06-20 10:02 ` Sunil V L
  2023-06-20 10:02 ` [PATCH v3 2/4] OvmfPkg/RiscVVirt: Add VirtNorFlashDeviceTreeLib library Sunil V L
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Sunil V L @ 2023-06-20 10:02 UTC (permalink / raw)
  To: devel
  Cc: Sunil V L, Ard Biesheuvel, Jiewen Yao, Jordan Justen,
	Gerd Hoffmann, Andrei Warkentin, Heinrich Schuchardt

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 <sunilvl@ventanamicro.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 OvmfPkg/RiscVVirt/VarStore.fdf.inc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/OvmfPkg/RiscVVirt/VarStore.fdf.inc b/OvmfPkg/RiscVVirt/VarStore.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|gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
 #
-#NV_FTW_WROK
+#NV_FTW_WORK
 #
 DATA = {
   # EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature = gEdkiiWorkingBlockSignatureGuid         =
@@ -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, Reserved
-  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
 }
 
 $(VARS_FTW_SPARE_OFFSET)|$(VARS_FTW_SPARE_SIZE)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 2/4] OvmfPkg/RiscVVirt: Add VirtNorFlashDeviceTreeLib library
  2023-06-20 10:02 [PATCH v3 0/4] OvmfPkg/RiscVVirt: Separate code and variable storage Sunil V L
  2023-06-20 10:02 ` [PATCH v3 1/4] OvmfPkg/RiscVVirt: Fix couple of issues in VarStore Sunil V L
@ 2023-06-20 10:02 ` Sunil V L
  2023-06-20 10:02 ` [PATCH v3 3/4] OvmfPkg/RiscVVirt: Add support for separate code and variable store Sunil V L
  2023-06-20 10:02 ` [PATCH v3 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test Sunil V L
  3 siblings, 0 replies; 5+ messages in thread
From: Sunil V L @ 2023-06-20 10:02 UTC (permalink / raw)
  To: devel
  Cc: Sunil V L, Ard Biesheuvel, Jiewen Yao, Jordan Justen,
	Gerd Hoffmann, Andrei Warkentin, Heinrich Schuchardt

This library is required to support separate code and
variable store images.

Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 .../VirtNorFlashDeviceTreeLib.inf             |  40 +++++
 .../VirtNorFlashDeviceTreeLib.c               | 137 ++++++++++++++++++
 2 files changed, 177 insertions(+)
 create mode 100644 OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf
 create mode 100644 OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.c

diff --git a/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf b/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf
new file mode 100644
index 000000000000..90df756e79a9
--- /dev/null
+++ b/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf
@@ -0,0 +1,40 @@
+#/** @file
+#
+#  Component description file for VirtNorFlashDeviceTreeLib module
+#
+#  Copyright (c) 2023, Ventana Micro Systems Inc. All rights reserved.<BR>
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#**/
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = VirtNorFlashDeviceTreeLib
+  FILE_GUID                      = 1D74E65F-A468-4FA6-ACB6-E4E941EB79D6
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = 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/VirtNorFlashDeviceTreeLib.c b/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.c
new file mode 100644
index 000000000000..73534a866430
--- /dev/null
+++ b/OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.c
@@ -0,0 +1,137 @@
+/** @file
+
+ Copyright (c) 2014-2018, Linaro Ltd. All rights reserved.<BR>
+ Copyright (c) 2023, Ventana Micro Systems Inc. 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>
+
+#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 = gBS->LocateProtocol (
+                  &gFdtClientProtocolGuid,
+                  NULL,
+                  (VOID **)&FdtClient
+                  );
+  ASSERT_EFI_ERROR (Status);
+
+  Num = 0;
+  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++;
+    }
+
+    //
+    // 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;
+}
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 3/4] OvmfPkg/RiscVVirt: Add support for separate code and variable store
  2023-06-20 10:02 [PATCH v3 0/4] OvmfPkg/RiscVVirt: Separate code and variable storage Sunil V L
  2023-06-20 10:02 ` [PATCH v3 1/4] OvmfPkg/RiscVVirt: Fix couple of issues in VarStore Sunil V L
  2023-06-20 10:02 ` [PATCH v3 2/4] OvmfPkg/RiscVVirt: Add VirtNorFlashDeviceTreeLib library Sunil V L
@ 2023-06-20 10:02 ` Sunil V L
  2023-06-20 10:02 ` [PATCH v3 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test Sunil V L
  3 siblings, 0 replies; 5+ messages in thread
From: Sunil V L @ 2023-06-20 10:02 UTC (permalink / raw)
  To: devel
  Cc: Sunil V L, Ard Biesheuvel, Jiewen Yao, Jordan Justen,
	Gerd Hoffmann, Andrei Warkentin, Heinrich Schuchardt

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 <sunilvl@ventanamicro.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 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/RiscVVirtQemu.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/GenericQemuLoadImageLib.inf
 
   TimerLib|UefiCpuPkg/Library/BaseRiscV64CpuTimerLib/BaseRiscV64CpuTimerLib.inf
-  VirtNorFlashPlatformLib|OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashStaticLib.inf
+  VirtNorFlashPlatformLib|OvmfPkg/RiscVVirt/Library/VirtNorFlashPlatformLib/VirtNorFlashDeviceTreeLib.inf
 
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
   BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
diff --git a/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf b/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf
index 354c9271d10c..21e4ba67379f 100644
--- a/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf
+++ b/OvmfPkg/RiscVVirt/RiscVVirtQemu.fdf
@@ -12,17 +12,25 @@
 !include RiscVVirt.fdf.inc
 
 ################################################################################
-[FD.RISCV_VIRT]
-BaseAddress   = $(FW_BASE_ADDRESS)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress
-Size          = $(FW_SIZE)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize
+[FD.RISCV_VIRT_CODE]
+BaseAddress   = $(CODE_BASE_ADDRESS)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress
+Size          = $(CODE_SIZE)|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize
 ErasePolarity = 1
 BlockSize     = $(BLOCK_SIZE)
-NumBlocks     = $(FW_BLOCKS)
+NumBlocks     = $(CODE_BLOCKS)
 
 0x00000000|$(CODE_SIZE)
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
 FV = FVMAIN_COMPACT
 
+################################################################################
+[FD.RISCV_VIRT_VARS]
+BaseAddress   = $(VARS_BASE_ADDRESS)
+Size          = $(VARS_SIZE)
+ErasePolarity = 1
+BlockSize     = $(VARS_BLOCK_SIZE)
+NumBlocks     = $(VARS_BLOCKS)
+
 !include VarStore.fdf.inc
 ################################################################################
 
diff --git a/OvmfPkg/RiscVVirt/RiscVVirt.fdf.inc b/OvmfPkg/RiscVVirt/RiscVVirt.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                  = 0x1000
 
+DEFINE PFLASH0_BASE                = 0x20000000
 DEFINE PFLASH1_BASE                = 0x22000000
 
-DEFINE FW_BASE_ADDRESS             = $(PFLASH1_BASE)
-DEFINE FW_SIZE                     = 0x00800000
-DEFINE FW_BLOCKS                   = 0x800
-
-DEFINE CODE_BASE_ADDRESS           = $(FW_BASE_ADDRESS)
-DEFINE CODE_SIZE                   = 0x00740000
-DEFINE CODE_BLOCKS                 = 0x740
+DEFINE CODE_BASE_ADDRESS           = $(PFLASH0_BASE)
+DEFINE CODE_SIZE                   = 0x00800000
+DEFINE CODE_BLOCKS                 = 0x800
 
+DEFINE VARS_BASE_ADDRESS            = $(PFLASH1_BASE)
 DEFINE VARS_SIZE                    = 0x000C0000
 DEFINE VARS_BLOCK_SIZE              = 0x40000
 DEFINE VARS_BLOCKS                  = 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                   = $(CODE_SIZE)
+DEFINE VARS_OFFSET                   = 0x00000000
 DEFINE VARS_LIVE_SIZE                = 0x00040000
 DEFINE VARS_FTW_WORKING_OFFSET       = $(VARS_OFFSET) + $(VARS_LIVE_SIZE)
 DEFINE VARS_FTW_WORKING_SIZE         = 0x00040000
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v3 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test
  2023-06-20 10:02 [PATCH v3 0/4] OvmfPkg/RiscVVirt: Separate code and variable storage Sunil V L
                   ` (2 preceding siblings ...)
  2023-06-20 10:02 ` [PATCH v3 3/4] OvmfPkg/RiscVVirt: Add support for separate code and variable store Sunil V L
@ 2023-06-20 10:02 ` Sunil V L
  3 siblings, 0 replies; 5+ messages in thread
From: Sunil V L @ 2023-06-20 10:02 UTC (permalink / raw)
  To: devel
  Cc: Sunil V L, Ard Biesheuvel, Jiewen Yao, Jordan Justen,
	Gerd Hoffmann, Andrei Warkentin, Heinrich Schuchardt

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 <sunilvl@ventanamicro.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Andrei Warkentin <andrei.warkentin@intel.com>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 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/7efd65423ab22e6f5890ca08ae40c84d6660242f)
+which supports separate pflash devices for EDK2 code and variable storage.
+
+## Build
+    export WORKSPACE=`pwd`
+    export GCC5_RISCV64_PREFIX=riscv64-linux-gnu-
+    export PACKAGES_PATH=$WORKSPACE/edk2
+    export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools
+    source edk2/edksetup.sh
+    make -C edk2/BaseTools
+    source edk2/edksetup.sh BaseTools
+    build -a RISCV64 --buildtarget RELEASE -p OvmfPkg/RiscVVirt/RiscVVirtQemu.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.fd`
+
+    `truncate -s 32M Build/RiscVVirtQemu/RELEASE_GCC5/FV/RISCV_VIRT_VARS.fd`
+
+2) Running QEMU
+
+        qemu-system-riscv64 \
+        -M virt,pflash0=pflash0,pflash1=pflash1,acpi=off \
+        -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=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
+        -blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
+        -netdev user,id=net0 \
+        -device virtio-net-pci,netdev=net0 \
+        -device virtio-blk-device,drive=hd0 \
+        -drive file=openSUSE-Tumbleweed-RISC-V-E20-efi.riscv64.raw,format=raw,id=hd0
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-20 10:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-20 10:02 [PATCH v3 0/4] OvmfPkg/RiscVVirt: Separate code and variable storage Sunil V L
2023-06-20 10:02 ` [PATCH v3 1/4] OvmfPkg/RiscVVirt: Fix couple of issues in VarStore Sunil V L
2023-06-20 10:02 ` [PATCH v3 2/4] OvmfPkg/RiscVVirt: Add VirtNorFlashDeviceTreeLib library Sunil V L
2023-06-20 10:02 ` [PATCH v3 3/4] OvmfPkg/RiscVVirt: Add support for separate code and variable store Sunil V L
2023-06-20 10:02 ` [PATCH v3 4/4] OvmfPkg/RiscVVirt: Add a readme for build and test Sunil V L

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox