VirtualBox

Changeset 82104 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Nov 22, 2019 5:55:02 PM (5 years ago)
Author:
vboxsync
Message:

EFI/Firmware: Work around a bug in Apples boot.efi present in at least Tiger, Leopard and Snow Leopard showing only with our updated EFI firmware

File:
1 edited

Legend:

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

    r80934 r82104  
    761761{
    762762  EFI_STATUS    Status;
     763#ifdef VBOX
     764  EFI_PHYSICAL_ADDRESS Memory;
     765#endif
    763766
    764767  DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n"));
     
    805808    InitializeXen ();
    806809  }
     810
     811#ifdef VBOX
     812  /*
     813   * This seemingly useless allocation is required to protect the memory against
     814   * a bug present in Apples boot.efi bootloader for OS X Tiger, Leopard and Snow Leopard
     815   * causing a triple fault before the kernel is started because the stack got trashed.
     816   *
     817   * Before handing control to the kernel it goes over the memory map acquired with gRT->GetMemoryMap()
     818   * and relocates all EfiRuntimeServicesData and EfiRuntimeServicesCode to another memory location.
     819   * Every entry not having the EfiRuntimeServicesData/EfiRuntimeServicesCode type gets removed and the
     820   * memory location is zeroed. However the size of the region is not taken from the memory descriptor
     821   * but calculated before by just using the last EfiRuntimeServices* regions size (which is the bug).
     822   *
     823   * In our case this is the variable store memory allocated in ReserveEmuVariableNvStore() which spans
     824   * 0x84 pages or 528KB which causes the stack to get trashed when boot.efi comes to the zero out the
     825   * EfiBootServicesData range covering the stack.
     826   * To prevent merging adjacent memory regions with the same properties in CoreGetMemoryMap() a
     827   * EfiRuntimeServicesCode region with exactly one page gets allocated as the first region here so it
     828   * ends up last in the memory map. This prevents boot.efi from zeroing too much memory.
     829   *
     830   * This worked with 6.0 and earlier firmware because the variable store was much smaller (only 128KB)
     831   * which happened to work by accident.
     832   */
     833  PeiServicesAllocatePages (EfiRuntimeServicesCode, 1, &Memory);
     834#endif
    807835
    808836  if (mBootMode != BOOT_ON_S3_RESUME) {
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