public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/CapsulePei: clean Dcache before consuming capsule data
@ 2018-06-06  9:52 Ard Biesheuvel
  2018-06-06 12:09 ` Ard Biesheuvel
  0 siblings, 1 reply; 15+ messages in thread
From: Ard Biesheuvel @ 2018-06-06  9:52 UTC (permalink / raw)
  To: edk2-devel
  Cc: leif.lindholm, jiewen.yao, ruiyu.ni, star.zeng, michael.d.kinney,
	liming.gao, Ard Biesheuvel

When capsule updates are staged for processing after a warm reboot,
they are copied into memory with the MMU and caches enabled. When
the capsule PEI gets around to coalescing the capsule, the MMU and
caches may still be disabled, and so on architectures where uncached
accesses are incoherent with the caches (such as ARM and AARCH64),
we may read stale data if we don't clean the caches to memory first.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/Universal/CapsulePei/CapsulePei.inf           | 1 +
 MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf b/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf
index c54bc21a95a8..594e110d1f8a 100644
--- a/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf
+++ b/MdeModulePkg/Universal/CapsulePei/CapsulePei.inf
@@ -48,6 +48,7 @@ [Packages]
 
 [LibraryClasses]
   BaseLib
+  CacheMaintenanceLib
   HobLib
   BaseMemoryLib
   PeiServicesLib
diff --git a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c b/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c
index 3e7054cd38a9..1730f925adc5 100644
--- a/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c
+++ b/MdeModulePkg/Universal/CapsulePei/Common/CapsuleCoalesce.c
@@ -27,6 +27,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/CapsuleVendor.h>
 
 #include <Library/BaseMemoryLib.h>
+#include <Library/CacheMaintenanceLib.h>
 #include <Library/DebugLib.h>
 #include <Library/PrintLib.h>
 #include <Library/BaseLib.h>
@@ -283,6 +284,9 @@ ValidateCapsuleByMemoryResource (
       DEBUG ((EFI_D_INFO, "Address(0x%lx) Size(0x%lx) in MemoryResource[0x%x] - Start(0x%lx) Length(0x%lx)\n",
                           Address, Size,
                           Index, MemoryResource[Index].PhysicalStart, MemoryResource[Index].ResourceLength));
+
+      WriteBackDataCacheRange ((VOID *)(UINTN)Address, Size);
+
       return TRUE;
     }
   }
-- 
2.17.0



^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-06-07 10:27 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-06  9:52 [PATCH] MdeModulePkg/CapsulePei: clean Dcache before consuming capsule data Ard Biesheuvel
2018-06-06 12:09 ` Ard Biesheuvel
2018-06-06 13:59   ` Yao, Jiewen
2018-06-06 16:07   ` Kinney, Michael D
2018-06-06 16:13     ` Ard Biesheuvel
2018-06-07  1:37   ` Zeng, Star
2018-06-07  4:50     ` Ard Biesheuvel
2018-06-07  5:41       ` Zeng, Star
2018-06-07  6:00         ` Ard Biesheuvel
2018-06-07  9:46           ` Zeng, Star
2018-06-07  9:52             ` Ard Biesheuvel
2018-06-07 10:12               ` Zeng, Star
2018-06-07 10:14                 ` Ard Biesheuvel
2018-06-07 10:27                   ` Zeng, Star
2018-06-07 10:27                     ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox