VirtualBox

Changeset 82107 in vbox


Ignore:
Timestamp:
Nov 22, 2019 6:32:44 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134916
Message:

EFI/Firmware/CpuGdt.c: Revert previous patch and add explanation why AllocateReservedPool() should be used instead of AllocateRuntimePool()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/Firmware/UefiCpuPkg/CpuDxe/CpuGdt.c

    r81821 r82107  
    128128  IA32_DESCRIPTOR gdtPtr;
    129129
    130 #ifndef VBOX
    131130  //
    132131  // Allocate Runtime Data for the GDT
    133132  //
     133#ifndef VBOX
    134134  gdt = AllocateRuntimePool (sizeof (GdtTemplate) + 8);
     135#else
     136  /*
     137   * Apples bootloader boot.efi for at least OS X Tiger, Leopard and Snow Leopard
     138   * relocates runtime regions which doesn't make sense for the GDT as the GDTR is not
     139   * updated and would point to invalid memory. Allocate the memory as reserved to hopefully
     140   * keep the bootloaders hands off of it, see also OvmfPkg/PlatformPei/Platform.c
     141   * (search for PeiServicesAllocatePages()) for a more detailed explanation of a
     142   * related bug in Apples bootloader.
     143   */
     144  gdt = AllocateReservedPool (sizeof (GdtTemplate) + 8);
     145#endif
    135146  ASSERT (gdt != NULL);
    136147  gdt = ALIGN_POINTER (gdt, 8);
    137 #else
    138    /*
    139     * With previous versions of the EDK2 changing AllocateRuntimePool to AllocateReservedPool
    140     * was enough to get earlier mac OS versions (Tiger up until at least Snow Leopard) not overwriting the GDT
    141     * when freeing not required EFI memory ranges anymore.
    142     * With the current version however the memory map (memmap command in EFI shell) returned to boot.efi
    143     * will have the Runtime flag always cleared no matter what. boot.efi overwrites the memory and
    144     * the VM triple faults because of the invalid GDT.
    145     * Using the AllocatePages() method with EfiRuntimeServicesData works around that and the GDT memory
    146     * has the proper Runtime flag set so boot.efi will leave it alone.
    147     */
    148   EFI_STATUS Status;
    149   EFI_PHYSICAL_ADDRESS PhysicalAddress = SIZE_4GB - 1;
    150   Status = gBS->AllocatePages(AllocateMaxAddress,
    151                               EfiRuntimeServicesData,
    152                               1,
    153                               &PhysicalAddress);
    154   ASSERT(!EFI_ERROR(Status));
    155   gdt = ALIGN_POINTER ((void *)(UINTN)PhysicalAddress, 8);
    156 #endif
    157148
    158149  //
Note: See TracChangeset for help on using the changeset viewer.

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