[edk2] [PATCH 3/5] OvmfPkg/PlatformPei: align EmuVariableNvStore at any page boundary

Laszlo Ersek posted 5 patches 7 years, 5 months ago
There is a newer version of this series
[edk2] [PATCH 3/5] OvmfPkg/PlatformPei: align EmuVariableNvStore at any page boundary
Posted by Laszlo Ersek 7 years, 5 months ago
EmuVariableFvbRuntimeDxe now uses a 4KB (EFI_PAGE_SIZE) block size.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/PlatformPei/Platform.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 1b4dc00b0180..3e9fda7c7ab0 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -504,7 +504,6 @@ ReserveEmuVariableNvStore (
 {
   EFI_PHYSICAL_ADDRESS VariableStore;
   RETURN_STATUS        PcdStatus;
-  UINT32               Alignment;
 
   //
   // Allocate storage for NV variables early on so it will be
@@ -512,26 +511,15 @@ ReserveEmuVariableNvStore (
   // across reboots, this allows the NV variable storage to survive
   // a VM reboot.
   //
-  Alignment = PcdGet32 (PcdFlashNvStorageFtwSpareSize);
-  if ((Alignment & (Alignment - 1)) != 0) {
-    //
-    // Round up Alignment to the next power of two.
-    //
-    Alignment = GetPowerOfTwo32 (Alignment) << 1;
-  }
-
   VariableStore =
     (EFI_PHYSICAL_ADDRESS)(UINTN)
-      AllocateAlignedRuntimePages (
-        EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)),
-        Alignment
+      AllocateRuntimePages (
+        EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))
         );
   DEBUG ((EFI_D_INFO,
-          "Reserved variable store memory: 0x%lX; size: %dkb, "
-          "alignment: 0x%x\n",
+          "Reserved variable store memory: 0x%lX; size: %dkb\n",
           VariableStore,
-          (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024,
-          Alignment
+          (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
         ));
   PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
   ASSERT_RETURN_ERROR (PcdStatus);
-- 
2.9.3


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH 3/5] OvmfPkg/PlatformPei: align EmuVariableNvStore at any page boundary
Posted by Gary Lin 7 years, 5 months ago
On Sat, May 06, 2017 at 09:30:21PM +0200, Laszlo Ersek wrote:
> EmuVariableFvbRuntimeDxe now uses a 4KB (EFI_PAGE_SIZE) block size.
> 
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>

Regression-tested-by: Gary Lin <glin@suse.com>

> ---
>  OvmfPkg/PlatformPei/Platform.c | 20 ++++----------------
>  1 file changed, 4 insertions(+), 16 deletions(-)
> 
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index 1b4dc00b0180..3e9fda7c7ab0 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -504,7 +504,6 @@ ReserveEmuVariableNvStore (
>  {
>    EFI_PHYSICAL_ADDRESS VariableStore;
>    RETURN_STATUS        PcdStatus;
> -  UINT32               Alignment;
>  
>    //
>    // Allocate storage for NV variables early on so it will be
> @@ -512,26 +511,15 @@ ReserveEmuVariableNvStore (
>    // across reboots, this allows the NV variable storage to survive
>    // a VM reboot.
>    //
> -  Alignment = PcdGet32 (PcdFlashNvStorageFtwSpareSize);
> -  if ((Alignment & (Alignment - 1)) != 0) {
> -    //
> -    // Round up Alignment to the next power of two.
> -    //
> -    Alignment = GetPowerOfTwo32 (Alignment) << 1;
> -  }
> -
>    VariableStore =
>      (EFI_PHYSICAL_ADDRESS)(UINTN)
> -      AllocateAlignedRuntimePages (
> -        EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)),
> -        Alignment
> +      AllocateRuntimePages (
> +        EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))
>          );
>    DEBUG ((EFI_D_INFO,
> -          "Reserved variable store memory: 0x%lX; size: %dkb, "
> -          "alignment: 0x%x\n",
> +          "Reserved variable store memory: 0x%lX; size: %dkb\n",
>            VariableStore,
> -          (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024,
> -          Alignment
> +          (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
>          ));
>    PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
>    ASSERT_RETURN_ERROR (PcdStatus);
> -- 
> 2.9.3
> 
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
> 
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel