Core: Add ZI and RW regions for seucre data in memory check
The ER_TFM_DATA zero data region is not included in the section between
Image$$ER_TFM_DATA$$Base and Image$$ER_TFM_DATA$$Limit. If the client
data buffer comes from the ZI region, the memory check function will
fail. So use RW and ZI region respectively to do a memory check to fix
this issue.
Change-Id: I0b2b3673ce9c3d99bd076ca541a331775b424dff
Signed-off-by: Edison Ai <edison.ai@arm.com>
diff --git a/secure_fw/core/ipc/tfm_spm.c b/secure_fw/core/ipc/tfm_spm.c
index 86e047e..1c06cd3 100644
--- a/secure_fw/core/ipc/tfm_spm.c
+++ b/secure_fw/core/ipc/tfm_spm.c
@@ -460,8 +460,10 @@
/* Macros to pick linker symbols and allow references to sections in all level*/
#define REGION_DECLARE_EXT(a, b, c) extern uint32_t REGION_NAME(a, b, c)
-REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$Base);
-REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$Limit);
+REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$ZI$$Base);
+REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$ZI$$Limit);
+REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$RW$$Base);
+REGION_DECLARE_EXT(Image$$, ER_TFM_DATA, $$RW$$Limit);
REGION_DECLARE_EXT(Image$$, TFM_SECURE_STACK, $$ZI$$Base);
REGION_DECLARE_EXT(Image$$, TFM_SECURE_STACK, $$ZI$$Limit);
REGION_DECLARE_EXT(Image$$, TFM_UNPRIV_SCRATCH, $$ZI$$Base);
@@ -514,8 +516,14 @@
return IPC_SUCCESS;
}
} else {
- base = (uintptr_t)®ION_NAME(Image$$, ER_TFM_DATA, $$Base);
- limit = (uintptr_t)®ION_NAME(Image$$, ER_TFM_DATA, $$Limit);
+ base = (uintptr_t)®ION_NAME(Image$$, ER_TFM_DATA, $$RW$$Base);
+ limit = (uintptr_t)®ION_NAME(Image$$, ER_TFM_DATA, $$RW$$Limit);
+ if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
+ return IPC_SUCCESS;
+ }
+
+ base = (uintptr_t)®ION_NAME(Image$$, ER_TFM_DATA, $$ZI$$Base);
+ limit = (uintptr_t)®ION_NAME(Image$$, ER_TFM_DATA, $$ZI$$Limit);
if (memory_check_range(buffer, len, base, limit) == IPC_SUCCESS) {
return IPC_SUCCESS;
}