mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
OcAppleBootCompatLib: Update attributes after every allocation
This commit is contained in:
parent
98f17b671d
commit
ffb49563cd
@ -275,6 +275,8 @@ OcAllocatePages (
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
BOOT_COMPAT_CONTEXT *BootCompat;
|
||||
EFI_PHYSICAL_ADDRESS Address;
|
||||
UINTN Pages;
|
||||
BOOLEAN IsPerfAlloc;
|
||||
|
||||
BootCompat = GetBootCompatContext ();
|
||||
@ -299,30 +301,40 @@ OcAllocatePages (
|
||||
Memory
|
||||
);
|
||||
|
||||
if (!EFI_ERROR (Status) && BootCompat->ServiceState.AppleBootNestedCount > 0) {
|
||||
if (IsPerfAlloc) {
|
||||
//
|
||||
// Called from boot.efi.
|
||||
// New perf data, it can be reallocated multiple times.
|
||||
//
|
||||
OcAppleDebugLogPerfAllocated ((VOID *)(UINTN) *Memory, EFI_PAGES_TO_SIZE (NumberOfPages));
|
||||
} else if (Type == AllocateAddress && MemoryType == EfiLoaderData) {
|
||||
//
|
||||
// Called from boot.efi.
|
||||
// Store minimally allocated address to find kernel image start.
|
||||
//
|
||||
if (BootCompat->ServiceState.MinAllocatedAddr == 0
|
||||
|| *Memory < BootCompat->ServiceState.MinAllocatedAddr) {
|
||||
BootCompat->ServiceState.MinAllocatedAddr = *Memory;
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (BootCompat->Settings.SyncRuntimePermissions && BootCompat->ServiceState.FwRuntime != NULL) {
|
||||
Status = BootCompat->ServiceState.FwRuntime->GetExecArea (&Address, &Pages);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
OcUpdateAttributes (Address, EfiRuntimeServicesCode, EFI_MEMORY_RO, EFI_MEMORY_XP);
|
||||
}
|
||||
}
|
||||
|
||||
if (BootCompat->ServiceState.AppleBootNestedCount > 0) {
|
||||
if (IsPerfAlloc) {
|
||||
//
|
||||
// Called from boot.efi.
|
||||
// New perf data, it can be reallocated multiple times.
|
||||
//
|
||||
OcAppleDebugLogPerfAllocated ((VOID *)(UINTN) *Memory, EFI_PAGES_TO_SIZE (NumberOfPages));
|
||||
} else if (Type == AllocateAddress && MemoryType == EfiLoaderData) {
|
||||
//
|
||||
// Called from boot.efi.
|
||||
// Store minimally allocated address to find kernel image start.
|
||||
//
|
||||
if (BootCompat->ServiceState.MinAllocatedAddr == 0
|
||||
|| *Memory < BootCompat->ServiceState.MinAllocatedAddr) {
|
||||
BootCompat->ServiceState.MinAllocatedAddr = *Memory;
|
||||
}
|
||||
} else if (BootCompat->ServiceState.AppleHibernateWake
|
||||
&& Type == AllocateAnyPages && MemoryType == EfiLoaderData
|
||||
&& BootCompat->ServiceState.HibernateImageAddress == 0) {
|
||||
//
|
||||
// Called from boot.efi during hibernate wake,
|
||||
// first such allocation is for hibernate image
|
||||
//
|
||||
BootCompat->ServiceState.HibernateImageAddress = *Memory;
|
||||
}
|
||||
} else if (BootCompat->ServiceState.AppleHibernateWake
|
||||
&& Type == AllocateAnyPages && MemoryType == EfiLoaderData
|
||||
&& BootCompat->ServiceState.HibernateImageAddress == 0) {
|
||||
//
|
||||
// Called from boot.efi during hibernate wake,
|
||||
// first such allocation is for hibernate image
|
||||
//
|
||||
BootCompat->ServiceState.HibernateImageAddress = *Memory;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user