public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G
       [not found] <cover.1638759596.git.lixianglai@loongson.cn>
@ 2021-12-06  4:00 ` xianglai
  2021-12-06 12:18   ` Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: xianglai @ 2021-12-06  4:00 UTC (permalink / raw)
  To: devel; +Cc: xianglai li

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


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

* Re: [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G
  2021-12-06  4:00 ` [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G xianglai
@ 2021-12-06 12:18   ` Gerd Hoffmann
  2021-12-11 15:36     ` Yao, Jiewen
       [not found]     ` <16BFBD5C8AF150FF.19089@groups.io>
  0 siblings, 2 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2021-12-06 12:18 UTC (permalink / raw)
  To: devel, lixianglai

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>


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

* Re: [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G
  2021-12-06 12:18   ` Gerd Hoffmann
@ 2021-12-11 15:36     ` Yao, Jiewen
       [not found]     ` <16BFBD5C8AF150FF.19089@groups.io>
  1 sibling, 0 replies; 4+ messages in thread
From: Yao, Jiewen @ 2021-12-11 15:36 UTC (permalink / raw)
  To: devel@edk2.groups.io, kraxel@redhat.com, lixianglai@loongson.cn

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>
> 
> 
> 
> 
> 


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

* Re: [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G
       [not found]     ` <16BFBD5C8AF150FF.19089@groups.io>
@ 2021-12-11 16:13       ` Yao, Jiewen
  0 siblings, 0 replies; 4+ messages in thread
From: Yao, Jiewen @ 2021-12-11 16:13 UTC (permalink / raw)
  To: devel@edk2.groups.io, Yao, Jiewen, kraxel@redhat.com,
	lixianglai@loongson.cn

Merged https://github.com/tianocore/edk2/pull/2290


> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Yao, Jiewen
> Sent: Saturday, December 11, 2021 11:36 PM
> To: devel@edk2.groups.io; kraxel@redhat.com; lixianglai@loongson.cn
> Subject: Re: [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe:
> Support Access To Memory Above 4G
> 
> 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>
> >
> >
> >
> >
> >
> 
> 
> 
> 
> 


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

end of thread, other threads:[~2021-12-11 16:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1638759596.git.lixianglai@loongson.cn>
2021-12-06  4:00 ` [edk2-devel] [PATCH] OvmfPkg-EmuVariableFvbRuntimeDxe: Support Access To Memory Above 4G xianglai
2021-12-06 12:18   ` Gerd Hoffmann
2021-12-11 15:36     ` Yao, Jiewen
     [not found]     ` <16BFBD5C8AF150FF.19089@groups.io>
2021-12-11 16:13       ` Yao, Jiewen

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