Changeset 82104 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Nov 22, 2019 5:55:02 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/PlatformPei/Platform.c
r80934 r82104 761 761 { 762 762 EFI_STATUS Status; 763 #ifdef VBOX 764 EFI_PHYSICAL_ADDRESS Memory; 765 #endif 763 766 764 767 DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n")); … … 805 808 InitializeXen (); 806 809 } 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 807 835 808 836 if (mBootMode != BOOT_ON_S3_RESUME) {
Note:
See TracChangeset
for help on using the changeset viewer.