UINTN Pages;\r
EFI_PHYSICAL_ADDRESS FfsBuffer;\r
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;\r
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc;\r
\r
Status = gBS->LocateProtocol (&gEfiDxeSmmReadyToLockProtocolGuid, NULL, &Interface);\r
if (EFI_ERROR (Status)) {\r
&FfsBuffer\r
);\r
ASSERT_EFI_ERROR (Status);\r
+\r
+ //\r
+ // Make sure that the buffer can be used to store code.\r
+ //\r
+ Status = gDS->GetMemorySpaceDescriptor (FfsBuffer, &MemDesc);\r
+ if (!EFI_ERROR (Status) && (MemDesc.Attributes & EFI_MEMORY_XP) != 0) {\r
+ gDS->SetMemorySpaceAttributes (\r
+ FfsBuffer,\r
+ EFI_PAGES_TO_SIZE (Pages),\r
+ MemDesc.Attributes & (~EFI_MEMORY_XP)\r
+ );\r
+ }\r
+\r
ImageContext.ImageAddress = (PHYSICAL_ADDRESS)(UINTN)FfsBuffer;\r
//\r
// Align buffer on section boundary\r
#include <Library/LockBoxLib.h>\r
#include <Library/CpuExceptionHandlerLib.h>\r
#include <Library/DevicePathLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
\r
#include <Guid/AcpiS3Context.h>\r
#include <Guid/BootScriptExecutorVariable.h>\r