Revision: 18897
          http://sourceforge.net/p/edk2/code/18897
Author:   abiesheuvel
Date:     2015-11-18 15:59:22 +0000 (Wed, 18 Nov 2015)
Log Message:
-----------
ArmPkg/ArmV7Mmu: introduce feature PCD to map normal memory non-shareable

Even though mapping normal memory (inner) shareable is usually the
correct choice on coherent systems, it may be desirable in some cases
to use non-shareable mappings for normal memory, e.g., when hardware
managed coherency is not required and the memory system is not fully
configured yet. So introduce a PCD PcdNormalMemoryNonshareableOverride
that makes cacheable mappings of normal memory non-shareable.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <[email protected]>
Reviewed-by: Leif Lindholm <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ArmPkg/ArmPkg.dec
    trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf
    trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf
    trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c

Modified: trunk/edk2/ArmPkg/ArmPkg.dec
===================================================================
--- trunk/edk2/ArmPkg/ArmPkg.dec        2015-11-18 15:59:04 UTC (rev 18896)
+++ trunk/edk2/ArmPkg/ArmPkg.dec        2015-11-18 15:59:22 UTC (rev 18897)
@@ -73,6 +73,12 @@
   # Define if the GICv3 controller should use the GICv2 legacy
   gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042
 
+[PcdsFeatureFlag.ARM]
+  # Whether to map normal memory as non-shareable. FALSE is the safe choice, 
but
+  # TRUE may be appropriate to fix performance problems if you don't care about
+  # hardware coherency (i.e., no virtualization or cache coherent DMA)
+  
gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride|FALSE|BOOLEAN|0x00000043
+
 [PcdsFixedAtBuild.common]
   gArmTokenSpaceGuid.PcdTrustzoneSupport|FALSE|BOOLEAN|0x00000006
 

Modified: trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf
===================================================================
--- trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf 2015-11-18 15:59:04 UTC 
(rev 18896)
+++ trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf 2015-11-18 15:59:22 UTC 
(rev 18897)
@@ -48,3 +48,6 @@
 
 [Protocols]
   gEfiCpuArchProtocolGuid
+
+[FeaturePcd.ARM]
+  gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride

Modified: trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf
===================================================================
--- trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf    2015-11-18 
15:59:04 UTC (rev 18896)
+++ trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf    2015-11-18 
15:59:22 UTC (rev 18897)
@@ -48,3 +48,6 @@
 
 [Protocols]
   gEfiCpuArchProtocolGuid
+
+[FeaturePcd.ARM]
+  gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride

Modified: trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c
===================================================================
--- trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c   2015-11-18 15:59:04 UTC 
(rev 18896)
+++ trunk/edk2/ArmPkg/Library/ArmLib/ArmV7/ArmV7Mmu.c   2015-11-18 15:59:22 UTC 
(rev 18897)
@@ -80,6 +80,10 @@
       break;
   }
 
+  if (FeaturePcdGet(PcdNormalMemoryNonshareableOverride)) {
+    PageAttributes &= ~TT_DESCRIPTOR_PAGE_S_SHARED;
+  }
+
   // Check if the Section Entry has already been populated. Otherwise attach a
   // Level 2 Translation Table to it
   if (*SectionEntry != 0) {
@@ -178,6 +182,10 @@
       break;
   }
 
+  if (FeaturePcdGet(PcdNormalMemoryNonshareableOverride)) {
+    Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED;
+  }
+
   // Get the first section entry for this mapping
   SectionEntry    = 
TRANSLATION_TABLE_ENTRY_FOR_VIRTUAL_ADDRESS(TranslationTable, 
MemoryRegion->VirtualBase);
 
@@ -266,15 +274,19 @@
   }
 
   if (TTBRAttributes & TTBR_SHAREABLE) {
-    //
-    // Unlike the S bit in the short descriptors, which implies inner shareable
-    // on an implementation that supports two levels, the meaning of the S bit
-    // in the TTBR depends on the NOS bit, which defaults to Outer Shareable.
-    // However, we should only set this bit after we have confirmed that the
-    // implementation supports multiple levels, or else the NOS bit is UNK/SBZP
-    //
-    if (((ArmReadIdMmfr0 () >> 12) & 0xf) != 0) {
-      TTBRAttributes |= TTBR_NOT_OUTER_SHAREABLE;
+    if (FeaturePcdGet(PcdNormalMemoryNonshareableOverride)) {
+      TTBRAttributes ^= TTBR_SHAREABLE;
+    } else {
+      //
+      // Unlike the S bit in the short descriptors, which implies inner 
shareable
+      // on an implementation that supports two levels, the meaning of the S 
bit
+      // in the TTBR depends on the NOS bit, which defaults to Outer Shareable.
+      // However, we should only set this bit after we have confirmed that the
+      // implementation supports multiple levels, or else the NOS bit is 
UNK/SBZP
+      //
+      if (((ArmReadIdMmfr0 () >> 12) & 0xf) != 0) {
+        TTBRAttributes |= TTBR_NOT_OUTER_SHAREABLE;
+      }
     }
   }
 


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to