[edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G

xianglai posted 1 patch 2 years, 4 months ago
Failed in applying to current master (apply log)
OvmfPkg/AmdSev/AmdSevX64.dsc             | 2 ++
OvmfPkg/Bhyve/BhyveX64.dsc               | 2 ++
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c   | 8 +++-----
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf | 4 ++--
OvmfPkg/Microvm/MicrovmX64.dsc           | 2 ++
OvmfPkg/OvmfPkgIa32.dsc                  | 2 ++
OvmfPkg/OvmfPkgIa32X64.dsc               | 2 ++
OvmfPkg/OvmfPkgX64.dsc                   | 2 ++
OvmfPkg/OvmfXen.dsc                      | 2 ++
9 files changed, 19 insertions(+), 7 deletions(-)
[edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G
Posted by xianglai 2 years, 4 months ago
In FvbInitialize Function,
PcdFlashNvStorageVariableBase64 PcdFlashNvStorageFtwWorkingBase
PcdFlashNvStorageFtwSpareBase will not exceed 0x100000000,
Due to truncation and variable type limitations.
That leads to the NV variable cannot be saved to the memory above 4G.

Modify as follows:
1.Remove the forced type conversion of UINT32.
2.Use UINT64 type variables.

Signed-off-by: xianglai li <lixianglai@loongson.cn>
---
 OvmfPkg/AmdSev/AmdSevX64.dsc             | 2 ++
 OvmfPkg/Bhyve/BhyveX64.dsc               | 2 ++
 OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c   | 8 +++-----
 OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf | 4 ++--
 OvmfPkg/Microvm/MicrovmX64.dsc           | 2 ++
 OvmfPkg/OvmfPkgIa32.dsc                  | 2 ++
 OvmfPkg/OvmfPkgIa32X64.dsc               | 2 ++
 OvmfPkg/OvmfPkgX64.dsc                   | 2 ++
 OvmfPkg/OvmfXen.dsc                      | 2 ++
 9 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index 5ee5445..d5ad34a 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -535,6 +535,8 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index d8fe607..8584e32 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -513,6 +513,8 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
index 766ad1e..2d03af1 100644
--- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
+++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
@@ -776,15 +776,14 @@ FvbInitialize (
     SetMem (Ptr, EMU_FVB_SIZE, ERASED_UINT8);
     InitializeFvAndVariableStoreHeaders (Ptr);
   }
-  PcdStatus = PcdSet64S (PcdFlashNvStorageVariableBase64, (UINT32)(UINTN) Ptr);
+  PcdStatus = PcdSet64S (PcdFlashNvStorageVariableBase64, (UINTN) Ptr);
   ASSERT_RETURN_ERROR (PcdStatus);
 
   //
   // Initialize the Fault Tolerant Write data area
   //
   SubPtr = (VOID*) ((UINT8*) Ptr + PcdGet32 (PcdFlashNvStorageVariableSize));
-  PcdStatus = PcdSet32S (PcdFlashNvStorageFtwWorkingBase,
-                (UINT32)(UINTN) SubPtr);
+  PcdStatus = PcdSet64S (PcdFlashNvStorageFtwWorkingBase64, (UINTN) SubPtr);
   ASSERT_RETURN_ERROR (PcdStatus);
 
   //
@@ -792,8 +791,7 @@ FvbInitialize (
   //
   SubPtr = (VOID*) ((UINT8*) Ptr +
                     EMU_FVB_NUM_SPARE_BLOCKS * EMU_FVB_BLOCK_SIZE);
-  PcdStatus = PcdSet32S (PcdFlashNvStorageFtwSpareBase,
-                (UINT32)(UINTN) SubPtr);
+  PcdStatus = PcdSet64S (PcdFlashNvStorageFtwSpareBase64, (UINTN) SubPtr);
   ASSERT_RETURN_ERROR (PcdStatus);
 
   //
diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
index 225ea27..0811545 100644
--- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
+++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
@@ -59,8 +59,8 @@
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved
 
 [Depex]
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 617f925..57d6caa 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -553,6 +553,8 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 6a5be97..3d45e08 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -596,6 +596,8 @@
 
 !if $(SMM_REQUIRE) == FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 71227d1..347467d 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -602,6 +602,8 @@
 
 !if $(SMM_REQUIRE) == FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
 !endif
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 52f7598..e7d34dd 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -602,6 +602,8 @@
 
 !if $(SMM_REQUIRE) == FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
 !endif
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index a31519e..74e878f 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -460,6 +460,8 @@
 [PcdsDynamicDefault]
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64|0
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|800
-- 
1.8.3.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84372): https://edk2.groups.io/g/devel/message/84372
Mute This Topic: https://groups.io/mt/87534620/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G
Posted by Gerd Hoffmann 2 years, 4 months ago
On Mon, Dec 06, 2021 at 12:00:33PM +0800, xianglai wrote:
> In FvbInitialize Function,
> PcdFlashNvStorageVariableBase64 PcdFlashNvStorageFtwWorkingBase
> PcdFlashNvStorageFtwSpareBase will not exceed 0x100000000,
> Due to truncation and variable type limitations.
> That leads to the NV variable cannot be saved to the memory above 4G.
> 
> Modify as follows:
> 1.Remove the forced type conversion of UINT32.
> 2.Use UINT64 type variables.
> 
> Signed-off-by: xianglai li <lixianglai@loongson.cn>

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84401): https://edk2.groups.io/g/devel/message/84401
Mute This Topic: https://groups.io/mt/87534620/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G
Posted by Yao, Jiewen 2 years, 4 months ago
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Gerd
> Hoffmann
> Sent: Monday, December 6, 2021 8:19 PM
> To: devel@edk2.groups.io; lixianglai@loongson.cn
> Subject: Re: [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe:
> Support Access To Memory Above 4G
> 
> On Mon, Dec 06, 2021 at 12:00:33PM +0800, xianglai wrote:
> > In FvbInitialize Function,
> > PcdFlashNvStorageVariableBase64 PcdFlashNvStorageFtwWorkingBase
> > PcdFlashNvStorageFtwSpareBase will not exceed 0x100000000,
> > Due to truncation and variable type limitations.
> > That leads to the NV variable cannot be saved to the memory above 4G.
> >
> > Modify as follows:
> > 1.Remove the forced type conversion of UINT32.
> > 2.Use UINT64 type variables.
> >
> > Signed-off-by: xianglai li <lixianglai@loongson.cn>
> 
> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84657): https://edk2.groups.io/g/devel/message/84657
Mute This Topic: https://groups.io/mt/87534620/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-