ArmPkg/CpuDxe: Simplify memory attributes protocol implementation
Now that ArmSetMemoryAttributes() permits a mask to be provided, we can simplify the implementation the UEFI memory attribute protocol substantially, and just pass on the requested mask to be set or cleared directly. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Oliver Smith-Denny <osde@linux.microsoft.com> Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
This commit is contained in:
		
				
					committed by
					
						![mergify[bot]](/avatar/e3df20cd7a67969c41a65f03bea54961?size=40) mergify[bot]
						mergify[bot]
					
				
			
			
				
	
			
			
			
						parent
						
							a21a994f55
						
					
				
				
					commit
					5542e528cd
				
			| @@ -183,8 +183,6 @@ SetMemoryAttributes ( | |||||||
|   IN  UINT64                         Attributes |   IN  UINT64                         Attributes | ||||||
|   ) |   ) | ||||||
| { | { | ||||||
|   EFI_STATUS  Status; |  | ||||||
|  |  | ||||||
|   DEBUG (( |   DEBUG (( | ||||||
|     DEBUG_INFO, |     DEBUG_INFO, | ||||||
|     "%a: BaseAddress == 0x%lx, Length == 0x%lx, Attributes == 0x%lx\n", |     "%a: BaseAddress == 0x%lx, Length == 0x%lx, Attributes == 0x%lx\n", | ||||||
| @@ -204,28 +202,7 @@ SetMemoryAttributes ( | |||||||
|     return EFI_UNSUPPORTED; |     return EFI_UNSUPPORTED; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if ((Attributes & EFI_MEMORY_RP) != 0) { |   return ArmSetMemoryAttributes (BaseAddress, Length, Attributes, Attributes); | ||||||
|     Status = ArmSetMemoryRegionNoAccess (BaseAddress, Length); |  | ||||||
|     if (EFI_ERROR (Status)) { |  | ||||||
|       return EFI_UNSUPPORTED; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   if ((Attributes & EFI_MEMORY_RO) != 0) { |  | ||||||
|     Status = ArmSetMemoryRegionReadOnly (BaseAddress, Length); |  | ||||||
|     if (EFI_ERROR (Status)) { |  | ||||||
|       return EFI_UNSUPPORTED; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   if ((Attributes & EFI_MEMORY_XP) != 0) { |  | ||||||
|     Status = ArmSetMemoryRegionNoExec (BaseAddress, Length); |  | ||||||
|     if (EFI_ERROR (Status)) { |  | ||||||
|       return EFI_UNSUPPORTED; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   return EFI_SUCCESS; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -267,8 +244,6 @@ ClearMemoryAttributes ( | |||||||
|   IN  UINT64                         Attributes |   IN  UINT64                         Attributes | ||||||
|   ) |   ) | ||||||
| { | { | ||||||
|   EFI_STATUS  Status; |  | ||||||
|  |  | ||||||
|   DEBUG (( |   DEBUG (( | ||||||
|     DEBUG_INFO, |     DEBUG_INFO, | ||||||
|     "%a: BaseAddress == 0x%lx, Length == 0x%lx, Attributes == 0x%lx\n", |     "%a: BaseAddress == 0x%lx, Length == 0x%lx, Attributes == 0x%lx\n", | ||||||
| @@ -288,28 +263,7 @@ ClearMemoryAttributes ( | |||||||
|     return EFI_UNSUPPORTED; |     return EFI_UNSUPPORTED; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   if ((Attributes & EFI_MEMORY_RP) != 0) { |   return ArmSetMemoryAttributes (BaseAddress, Length, 0, Attributes); | ||||||
|     Status = ArmClearMemoryRegionNoAccess (BaseAddress, Length); |  | ||||||
|     if (EFI_ERROR (Status)) { |  | ||||||
|       return EFI_UNSUPPORTED; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   if ((Attributes & EFI_MEMORY_RO) != 0) { |  | ||||||
|     Status = ArmClearMemoryRegionReadOnly (BaseAddress, Length); |  | ||||||
|     if (EFI_ERROR (Status)) { |  | ||||||
|       return EFI_UNSUPPORTED; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   if ((Attributes & EFI_MEMORY_XP) != 0) { |  | ||||||
|     Status = ArmClearMemoryRegionNoExec (BaseAddress, Length); |  | ||||||
|     if (EFI_ERROR (Status)) { |  | ||||||
|       return EFI_UNSUPPORTED; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   return EFI_SUCCESS; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| EFI_MEMORY_ATTRIBUTE_PROTOCOL  mMemoryAttribute = { | EFI_MEMORY_ATTRIBUTE_PROTOCOL  mMemoryAttribute = { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user