VirtualBox

Changeset 82249 in vbox for trunk/src/VBox/Devices/EFI


Ignore:
Timestamp:
Nov 27, 2019 6:18:11 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
135067
Message:

EFI/Firmware: Relocate the DXE FV volume to the top of the RAM once the memory is initialized to not interfer with older OS X bootloaders which try to allocate memory in that area

Location:
trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/Fv.c

    r80721 r82249  
    1414#include <Library/PcdLib.h>
    1515
     16#include <Library/BaseMemoryLib.h>
    1617
    1718/**
     
    2829{
    2930  BOOLEAN SecureS3Needed;
     31#ifdef VBOX
     32  EFI_PHYSICAL_ADDRESS PhysOvmfDxeMemFvBaseRelocated = 0;
     33  VOID *OvmfDxeMemFvBaseRelocated;
     34#endif
    3035
    3136  DEBUG ((EFI_D_INFO, "Platform PEI Firmware Volume Initialization\n"));
     37
     38#ifdef VBOX
     39  /*
     40   * Relocate the DXE firmware to the top of the RAM so it doesn't interfer with older OS X bootloaders
     41   * trying to allocate memory in the area where MEMFD is currently residing.
     42   */
     43  PeiServicesAllocatePages (EfiRuntimeServicesCode,
     44                            EFI_SIZE_TO_PAGES(PcdGet32 (PcdOvmfDxeMemFvSize)),
     45                            &PhysOvmfDxeMemFvBaseRelocated);
     46
     47  OvmfDxeMemFvBaseRelocated = (VOID *)(UINTN)PhysOvmfDxeMemFvBaseRelocated;
     48  CopyMem (OvmfDxeMemFvBaseRelocated, (VOID *)(UINTN)PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
     49
     50  //
     51  // Let DXE know about the DXE FV
     52  //
     53  BuildFvHob (PhysOvmfDxeMemFvBaseRelocated, PcdGet32 (PcdOvmfDxeMemFvSize));
     54
     55  SecureS3Needed = mS3Supported && FeaturePcdGet (PcdSmmSmramRequire);
     56
     57  //
     58  // Create a memory allocation HOB for the DXE FV.
     59  //
     60  // If "secure" S3 is needed, then SEC will decompress both PEI and DXE
     61  // firmware volumes at S3 resume too, hence we need to keep away the OS from
     62  // DXEFV as well. Otherwise we only need to keep away DXE itself from the
     63  // DXEFV area.
     64  //
     65  BuildMemoryAllocationHob (
     66    PhysOvmfDxeMemFvBaseRelocated,
     67    PcdGet32 (PcdOvmfDxeMemFvSize),
     68    SecureS3Needed ? EfiACPIMemoryNVS : EfiBootServicesData
     69    );
     70
     71  //
     72  // Let PEI know about the DXE FV so it can find the DXE Core
     73  //
     74  PeiServicesInstallFvInfoPpi (
     75    NULL,
     76    (VOID *)(UINTN)OvmfDxeMemFvBaseRelocated,
     77    PcdGet32 (PcdOvmfDxeMemFvSize),
     78    NULL,
     79    NULL
     80    );
     81#else
    3282
    3383  //
     
    89139    NULL
    90140    );
     141#endif
    91142
    92143  return EFI_SUCCESS;
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/MemDetect.c

    r80934 r82249  
    882882
    883883  if (mBootMode != BOOT_ON_S3_RESUME) {
     884#ifndef VBOX
     885    /*
     886     * This is currently no required and interferes with older OS X bootloaders trying to
     887     * allocate memory in that area. Needs to be revisited once we need this.
     888     */
    884889    if (!FeaturePcdGet (PcdSmmSmramRequire)) {
    885890      //
     
    903908        );
    904909    }
     910#endif
    905911
    906912    if (FeaturePcdGet (PcdSmmSmramRequire)) {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette