SPM: Correct stack pointer moving to avoid irq context overlap
This patch fixes the irq stack operation logic when push or pop
the interrupted context stack frame to avoid overlap with handler
context stack frame.
Change-Id: I22e3dce42233adef6910ce718f03fb12075a2fdf
Signed-off-by: Matt Ma <matt2048.ma@gmail.com>
diff --git a/secure_fw/spm/spm_api_func.c b/secure_fw/spm/spm_api_func.c
index d907e59..bf2b4b8 100644
--- a/secure_fw/spm/spm_api_func.c
+++ b/secure_fw/spm/spm_api_func.c
@@ -110,6 +110,9 @@
(struct interrupted_ctx_stack_frame_t *)runtime_data->ctx_stack_ptr;
stack_frame->partition_state = runtime_data->partition_state;
+
+ runtime_data->ctx_stack_ptr +=
+ sizeof(struct interrupted_ctx_stack_frame_t) / sizeof(uint32_t);
}
void tfm_spm_partition_pop_interrupted_ctx(uint32_t partition_idx)
@@ -118,6 +121,9 @@
&g_spm_partition_db.partitions[partition_idx].runtime_data;
struct interrupted_ctx_stack_frame_t *stack_frame;
+ runtime_data->ctx_stack_ptr -=
+ sizeof(struct interrupted_ctx_stack_frame_t) / sizeof(uint32_t);
+
stack_frame = (struct interrupted_ctx_stack_frame_t *)
runtime_data->ctx_stack_ptr;
tfm_spm_partition_set_state(partition_idx, stack_frame->partition_state);