}\r
\r
if (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {\r
- //\r
- // On q35, the 32-bit area that we'll mark as UC, through variable MTRRs,\r
- // starts at PcdPciExpressBaseAddress. The platform DSC is responsible for\r
- // setting PcdPciExpressBaseAddress such that describing the\r
- // [PcdPciExpressBaseAddress, 4GB) range require a very small number of\r
- // variable MTRRs (preferably 1 or 2).\r
- //\r
+ LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);\r
ASSERT (PcdGet64 (PcdPciExpressBaseAddress) <= MAX_UINT32);\r
- PlatformInfoHob->Uc32Base = (UINT32)PcdGet64 (PcdPciExpressBaseAddress);\r
+ ASSERT (PcdGet64 (PcdPciExpressBaseAddress) >= LowerMemorySize);\r
+\r
+ if (LowerMemorySize <= BASE_2GB) {\r
+ // Newer qemu with gigabyte aligned memory,\r
+ // 32-bit pci mmio window is 2G -> 4G then.\r
+ PlatformInfoHob->Uc32Base = BASE_2GB;\r
+ } else {\r
+ //\r
+ // On q35, the 32-bit area that we'll mark as UC, through variable MTRRs,\r
+ // starts at PcdPciExpressBaseAddress. The platform DSC is responsible for\r
+ // setting PcdPciExpressBaseAddress such that describing the\r
+ // [PcdPciExpressBaseAddress, 4GB) range require a very small number of\r
+ // variable MTRRs (preferably 1 or 2).\r
+ //\r
+ PlatformInfoHob->Uc32Base = (UINT32)PcdGet64 (PcdPciExpressBaseAddress);\r
+ }\r
+\r
return;\r
}\r
\r