Acidanthera UEFI Development Kit based on EDK II edk2-stable202311
Go to file
Laszlo Ersek d41fd8e839 OvmfPkg: restore temporary SEC/PEI RAM size to 64KB
(1) In the PEI phase, the PCD database is maintained in a GUID HOB. In
    OVMF, we load the PCD PEIM before any other PEIMs (using APRIORI PEI),
    so that all other PEIMs can use dynamic PCDs. Consequently,

    - the PCD GUID HOB is initially allocated from the temporary SEC/PEI
      heap,

    - whenever we introduce a dynamic PCD to a PEIM built into OVMF such
      that the PCD is new to OVMF's whole PEI phase, the PCD GUID HOB (and
      its temporary heap footprint) grow.

    I've noticed that, if we add just one more dynamic PCD to the PEI
    phase, then in the X64 build,

    - we get very close to the half of the temporary heap (i.e., 8192
      bytes),

    - obscure PEI phase hangs or DXE core initialization failures
      (ASSERTs) occur. The symptoms vary between the FD_SIZE_2MB and
      FD_SIZE_4MB builds of X64 OVMF.

(2) I've found that commit

      2bbd7e2fbd ("UefiCpuPkg/MtrrLib: Update algorithm to calculate
                    optimal settings", 2017-09-27)

    introduced a large (16KB) stack allocation:

> The patch changes existing MtrrSetMemoryAttributeInMtrrSettings() and
> MtrrSetMemoryAttribute() to use the 4-page stack buffer for calculation.
> ...
> +#define SCRATCH_BUFFER_SIZE           (4 * SIZE_4KB)
> ...
> @@ -2207,17 +2462,66 @@ MtrrSetMemoryAttributeInMtrrSettings (
> ...
> +  UINT8                      Scratch[SCRATCH_BUFFER_SIZE];

(3) OVMF's temp SEC/PEI RAM size has been 32KB ever since commit

      7cb6b0e068 ("OvmfPkg: Move SEC/PEI Temporary RAM from 0x70000 to
                    0x810000", 2014-01-21)

    Of that, the upper 16KB half is stack (growing down), and the lower
    16KB half is heap.

    Thus, OvmfPkg/PlatformPei's calls to "UefiCpuPkg/Library/MtrrLib", in
    QemuInitializeRam(), cause the Scratch array to overflow the entire
    stack (heading towards lower addresses), and corrupt the heap below
    the stack. It turns out that the total stack demand is about 24KB, so
    the overflow is able to corrupt the upper 8KB of the heap. If that
    part of the heap is actually used (for example because we grow the PCD
    GUID HOB sufficiently), mayhem ensues.

(4) Right after commit 7cb6b0e068 (see above), there would be no room
    left above the 32KB temp SEC/PEI RAM. However, given more recent
    commits

      45d8708151 ("OvmfPkg/PlatformPei: rebase and resize the permanent
                    PEI memory for S3", 2016-07-13)

      6b04cca4d6 ("OvmfPkg: remove PcdS3AcpiReservedMemoryBase,
                    PcdS3AcpiReservedMemorySize", 2016-07-12)

    we can now restore the temp SEC/PEI RAM size to the original
    (pre-7cb6b0e06809) 64KB. This will allow for a 32KB temp SEC/PEI
    stack, which accommodates the ~24KB demand mentioned in (3).

    (Prior patches in this series will let us monitor the stack usage in
    the future.)

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=747
Ref: http://mid.mail-archive.com/a49cc089-12ae-a887-a4d6-4dc509233a74@redhat.com
Ref: http://mid.mail-archive.com/03e369bb-77c4-0134-258f-bdae62cbc8c5@redhat.com
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2017-11-17 18:12:18 +01:00
AppPkg AppPkg/WebServer: Fix build failure. 2017-09-14 08:55:09 +08:00
ArmPkg ArmPkg: move RVCT PLATFORM_FLAGS override into ArmHvcLib/ArmSmcLib 2017-11-16 16:02:23 +00:00
ArmPlatformPkg ArmPlatformPkg: reorganize PL011 code 2017-11-17 10:01:29 +00:00
ArmVirtPkg ArmVirtPkg: switch to new PL011UartLib implementation 2017-11-17 10:02:36 +00:00
BaseTools BaseTools: Fix the bug to re-build uni file for Library 2017-11-14 16:23:07 +08:00
BeagleBoardPkg BeagleBoardPkg: switch to generic non-coherent DmaLib 2017-08-30 14:13:58 +01:00
Conf EDK II: Add .gitignore 2014-10-14 16:08:15 +00:00
CorebootModulePkg CorebootModulePkg/CbSupportDxe: Remove duplicated IO Space addition 2017-11-16 10:52:00 +08:00
CorebootPayloadPkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
CryptoPkg CryptoPkg/BaseCryptLib: Add C-structure to matching certificate stack 2017-11-07 22:06:48 +08:00
DuetPkg DuetPkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined 2017-08-11 08:44:54 +08:00
EdkCompatibilityPkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
EdkShellBinPkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
EdkShellPkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
EmbeddedPkg EmbeddedPkg: add mx66u1g45g nor flash info 2017-11-16 16:28:55 +00:00
EmulatorPkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
FatBinPkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
FatPkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
IntelFrameworkModulePkg IntelFrameworkModulePkg: Fix MSFT C4255 warning 2017-11-14 18:18:36 +08:00
IntelFrameworkPkg IntelFrameworkPkg PeiHobLibFramework: Implement BuildFv3Hob 2017-10-10 20:54:37 +08:00
IntelFsp2Pkg IntelFsp2Pkg-Tools: GenCfgOpt.py shouldn't include specific UPD name 2017-11-08 20:44:29 +08:00
IntelFsp2WrapperPkg IntelFsp2WrapperPkg: Update Protocol/Guid usage in INF files 2017-10-10 18:10:24 +08:00
IntelFspPkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
IntelFspWrapperPkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
IntelSiliconPkg IntelSiliconPkg IntelVTdDxe: Use ACPI table event to get DMAR table 2017-11-06 10:08:48 +08:00
MdeModulePkg MdeModulePkg/SdBlockIoPei: Support IoMmu 2017-11-17 11:38:46 +08:00
MdePkg MdePkg: Fix MSFT C4255 warning 2017-11-14 18:18:48 +08:00
NetworkPkg NetworkPkg: Fix incorrect SizeofHeaders returned from HttpTcpReceiveHeader(). 2017-11-16 14:08:54 +08:00
Nt32Pkg Nt32Pkg: Update SecMain consumes PCD to get the init value in temp stack 2017-11-03 17:45:51 +08:00
Omap35xxPkg Omap35xxPkg: switch to EmbeddedPkg's NonCoherentDmaLib 2017-08-30 14:13:47 +01:00
OptionRomPkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
OvmfPkg OvmfPkg: restore temporary SEC/PEI RAM size to 64KB 2017-11-17 18:12:18 +01:00
PcAtChipsetPkg PcAtChipsetPkg/IsaAcpiDxe: Restore PCI attributes correctly 2017-11-08 11:42:45 +08:00
PerformancePkg PerformancePkg DP: Init CustomCumulativeData.MinDur 2017-08-14 16:55:44 +08:00
QuarkPlatformPkg QuarkPlatformPkg/PlatformBootManagerLib: Update boot mode handling 2017-11-14 16:47:35 -08:00
QuarkSocPkg QuarkSocPkg/QNCSmmDispatcher: Fix use after free issue #2 2017-08-16 19:42:17 -07:00
SecurityPkg SecurityPkg/AuthVariableLib: Use EFI_CERT_DATA to parse certificate 2017-11-07 22:06:54 +08:00
ShellBinPkg ShellBinPkg: AARCH64/ARM Shell binary update. 2017-08-31 15:41:59 +01:00
ShellPkg ShellPkg: Add error message if failed to place receive token in ping command. 2017-11-16 14:07:31 +08:00
SignedCapsulePkg SignedCapsulePkg: Update Guid usage in INF file to match source code logic 2017-10-10 18:10:21 +08:00
SourceLevelDebugPkg SourceLevelDebugPkg: Update SmmDebugAgentLib to restore APIC timer 2017-10-16 11:23:16 +08:00
StdLib StdLib/BsdSocketLib: Remove unused variables 2017-11-13 07:39:06 -08:00
StdLibPrivateInternalFiles edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
UefiCpuPkg UefiCpuPkg/ResetVector/Vtf0: document segment register setup 2017-11-17 18:11:58 +01:00
UnixPkg
Vlv2DeviceRefCodePkg edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
Vlv2TbltDevicePkg Vlv2TbltDevicePkg: Remove reference deprecated macro. 2017-08-07 15:28:13 +08:00
.gitignore edk2: Add .DS_Store to .gitignore for macOS 2017-05-19 15:14:34 -07:00
BuildNotes2.txt BaseTools: Updated BuildNotes URLs 2016-03-25 09:46:44 +08:00
Contributions.txt edk2: Fix typo in Contributions.txt 2017-08-16 17:50:44 +08:00
Edk2Setup.bat Edk2Setup.bat: Fix build errors from VS tools PREFIX ENV missing 2016-11-05 09:10:58 +08:00
License.txt edk2: Move License.txt file to root 2017-08-03 11:02:17 -07:00
Maintainers.txt Add one maintainer to CorebootModulePkg and CorebootPayloadPkg 2017-11-02 10:17:54 +08:00
Readme.md edk2: Add Readme.md to root of edk2 repository 2017-08-03 11:02:25 -07:00
edksetup.bat BaseTools: suppress usage instructions with rebuild options 2017-07-04 10:16:13 +08:00
edksetup.sh BaseTools/edksetup.sh: fix invalid test for current working directory 2017-08-10 12:54:58 +08:00

Readme.md

EDK II Project

A modern, feature-rich, cross-platform firmware development environment for the UEFI and PI specifications from www.uefi.org.

Contributions to the EDK II open source project are covered by the TianoCore Contribution Agreement 1.1

The majority of the content in the EDK II open source project uses a BSD 2-Clause License. The EDK II open source project contains the following components that are covered by additional licenses:

The EDK II Project is composed of packages. The maintainers for each package are listed in Maintainers.txt.

Resources