]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Do not expose MMIO in SMM build
authorBrijesh Singh <brijesh.singh@amd.com>
Fri, 6 Jul 2018 15:00:41 +0000 (10:00 -0500)
committerLaszlo Ersek <lersek@redhat.com>
Fri, 6 Jul 2018 18:08:21 +0000 (20:08 +0200)
In the SMM build, only an SMM driver is using the address range hence we
do not need to expose the flash MMIO range in EFI runtime mapping.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Julien Grall <julien.grall@linaro.org>
Cc: Justen Jordan L <jordan.l.justen@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.c
OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockService.h
OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceDxe.c
OvmfPkg/QemuFlashFvbServicesRuntimeDxe/FwBlockServiceSmm.c

index b3f428bb4284c9f4c7ea4cfe4fc3687ae8abc1e3..eec8b1b1ae9dec7760a5fc2759056f569a7698dd 100644 (file)
@@ -829,56 +829,6 @@ ValidateFvHeader (
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
-STATIC\r
-EFI_STATUS\r
-MarkIoMemoryRangeForRuntimeAccess (\r
-  EFI_PHYSICAL_ADDRESS                BaseAddress,\r
-  UINTN                               Length\r
-  )\r
-{\r
-  EFI_STATUS                          Status;\r
-  EFI_GCD_MEMORY_SPACE_DESCRIPTOR     GcdDescriptor;\r
-\r
-  //\r
-  // Mark flash region as runtime memory\r
-  //\r
-  Status = gDS->RemoveMemorySpace (\r
-                  BaseAddress,\r
-                  Length\r
-                  );\r
-\r
-  Status = gDS->AddMemorySpace (\r
-                  EfiGcdMemoryTypeMemoryMappedIo,\r
-                  BaseAddress,\r
-                  Length,\r
-                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gDS->AllocateMemorySpace (\r
-                  EfiGcdAllocateAddress,\r
-                  EfiGcdMemoryTypeMemoryMappedIo,\r
-                  0,\r
-                  Length,\r
-                  &BaseAddress,\r
-                  gImageHandle,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  Status = gDS->SetMemorySpaceAttributes (\r
-                  BaseAddress,\r
-                  Length,\r
-                  GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  return Status;\r
-}\r
-\r
 STATIC\r
 EFI_STATUS\r
 InitializeVariableFvHeader (\r
 STATIC\r
 EFI_STATUS\r
 InitializeVariableFvHeader (\r
index 1f9287b0876971cb7c2b9be620a128ee1099de6f..178f578d49f0744582484c3dfad8edd2ea2e1611 100644 (file)
@@ -189,4 +189,11 @@ VOID
 InstallVirtualAddressChangeHandler (\r
   VOID\r
   );\r
 InstallVirtualAddressChangeHandler (\r
   VOID\r
   );\r
+\r
+EFI_STATUS\r
+MarkIoMemoryRangeForRuntimeAccess (\r
+  IN EFI_PHYSICAL_ADDRESS   BaseAddress,\r
+  IN UINTN                  Length\r
+  );\r
+\r
 #endif\r
 #endif\r
index 63b308658e36b4ef91f1e098f01e504c965fead7..37deece363e6e586df290101653290fd09abc12b 100644 (file)
@@ -17,6 +17,7 @@
 #include <Guid/EventGroup.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/DevicePathLib.h>\r
 #include <Guid/EventGroup.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/DevicePathLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
@@ -155,3 +156,52 @@ InstallVirtualAddressChangeHandler (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 }\r
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 }\r
+\r
+EFI_STATUS\r
+MarkIoMemoryRangeForRuntimeAccess (\r
+  IN EFI_PHYSICAL_ADDRESS                BaseAddress,\r
+  IN UINTN                               Length\r
+  )\r
+{\r
+  EFI_STATUS                          Status;\r
+  EFI_GCD_MEMORY_SPACE_DESCRIPTOR     GcdDescriptor;\r
+\r
+  //\r
+  // Mark flash region as runtime memory\r
+  //\r
+  Status = gDS->RemoveMemorySpace (\r
+                  BaseAddress,\r
+                  Length\r
+                  );\r
+\r
+  Status = gDS->AddMemorySpace (\r
+                  EfiGcdMemoryTypeMemoryMappedIo,\r
+                  BaseAddress,\r
+                  Length,\r
+                  EFI_MEMORY_UC | EFI_MEMORY_RUNTIME\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gDS->AllocateMemorySpace (\r
+                  EfiGcdAllocateAddress,\r
+                  EfiGcdMemoryTypeMemoryMappedIo,\r
+                  0,\r
+                  Length,\r
+                  &BaseAddress,\r
+                  gImageHandle,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  Status = gDS->SetMemorySpaceAttributes (\r
+                  BaseAddress,\r
+                  Length,\r
+                  GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r
index e0617f2503a2ac1d3875580d6852bf2d0b37bb13..af08fa69d489a04f241e6db31bf447260ba9dc62 100644 (file)
@@ -67,3 +67,16 @@ InstallVirtualAddressChangeHandler (
   // Nothing.\r
   //\r
 }\r
   // Nothing.\r
   //\r
 }\r
+\r
+EFI_STATUS\r
+MarkIoMemoryRangeForRuntimeAccess (\r
+  IN EFI_PHYSICAL_ADDRESS                BaseAddress,\r
+  IN UINTN                               Length\r
+  )\r
+{\r
+  //\r
+  // Nothing\r
+  //\r
+\r
+  return EFI_SUCCESS;\r
+}\r