]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: PlatformPei: force 32-bit MMIO aperture above 3 GB on Q35
authorLaszlo Ersek <lersek@redhat.com>
Wed, 2 Sep 2015 18:45:44 +0000 (18:45 +0000)
committerlersek <lersek@Edk2>
Wed, 2 Sep 2015 18:45:44 +0000 (18:45 +0000)
The logic we have in place for i440fx does not work reliably on q35. For
example, if the guest has 2GB of RAM, we allow the PCI root bridge driver
to allocate the legacy video RAM BAR from the [2048 MB, 2816 MB] range,
which falls strictly outside of the Q35 PCI host MMIO aperture that QEMU
configures, and advertizes in ACPI.

In turn, PCI BARs that exist outside of the PCI host aperture that is
exposed in ACPI break Windows guests.

Allocating PCI MMIO resources at or above 3GB on Q35 ensures that we stay
within QEMU's aperture. (See the "w32.begin" assignments in
"hw/pci-host/q35.c".) Furthermore, in pc_q35_init() (file
"hw/i386/pc_q35.c"), QEMU ensures that the low RAM never "leaks" above
3GB.

The i440fx logic is left unchanged.

The Windows guest malfunction on Q35 was reported by Jon Panozzo of Lime
Technology, Inc.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Jon Panozzo <jonp@lime-technology.com>
Cc: "Gabriel L. Somlo" <somlo@cmu.edu>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Tested-by: Jonathan Panozzo <jonp@lime-technology.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18393 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/PlatformPei/Platform.c

index 2cc4c7e973627e2b3ad8d98d276abd8c9ff57241..6a7bc52c45db3e15138cf620a4b103bdeb1d737c 100644 (file)
@@ -204,7 +204,20 @@ MemMapInitialization (
 \r
   if (!mXen) {\r
     UINT32  TopOfLowRam;\r
+    UINT32  PciBase;\r
+\r
     TopOfLowRam = GetSystemMemorySizeBelow4gb ();\r
+    if (mHostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {\r
+      //\r
+      // A 3GB base will always fall into Q35's 32-bit PCI host aperture,\r
+      // regardless of the Q35 MMCONFIG BAR. Correspondingly, QEMU never lets\r
+      // the RAM below 4 GB exceed it.\r
+      //\r
+      PciBase = BASE_2GB + BASE_1GB;\r
+      ASSERT (TopOfLowRam <= PciBase);\r
+    } else {\r
+      PciBase = (TopOfLowRam < BASE_2GB) ? BASE_2GB : TopOfLowRam;\r
+    }\r
 \r
     //\r
     // address       purpose   size\r
@@ -219,8 +232,7 @@ MemMapInitialization (
     // 0xFED20000    gap                          896 KB\r
     // 0xFEE00000    LAPIC                          1 MB\r
     //\r
-    AddIoMemoryRangeHob (TopOfLowRam < BASE_2GB ?\r
-                         BASE_2GB : TopOfLowRam, 0xFC000000);\r
+    AddIoMemoryRangeHob (PciBase, 0xFC000000);\r
     AddIoMemoryBaseSizeHob (0xFEC00000, SIZE_4KB);\r
     AddIoMemoryBaseSizeHob (0xFED00000, SIZE_1KB);\r
     if (mHostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {\r