OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Do not expose MMIO in SMM build
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>
This commit is contained in:
		
				
					committed by
					
						 Laszlo Ersek
						Laszlo Ersek
					
				
			
			
				
	
			
			
			
						parent
						
							966363d5a3
						
					
				
				
					commit
					3b3d016b7b
				
			| @@ -829,56 +829,6 @@ ValidateFvHeader ( | |||||||
|   return EFI_SUCCESS; |   return EFI_SUCCESS; | ||||||
| } | } | ||||||
|  |  | ||||||
| STATIC |  | ||||||
| EFI_STATUS |  | ||||||
| MarkIoMemoryRangeForRuntimeAccess ( |  | ||||||
|   EFI_PHYSICAL_ADDRESS                BaseAddress, |  | ||||||
|   UINTN                               Length |  | ||||||
|   ) |  | ||||||
| { |  | ||||||
|   EFI_STATUS                          Status; |  | ||||||
|   EFI_GCD_MEMORY_SPACE_DESCRIPTOR     GcdDescriptor; |  | ||||||
|  |  | ||||||
|   // |  | ||||||
|   // Mark flash region as runtime memory |  | ||||||
|   // |  | ||||||
|   Status = gDS->RemoveMemorySpace ( |  | ||||||
|                   BaseAddress, |  | ||||||
|                   Length |  | ||||||
|                   ); |  | ||||||
|  |  | ||||||
|   Status = gDS->AddMemorySpace ( |  | ||||||
|                   EfiGcdMemoryTypeMemoryMappedIo, |  | ||||||
|                   BaseAddress, |  | ||||||
|                   Length, |  | ||||||
|                   EFI_MEMORY_UC | EFI_MEMORY_RUNTIME |  | ||||||
|                   ); |  | ||||||
|   ASSERT_EFI_ERROR (Status); |  | ||||||
|  |  | ||||||
|   Status = gDS->AllocateMemorySpace ( |  | ||||||
|                   EfiGcdAllocateAddress, |  | ||||||
|                   EfiGcdMemoryTypeMemoryMappedIo, |  | ||||||
|                   0, |  | ||||||
|                   Length, |  | ||||||
|                   &BaseAddress, |  | ||||||
|                   gImageHandle, |  | ||||||
|                   NULL |  | ||||||
|                   ); |  | ||||||
|   ASSERT_EFI_ERROR (Status); |  | ||||||
|  |  | ||||||
|   Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor); |  | ||||||
|   ASSERT_EFI_ERROR (Status); |  | ||||||
|  |  | ||||||
|   Status = gDS->SetMemorySpaceAttributes ( |  | ||||||
|                   BaseAddress, |  | ||||||
|                   Length, |  | ||||||
|                   GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME |  | ||||||
|                   ); |  | ||||||
|   ASSERT_EFI_ERROR (Status); |  | ||||||
|  |  | ||||||
|   return Status; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| STATIC | STATIC | ||||||
| EFI_STATUS | EFI_STATUS | ||||||
| InitializeVariableFvHeader ( | InitializeVariableFvHeader ( | ||||||
|   | |||||||
| @@ -189,4 +189,11 @@ VOID | |||||||
| InstallVirtualAddressChangeHandler ( | InstallVirtualAddressChangeHandler ( | ||||||
|   VOID |   VOID | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
|  | EFI_STATUS | ||||||
|  | MarkIoMemoryRangeForRuntimeAccess ( | ||||||
|  |   IN EFI_PHYSICAL_ADDRESS   BaseAddress, | ||||||
|  |   IN UINTN                  Length | ||||||
|  |   ); | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -17,6 +17,7 @@ | |||||||
| #include <Guid/EventGroup.h> | #include <Guid/EventGroup.h> | ||||||
| #include <Library/DebugLib.h> | #include <Library/DebugLib.h> | ||||||
| #include <Library/DevicePathLib.h> | #include <Library/DevicePathLib.h> | ||||||
|  | #include <Library/DxeServicesTableLib.h> | ||||||
| #include <Library/PcdLib.h> | #include <Library/PcdLib.h> | ||||||
| #include <Library/UefiBootServicesTableLib.h> | #include <Library/UefiBootServicesTableLib.h> | ||||||
| #include <Library/UefiRuntimeLib.h> | #include <Library/UefiRuntimeLib.h> | ||||||
| @@ -155,3 +156,52 @@ InstallVirtualAddressChangeHandler ( | |||||||
|                   ); |                   ); | ||||||
|   ASSERT_EFI_ERROR (Status); |   ASSERT_EFI_ERROR (Status); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | EFI_STATUS | ||||||
|  | MarkIoMemoryRangeForRuntimeAccess ( | ||||||
|  |   IN EFI_PHYSICAL_ADDRESS                BaseAddress, | ||||||
|  |   IN UINTN                               Length | ||||||
|  |   ) | ||||||
|  | { | ||||||
|  |   EFI_STATUS                          Status; | ||||||
|  |   EFI_GCD_MEMORY_SPACE_DESCRIPTOR     GcdDescriptor; | ||||||
|  |  | ||||||
|  |   // | ||||||
|  |   // Mark flash region as runtime memory | ||||||
|  |   // | ||||||
|  |   Status = gDS->RemoveMemorySpace ( | ||||||
|  |                   BaseAddress, | ||||||
|  |                   Length | ||||||
|  |                   ); | ||||||
|  |  | ||||||
|  |   Status = gDS->AddMemorySpace ( | ||||||
|  |                   EfiGcdMemoryTypeMemoryMappedIo, | ||||||
|  |                   BaseAddress, | ||||||
|  |                   Length, | ||||||
|  |                   EFI_MEMORY_UC | EFI_MEMORY_RUNTIME | ||||||
|  |                   ); | ||||||
|  |   ASSERT_EFI_ERROR (Status); | ||||||
|  |  | ||||||
|  |   Status = gDS->AllocateMemorySpace ( | ||||||
|  |                   EfiGcdAllocateAddress, | ||||||
|  |                   EfiGcdMemoryTypeMemoryMappedIo, | ||||||
|  |                   0, | ||||||
|  |                   Length, | ||||||
|  |                   &BaseAddress, | ||||||
|  |                   gImageHandle, | ||||||
|  |                   NULL | ||||||
|  |                   ); | ||||||
|  |   ASSERT_EFI_ERROR (Status); | ||||||
|  |  | ||||||
|  |   Status = gDS->GetMemorySpaceDescriptor (BaseAddress, &GcdDescriptor); | ||||||
|  |   ASSERT_EFI_ERROR (Status); | ||||||
|  |  | ||||||
|  |   Status = gDS->SetMemorySpaceAttributes ( | ||||||
|  |                   BaseAddress, | ||||||
|  |                   Length, | ||||||
|  |                   GcdDescriptor.Attributes | EFI_MEMORY_RUNTIME | ||||||
|  |                   ); | ||||||
|  |   ASSERT_EFI_ERROR (Status); | ||||||
|  |  | ||||||
|  |   return Status; | ||||||
|  | } | ||||||
|   | |||||||
| @@ -67,3 +67,16 @@ InstallVirtualAddressChangeHandler ( | |||||||
|   // Nothing. |   // Nothing. | ||||||
|   // |   // | ||||||
| } | } | ||||||
|  |  | ||||||
|  | EFI_STATUS | ||||||
|  | MarkIoMemoryRangeForRuntimeAccess ( | ||||||
|  |   IN EFI_PHYSICAL_ADDRESS                BaseAddress, | ||||||
|  |   IN UINTN                               Length | ||||||
|  |   ) | ||||||
|  | { | ||||||
|  |   // | ||||||
|  |   // Nothing | ||||||
|  |   // | ||||||
|  |  | ||||||
|  |   return EFI_SUCCESS; | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user