]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/ScriptExecute.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / Acpi / BootScriptExecutorDxe / ScriptExecute.c
index 4545d6e5810cd38889dfd6a3fb090e68d432093f..e76abb7b7b1619e8d99b6b01edbd06c15f7b53db 100644 (file)
@@ -4,7 +4,7 @@
   This driver is dispatched by Dxe core and the driver will reload itself to ACPI reserved memory\r
   in the entry point. The functionality is to interpret and restore the S3 boot script\r
 \r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
 \r
 This program and the accompanying materials\r
@@ -72,12 +72,12 @@ S3BootScriptExecutorEntryFunction (
   // for that parameter.\r
   //\r
   Status = S3BootScriptExecute ();\r
-  \r
+\r
   //\r
   // If invalid script table or opcode in S3 boot script table.\r
   //\r
   ASSERT_EFI_ERROR (Status);\r
-  \r
+\r
   if (EFI_ERROR (Status)) {\r
     CpuDeadLoop ();\r
     return Status;\r
@@ -95,7 +95,7 @@ S3BootScriptExecutorEntryFunction (
   //\r
   if (PeiS3ResumeState != 0) {\r
     //\r
-    // Need report status back to S3ResumePeim. \r
+    // Need report status back to S3ResumePeim.\r
     // If boot script execution is failed, S3ResumePeim wil report the error status code.\r
     //\r
     PeiS3ResumeState->ReturnStatus = (UINT64)(UINTN)Status;\r
@@ -145,7 +145,7 @@ S3BootScriptExecutorEntryFunction (
     CpuDeadLoop();\r
     return EFI_UNSUPPORTED;\r
   }\r
-  \r
+\r
   //\r
   // S3ResumePeim does not provide a way to jump back to itself, so resume to OS here directly\r
   //\r
@@ -254,9 +254,9 @@ RegisterMemoryProfileImage (
 /**\r
   This is the Event notification function to reload BootScriptExecutor image\r
   to RESERVED mem and save it to LockBox.\r
-  \r
+\r
   @param    Event   Pointer to this event\r
-  @param    Context Event handler private data \r
+  @param    Context Event handler private data\r
  **/\r
 VOID\r
 EFIAPI\r
@@ -273,6 +273,7 @@ ReadyToLockEventNotify (
   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
@@ -322,6 +323,19 @@ ReadyToLockEventNotify (
                   &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