{\r
EFI_PHYSICAL_ADDRESS VariableStore;\r
RETURN_STATUS PcdStatus;\r
+ UINT32 Alignment;\r
\r
//\r
// Allocate storage for NV variables early on so it will be\r
// across reboots, this allows the NV variable storage to survive\r
// a VM reboot.\r
//\r
+ Alignment = PcdGet32 (PcdFlashNvStorageFtwSpareSize);\r
+ if ((Alignment & (Alignment - 1)) != 0) {\r
+ //\r
+ // Round up Alignment to the next power of two.\r
+ //\r
+ Alignment = GetPowerOfTwo32 (Alignment) << 1;\r
+ }\r
+\r
VariableStore =\r
(EFI_PHYSICAL_ADDRESS)(UINTN)\r
AllocateAlignedRuntimePages (\r
EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)),\r
- PcdGet32 (PcdFlashNvStorageFtwSpareSize)\r
+ Alignment\r
);\r
DEBUG ((EFI_D_INFO,\r
- "Reserved variable store memory: 0x%lX; size: %dkb\n",\r
+ "Reserved variable store memory: 0x%lX; size: %dkb, "\r
+ "alignment: 0x%x\n",\r
VariableStore,\r
- (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024\r
+ (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024,\r
+ Alignment\r
));\r
PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);\r
ASSERT_RETURN_ERROR (PcdStatus);\r