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 b3f428b..eec8b1b 100644 (file)
@@ -829,56 +829,6 @@ ValidateFvHeader (
   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
index 1f9287b..178f578 100644 (file)
@@ -189,4 +189,11 @@ VOID
 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
index 63b3086..37deece 100644 (file)
@@ -17,6 +17,7 @@
 #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
@@ -155,3 +156,52 @@ InstallVirtualAddressChangeHandler (
                   );\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 e0617f2..af08fa6 100644 (file)
@@ -67,3 +67,16 @@ InstallVirtualAddressChangeHandler (
   // 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