]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/CpuDxe: translate invalid memory types in EfiAttributeToArmAttribute
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 15 Feb 2017 17:11:54 +0000 (17:11 +0000)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 21 Feb 2017 17:23:03 +0000 (17:23 +0000)
The single user of EfiAttributeToArmAttribute () is the protocol
method EFI_CPU_ARCH_PROTOCOL.SetMemoryAttributes(), which uses the
return value to compare against the ARM attributes of an existing mapping,
to infer whether it is actually necessary to change anything, or whether
the requested update is redundant. This saves some cache and TLB
maintenance on 32-bit ARM systems that use uncached translation tables.

However, EFI_CPU_ARCH_PROTOCOL.SetMemoryAttributes() may be invoked with
only permission bits set, in which case the implied requested action is to
update the permissions of the region without modifying the cacheability
attributes. This is currently not possible, because
EfiAttributeToArmAttribute () ASSERT()s [on AArch64] on Attributes arguments
that lack a cacheability bit.

So let's simply return TT_ATTR_INDX_MASK (AArch64) or
TT_DESCRIPTOR_SECTION_TYPE_FAULT (ARM) in these cases (or'ed with the
appropriate permission bits). This way, the return value is equally
suitable for checking whether the attributes need to be modified, but
in a way that accommodates the use without a cacheability bit set.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
ArmPkg/Drivers/CpuDxe/Arm/Mmu.c

index 15d5a81732334211a8e15ae957b826308187bbf4..7688846e70cb1833c732a3eafee8e885004b502a 100644 (file)
@@ -216,9 +216,7 @@ EfiAttributeToArmAttribute (
     ArmAttributes = TT_ATTR_INDX_MEMORY_WRITE_BACK;\r
     break;\r
   default:\r
     ArmAttributes = TT_ATTR_INDX_MEMORY_WRITE_BACK;\r
     break;\r
   default:\r
-    DEBUG ((EFI_D_ERROR, "EfiAttributeToArmAttribute: 0x%lX attributes is not supported.\n", EfiAttributes));\r
-    ASSERT (0);\r
-    ArmAttributes = TT_ATTR_INDX_DEVICE_MEMORY;\r
+    ArmAttributes = TT_ATTR_INDX_MASK;\r
   }\r
 \r
   // Set the access flag to match the block attributes\r
   }\r
 \r
   // Set the access flag to match the block attributes\r
index 6dcfba69e8799f04d4f618359e9531c521305d93..b6ba975b353ab66540457d9b1a49d00db8f44319 100644 (file)
@@ -733,10 +733,7 @@ EfiAttributeToArmAttribute (
 \r
     case EFI_MEMORY_UCE:\r
     default:\r
 \r
     case EFI_MEMORY_UCE:\r
     default:\r
-      // Cannot be implemented UEFI definition unclear for ARM\r
-      // Cause a page fault if these ranges are accessed.\r
       ArmAttributes = TT_DESCRIPTOR_SECTION_TYPE_FAULT;\r
       ArmAttributes = TT_DESCRIPTOR_SECTION_TYPE_FAULT;\r
-      DEBUG ((EFI_D_PAGE, "SetMemoryAttributes(): Unsupported attribute %x will page fault on access\n", EfiAttributes));\r
       break;\r
   }\r
 \r
       break;\r
   }\r
 \r