audk/OvmfPkg/PlatformPei
Laszlo Ersek b09c1c6f25 OvmfPkg: PlatformPei: account for TSEG size with PcdSmmSmramRequire set
PlatformPei calls GetSystemMemorySizeBelow4gb() in three locations:

- PublishPeiMemory(): on normal boot, the permanent PEI RAM is installed
  so that it ends with the RAM below 4GB,

- QemuInitializeRam(): on normal boot, memory resource descriptor HOBs are
  created for the RAM below 4GB; plus MTRR attributes are set
  (independently of S3 vs. normal boot)

- MemMapInitialization(): an MMIO resource descriptor HOB is created for
  PCI resource allocation, on normal boot, starting at max(RAM below 4GB,
  2GB).

The first two of these is adjusted for the configured TSEG size, if
PcdSmmSmramRequire is set:

- In PublishPeiMemory(), the permanent PEI RAM is kept under TSEG.

- In QemuInitializeRam(), we must keep the DXE out of TSEG.

  One idea would be to simply trim the [1MB .. LowerMemorySize] memory
  resource descriptor HOB, leaving a hole for TSEG in the memory space
  map.

  The SMM IPL will however want to massage the caching attributes of the
  SMRAM range that it loads the SMM core into, with
  gDS->SetMemorySpaceAttributes(), and that won't work on a hole. So,
  instead of trimming this range, split the TSEG area off, and report it
  as a cacheable reserved memory resource.

  Finally, since reserved memory can be allocated too, pre-allocate TSEG
  in InitializeRamRegions(), after QemuInitializeRam() returns. (Note that
  this step alone does not suffice without the resource descriptor HOB
  trickery: if we omit that, then the DXE IPL PEIM fails to load and start
  the DXE core.)

- In MemMapInitialization(), the start of the PCI MMIO range is not
  affected.

We choose the largest option (8MB) for the default TSEG size. Michael
Kinney pointed out that the SMBASE relocation in PiSmmCpuDxeSmm consumes
SMRAM proportionally to the number of CPUs. From the three options
available, he reported that 8MB was both necessary and sufficient for the
SMBASE relocation to succeed with 255 CPUs:

- http://thread.gmane.org/gmane.comp.bios.edk2.devel/3020/focus=3137
- http://thread.gmane.org/gmane.comp.bios.edk2.devel/3020/focus=3177

Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19039 6f19259b-4bc3-4df7-8a09-765794883524
2015-11-30 18:41:33 +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: decompress FVs on S3 resume if SMM_REQUIRE is set 2015-11-30 18:41:24 +00:00
MemDetect.c OvmfPkg: PlatformPei: account for TSEG size with PcdSmmSmramRequire set 2015-11-30 18:41:33 +00:00
Platform.c OvmfPkg: PlatformPei: allow caching in AddReservedMemoryBaseSizeHob() 2015-11-30 18:41:29 +00:00
Platform.h OvmfPkg: PlatformPei: allow caching in AddReservedMemoryBaseSizeHob() 2015-11-30 18:41:29 +00:00
PlatformPei.inf OvmfPkg: PlatformPei: account for TSEG size with PcdSmmSmramRequire set 2015-11-30 18:41:33 +00:00
Xen.c OvmfPkg: PlatformPei: allow caching in AddReservedMemoryBaseSizeHob() 2015-11-30 18:41:29 +00:00
Xen.h OvmfPkg: define EFI_XEN_OVMF_INFO 2013-12-08 01:35:52 +00:00