VirtualBox

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


Ignore:
Timestamp:
Nov 13, 2019 11:37:39 AM (5 years ago)
Author:
vboxsync
Message:

EFI/Firmware/CpuDxe: Work around earlier macOS versions (Tiger up until at least Snow Leopard) overwriting the GDT because it the memory range does not have the Runtime flag set

File:
1 edited

Legend:

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

    r80721 r81821  
    128128  IA32_DESCRIPTOR gdtPtr;
    129129
     130#ifndef VBOX
    130131  //
    131132  // Allocate Runtime Data for the GDT
    132133  //
    133   gdt = AllocateReservedPool (sizeof (GdtTemplate) + 8); /* VBox: Required for OS X (tested with 32-bit 10.6), original uses AllocateRuntimePool here. */
     134  gdt = AllocateRuntimePool (sizeof (GdtTemplate) + 8);
    134135  ASSERT (gdt != NULL);
    135136  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
    136157
    137158  //
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