audk/OvmfPkg/PlatformPei
Laszlo Ersek 79d274b8b6 OvmfPkg: PlatformPei: invert MTRR setup in QemuInitializeRam()
At the moment we work with a UC default MTRR type, and set three memory
ranges to WB:
- [0, 640 KB),
- [1 MB, LowerMemorySize),
- [4 GB, 4 GB + UpperMemorySize).

Unfortunately, coverage for the third range can fail with a high
likelihood. If the alignment of the base (ie. 4 GB) and the alignment of
the size (UpperMemorySize) differ, then MtrrLib creates a series of
variable MTRR entries, with power-of-two sized MTRR masks. And, it's
really easy to run out of variable MTRR entries, dependent on the
alignment difference.

This is a problem because a Linux guest will loudly reject any high memory
that is not covered my MTRR.

So, let's follow the inverse pattern (loosely inspired by SeaBIOS):
- flip the MTRR default type to WB,
- set [0, 640 KB) to WB -- fixed MTRRs have precedence over the default
  type and variable MTRRs, so we can't avoid this,
- set [640 KB, 1 MB) to UC -- implemented with fixed MTRRs,
- set [LowerMemorySize, 4 GB) to UC -- should succeed with variable MTRRs
  more likely than the other scheme (due to less chaotic alignment
  differences).

Effects of this patch can be observed by setting DEBUG_CACHE (0x00200000)
in PcdDebugPrintErrorLevel.

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: 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@17722 6f19259b-4bc3-4df7-8a09-765794883524
2015-06-26 16:09:52 +00:00
..
Cmos.c Update the copyright notice format 2010-04-28 12:43:04 +00:00
Cmos.h Update the copyright notice format 2010-04-28 12:43:04 +00:00
Fv.c OvmfPkg/PlatformPei: Allocate PEI FV as ACPI NVS if S3 is supported 2014-03-04 08:02:59 +00:00
MemDetect.c OvmfPkg: PlatformPei: invert MTRR setup in QemuInitializeRam() 2015-06-26 16:09:52 +00:00
Platform.c OvmfPkg: PlatformPei: create the CPU HOB with dynamic memory space width 2015-06-26 16:09:43 +00:00
Platform.h OvmfPkg: PlatformPei: enable larger permanent PEI RAM 2015-06-26 16:09:39 +00:00
PlatformPei.inf OvmfPkg: PlatformPei: enable larger permanent PEI RAM 2015-06-26 16:09:39 +00:00
Xen.c OvmfPkg/PlatformPei: Set PcdPciDisableBusEnumeration in InitializeXen 2014-02-01 21:22:36 +00:00
Xen.h OvmfPkg: define EFI_XEN_OVMF_INFO 2013-12-08 01:35:52 +00:00