From 2e74e2ac96d7c1f145b3372898f36a91a20dd5d9 Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Thu, 31 May 2018 13:51:48 +0800 Subject: imx8qm: move M4 to OS part at last With default configuration, M4 and A35 in one partition, M4 is loaded by ROM. "err = sc_rm_move_all(ipc_handle, secure_part, os_part, true, true);" M4 core will first be moved to non-secure OS part, then the resource used by M4 will be moved to non-secure OS part later. But before the resource be moved to non-secure OS part, M4 core is still running, so a non-secure M4 core access a secure resource will trigger error in M4 side. First mark M4 core as non-movable, after all other resoures moved to OS part, move M4 to OS part. No need to check whether M4 is created a new partition by SCFW, if a partition already created, the call to mark M4 as non-removable will fail, because it M4 is in its own partition. Signed-off-by: Peng Fan --- plat/imx/imx8qm/imx8qm_bl31_setup.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'plat/imx/imx8qm/imx8qm_bl31_setup.c') diff --git a/plat/imx/imx8qm/imx8qm_bl31_setup.c b/plat/imx/imx8qm/imx8qm_bl31_setup.c index 7ad56376..142dabc2 100644 --- a/plat/imx/imx8qm/imx8qm_bl31_setup.c +++ b/plat/imx/imx8qm/imx8qm_bl31_setup.c @@ -168,7 +168,7 @@ void mx8_partition_resources(void) sc_err_t err; sc_rm_pt_t secure_part, os_part; sc_rm_mr_t mr, mr_record = 64; - bool owned; + bool owned, owned2; sc_faddr_t start, end; int i; @@ -185,6 +185,15 @@ void mx8_partition_resources(void) secure_rsrcs[i], false); } + owned = sc_rm_is_resource_owned(ipc_handle, SC_R_M4_0_PID0); + if (owned) + err = sc_rm_set_resource_movable(ipc_handle, SC_R_M4_0_PID0, + SC_R_M4_0_PID0, false); + + owned2 = sc_rm_is_resource_owned(ipc_handle, SC_R_M4_1_PID0); + if (owned2) + err = sc_rm_set_resource_movable(ipc_handle, SC_R_M4_1_PID0, + SC_R_M4_1_PID0, false); /* move all movable resources and pins to non-secure partition */ err = sc_rm_move_all(ipc_handle, secure_part, os_part, true, true); @@ -194,6 +203,17 @@ void mx8_partition_resources(void) os_part, SC_RM_PERM_FULL); } + if (owned) { + err = sc_rm_set_resource_movable(ipc_handle, SC_R_M4_0_PID0, + SC_R_M4_0_PID0, true); + err = sc_rm_assign_resource(ipc_handle, os_part, SC_R_M4_0_PID0); + } + if (owned2) { + err = sc_rm_set_resource_movable(ipc_handle, SC_R_M4_1_PID0, + SC_R_M4_1_PID0, true); + err = sc_rm_assign_resource(ipc_handle, os_part, SC_R_M4_1_PID0); + } + /* * sc_rm_set_peripheral_permissions * -- cgit v1.2.3