From bb8bd5dedb3b010b0466561413a9c7af464d863e Mon Sep 17 00:00:00 2001 From: vit9696 Date: Fri, 3 Apr 2020 14:43:09 +0300 Subject: [PATCH] OcAppleBootCompatLib: Update memory attributes before StartImage as well --- Library/OcAppleBootCompatLib/ServiceOverrides.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Library/OcAppleBootCompatLib/ServiceOverrides.c b/Library/OcAppleBootCompatLib/ServiceOverrides.c index fcc3bf6f..1225b20e 100644 --- a/Library/OcAppleBootCompatLib/ServiceOverrides.c +++ b/Library/OcAppleBootCompatLib/ServiceOverrides.c @@ -447,6 +447,8 @@ OcStartImage ( BOOT_COMPAT_CONTEXT *BootCompat; OC_FWRT_CONFIG Config; UINTN DataSize; + EFI_PHYSICAL_ADDRESS Address; + UINTN Pages; BootCompat = GetBootCompatContext (); AppleLoadedImage = OcGetAppleBootLoadedImage (ImageHandle); @@ -462,6 +464,14 @@ OcStartImage ( gBS->CalculateCrc32 (gBS, gBS->Hdr.HeaderSize, &gBS->Hdr.CRC32); } + 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); + } + } + // // Clear monitoring vars //