OcAppleBootCompatLib: Reduce attribute update frequency to RT memory
STATIC
VOID
FixRuntimeAttributes (
- IN BOOT_COMPAT_CONTEXT *BootCompat
+ IN BOOT_COMPAT_CONTEXT *BootCompat,
+ IN UINT32 Type
)
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS Address;
UINTN Pages;
+ if (Type != EfiRuntimeServicesCode && Type != EfiRuntimeServicesData) {
+ return;
+ }
+
if (BootCompat->Settings.SyncRuntimePermissions && BootCompat->ServiceState.FwRuntime != NULL) {
Status = BootCompat->ServiceState.FwRuntime->GetExecArea (&Address, &Pages);
@@ -324,7 +329,7 @@ OcAllocatePages (
);
if (!EFI_ERROR (Status)) {
- FixRuntimeAttributes (BootCompat);
+ FixRuntimeAttributes (BootCompat, MemoryType);
if (BootCompat->ServiceState.AppleBootNestedCount > 0) {
if (IsPerfAlloc) {
@@ -380,7 +385,7 @@ OcFreePages (
);
if (!EFI_ERROR (Status)) {
- FixRuntimeAttributes (BootCompat);
+ FixRuntimeAttributes (BootCompat, EfiRuntimeServicesData);
}
return Status;
@@ -521,7 +526,7 @@ OcAllocatePool (
);
if (!EFI_ERROR (Status)) {
- FixRuntimeAttributes (BootCompat);
+ FixRuntimeAttributes (BootCompat, PoolType);
}
return Status;
@@ -548,7 +553,7 @@ OcFreePool (
);
if (!EFI_ERROR (Status)) {
- FixRuntimeAttributes (BootCompat);
+ FixRuntimeAttributes (BootCompat, EfiRuntimeServicesData);
}
return Status;
@@ -588,7 +593,7 @@ OcStartImage (
gBS->CalculateCrc32 (gBS, gBS->Hdr.HeaderSize, &gBS->Hdr.CRC32);
}
- FixRuntimeAttributes (BootCompat);
+ FixRuntimeAttributes (BootCompat, EfiRuntimeServicesData);
//
// Clear monitoring vars
@@ -740,7 +745,7 @@ OcExitBootServices (
}
}
- FixRuntimeAttributes (BootCompat);
+ FixRuntimeAttributes (BootCompat, EfiRuntimeServicesData);
//
// For non-macOS operating systems return directly.
