]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: PlatformPei: create the CPU HOB with dynamic memory space width
authorLaszlo Ersek <lersek@redhat.com>
Fri, 26 Jun 2015 16:09:43 +0000 (16:09 +0000)
committerlersek <lersek@Edk2>
Fri, 26 Jun 2015 16:09:43 +0000 (16:09 +0000)
Maoming reported that guest memory sizes equal to or larger than 64GB
were not correctly handled by OVMF.

Enabling the DEBUG_GCD (0x00100000) bit in PcdDebugPrintErrorLevel, and
starting QEMU with 64GB guest RAM size, I found the following error in the
OVMF debug log:

> GCD:AddMemorySpace(Base=0000000100000000,Length=0000000F40000000)
>   GcdMemoryType   = Reserved
>   Capabilities    = 030000000000000F
>   Status = Unsupported

This message is emitted when the DXE core is initializing the memory space
map, processing the "above 4GB" memory resource descriptor HOB that was
created by OVMF's QemuInitializeRam() function (see "UpperMemorySize").

The DXE core's call chain fails in:

CoreInternalAddMemorySpace() [MdeModulePkg/Core/Dxe/Gcd/Gcd.c]
  CoreConvertSpace()
    //
    // Search for the list of descriptors that cover the range BaseAddress
    // to BaseAddress+Length
    //
    CoreSearchGcdMapEntry()

CoreSearchGcdMapEntry() fails because the one entry (with type
"nonexistent") in the initial GCD memory space map is too small, and
cannot be split to cover the memory space range being added:

> GCD:Initial GCD Memory Space Map
> GCDMemType Range                             Capabilities     Attributes
> ========== ================================= ================ ================
> NonExist   0000000000000000-0000000FFFFFFFFF 0000000000000000 0000000000000000

The size of this initial entry is determined from the CPU HOB
(CoreInitializeGcdServices()).

Set the SizeOfMemorySpace field in the CPU HOB to mPhysMemAddressWidth,
which is the narrowest valid value to cover the entire guest RAM.

Reported-by: Maoming <maoming.maoming@huawei.com>
Cc: Maoming <maoming.maoming@huawei.com>
Cc: Huangpeng (Peter) <peter.huangpeng@huawei.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Wei Liu <wei.liu2@citrix.com>
Tested-by: Maoming <maoming.maoming@huawei.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17720 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/PlatformPei/Platform.c

index 6557a33a5fb04463ca278bc64466d305ae705582..fc98fc35e0781a88385ad015b7fcf3cd9f539319 100644 (file)
@@ -249,9 +249,11 @@ MiscInitialization (
   IoOr8 (0x92, BIT1);\r
 \r
   //\r
-  // Build the CPU hob with 36-bit addressing and 16-bits of IO space.\r
+  // Build the CPU HOB with guest RAM size dependent address width and 16-bits\r
+  // of IO space. (Side note: unlike other HOBs, the CPU HOB is needed during\r
+  // S3 resume as well, so we build it unconditionally.)\r
   //\r
-  BuildCpuHob (36, 16);\r
+  BuildCpuHob (mPhysMemAddressWidth, 16);\r
 \r
   //\r
   // Determine platform type and save Host Bridge DID to PCD\r