OvmfPkg/PlatformPei: handle non-power-of-two spare size for emu variables
authorLaszlo Ersek <lersek@redhat.com>
Fri, 5 May 2017 00:35:21 +0000 (02:35 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Fri, 5 May 2017 16:02:12 +0000 (18:02 +0200)
commit0c79471d6a986b858c35dc577eaeb344cc5c4cdd
tree175fcb68c35e04b11f140cd98c50730df9e5ff92
parent6e49d01cfb43db92f8b698ec16d811981c2da22b
OvmfPkg/PlatformPei: handle non-power-of-two spare size for emu variables

In commit b24fca05751f ("OvmfPkg: introduce 4MB flash image (mainly) for
Windows HCK", 2017-04-29), I changed PcdFlashNvStorageFtwSpareSize to
264KB, in the then-new default 4MB build.

While PcdFlashNvStorageFtwSpareSize remains exactly half of the entire
non-volatile store (which is 528KB), 264KB isn't itself a power of two.
This triggers an assertion failure in AllocateAlignedRuntimePages() when
PlatformPei calls it from the ReserveEmuVariableNvStore() function,
passing PcdFlashNvStorageFtwSpareSize as the Alignment parameter:

> ASSERT MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c(196):
> (Alignment & (Alignment - 1)) == 0

Round up the alignment to the next power of two if necessary.

Fixes: b24fca05751f8222acf264853709012e0ab7bf49
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
OvmfPkg/PlatformPei/Platform.c