|
|
eb7fe6 |
From 0d92c07320682a2b0f0d2560bb447ec48d373049 Mon Sep 17 00:00:00 2001
|
|
|
eb7fe6 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
eb7fe6 |
Date: Fri, 5 May 2017 20:24:19 +0200
|
|
|
eb7fe6 |
Subject: [PATCH 08/10] OvmfPkg/PlatformPei: handle non-power-of-two spare size
|
|
|
eb7fe6 |
for emu variables
|
|
|
eb7fe6 |
|
|
|
eb7fe6 |
Message-id: <20170505182421.19670-9-lersek@redhat.com>
|
|
|
eb7fe6 |
Patchwork-id: 75034
|
|
|
eb7fe6 |
O-Subject: [RHEL-7.4 ovmf PATCH v2 08/10] OvmfPkg/PlatformPei: handle
|
|
|
eb7fe6 |
non-power-of-two spare size for emu variables
|
|
|
eb7fe6 |
Bugzilla: 1443351
|
|
|
eb7fe6 |
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
eb7fe6 |
Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
|
|
|
eb7fe6 |
Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
eb7fe6 |
|
|
|
eb7fe6 |
In commit b24fca05751f ("OvmfPkg: introduce 4MB flash image (mainly) for
|
|
|
eb7fe6 |
Windows HCK", 2017-04-29), I changed PcdFlashNvStorageFtwSpareSize to
|
|
|
eb7fe6 |
264KB, in the then-new default 4MB build.
|
|
|
eb7fe6 |
|
|
|
eb7fe6 |
While PcdFlashNvStorageFtwSpareSize remains exactly half of the entire
|
|
|
eb7fe6 |
non-volatile store (which is 528KB), 264KB isn't itself a power of two.
|
|
|
eb7fe6 |
This triggers an assertion failure in AllocateAlignedRuntimePages() when
|
|
|
eb7fe6 |
PlatformPei calls it from the ReserveEmuVariableNvStore() function,
|
|
|
eb7fe6 |
passing PcdFlashNvStorageFtwSpareSize as the Alignment parameter:
|
|
|
eb7fe6 |
|
|
|
eb7fe6 |
> ASSERT MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c(196):
|
|
|
eb7fe6 |
> (Alignment & (Alignment - 1)) == 0
|
|
|
eb7fe6 |
|
|
|
eb7fe6 |
Round up the alignment to the next power of two if necessary.
|
|
|
eb7fe6 |
|
|
|
eb7fe6 |
Fixes: b24fca05751f8222acf264853709012e0ab7bf49
|
|
|
eb7fe6 |
Contributed-under: TianoCore Contribution Agreement 1.0
|
|
|
eb7fe6 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
eb7fe6 |
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
|
|
|
eb7fe6 |
(cherry picked from commit 0c79471d6a986b858c35dc577eaeb344cc5c4cdd)
|
|
|
eb7fe6 |
---
|
|
|
eb7fe6 |
OvmfPkg/PlatformPei/Platform.c | 17 ++++++++++++++---
|
|
|
eb7fe6 |
1 file changed, 14 insertions(+), 3 deletions(-)
|
|
|
eb7fe6 |
|
|
|
eb7fe6 |
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
|
|
|
eb7fe6 |
index 5ef0fdc..6c8758c 100644
|
|
|
eb7fe6 |
--- a/OvmfPkg/PlatformPei/Platform.c
|
|
|
eb7fe6 |
+++ b/OvmfPkg/PlatformPei/Platform.c
|
|
|
eb7fe6 |
@@ -503,6 +503,7 @@ ReserveEmuVariableNvStore (
|
|
|
eb7fe6 |
{
|
|
|
eb7fe6 |
EFI_PHYSICAL_ADDRESS VariableStore;
|
|
|
eb7fe6 |
RETURN_STATUS PcdStatus;
|
|
|
eb7fe6 |
+ UINT32 Alignment;
|
|
|
eb7fe6 |
|
|
|
eb7fe6 |
//
|
|
|
eb7fe6 |
// Allocate storage for NV variables early on so it will be
|
|
|
eb7fe6 |
@@ -510,16 +511,26 @@ ReserveEmuVariableNvStore (
|
|
|
eb7fe6 |
// across reboots, this allows the NV variable storage to survive
|
|
|
eb7fe6 |
// a VM reboot.
|
|
|
eb7fe6 |
//
|
|
|
eb7fe6 |
+ Alignment = PcdGet32 (PcdFlashNvStorageFtwSpareSize);
|
|
|
eb7fe6 |
+ if ((Alignment & (Alignment - 1)) != 0) {
|
|
|
eb7fe6 |
+ //
|
|
|
eb7fe6 |
+ // Round up Alignment to the next power of two.
|
|
|
eb7fe6 |
+ //
|
|
|
eb7fe6 |
+ Alignment = GetPowerOfTwo32 (Alignment) << 1;
|
|
|
eb7fe6 |
+ }
|
|
|
eb7fe6 |
+
|
|
|
eb7fe6 |
VariableStore =
|
|
|
eb7fe6 |
(EFI_PHYSICAL_ADDRESS)(UINTN)
|
|
|
eb7fe6 |
AllocateAlignedRuntimePages (
|
|
|
eb7fe6 |
EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)),
|
|
|
eb7fe6 |
- PcdGet32 (PcdFlashNvStorageFtwSpareSize)
|
|
|
eb7fe6 |
+ Alignment
|
|
|
eb7fe6 |
);
|
|
|
eb7fe6 |
DEBUG ((EFI_D_INFO,
|
|
|
eb7fe6 |
- "Reserved variable store memory: 0x%lX; size: %dkb\n",
|
|
|
eb7fe6 |
+ "Reserved variable store memory: 0x%lX; size: %dkb, "
|
|
|
eb7fe6 |
+ "alignment: 0x%x\n",
|
|
|
eb7fe6 |
VariableStore,
|
|
|
eb7fe6 |
- (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
|
|
|
eb7fe6 |
+ (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024,
|
|
|
eb7fe6 |
+ Alignment
|
|
|
eb7fe6 |
));
|
|
|
eb7fe6 |
PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
|
|
|
eb7fe6 |
ASSERT_RETURN_ERROR (PcdStatus);
|
|
|
eb7fe6 |
--
|
|
|
eb7fe6 |
1.8.3.1
|
|
|
eb7fe6 |
|