Support SPCI memory sharing clear flag.
Bug: 132420445
Change-Id: I2705cc8114dcf3ad500e4060be54527cebc3d5a2
diff --git a/src/api.c b/src/api.c
index caf024c..c748fb5 100644
--- a/src/api.c
+++ b/src/api.c
@@ -1544,6 +1544,19 @@
goto out;
}
+ /* Clear the memory so no VM or device can see the previous contents. */
+ if ((memory_region->flags & SPCI_MEMORY_REGION_FLAG_CLEAR) &&
+ !api_clear_memory(pa_begin, pa_end, &local_page_pool)) {
+ ret = spci_error(SPCI_NO_MEMORY);
+
+ /* Return memory to the sender. */
+ CHECK(mm_vm_identity_map(&from->ptable, pa_begin, pa_end,
+ orig_from_mode, NULL,
+ &local_page_pool));
+
+ goto out;
+ }
+
/* Complete the transfer by mapping the memory into the recipient. */
if (!mm_vm_identity_map(&to->ptable, pa_begin, pa_end, to_mode, NULL,
&local_page_pool)) {