test(realm): fix bug in RMI_RTT_SET_S2AP command helper

pass correct rec adr to RMI_RTT_SET_S2AP command.
RSI_MEM_SET_PERM_INDEX can be called from any rec.

Change-Id: I701d7f7f9de80f305d10d2582c614b3090fc2ac5
Signed-off-by: Shruti Gupta <shruti.gupta@arm.com>
diff --git a/tftf/tests/runtime_services/host_realm_managment/host_realm_rmi.c b/tftf/tests/runtime_services/host_realm_managment/host_realm_rmi.c
index 82a80a1..72d0876 100644
--- a/tftf/tests/runtime_services/host_realm_managment/host_realm_rmi.c
+++ b/tftf/tests/runtime_services/host_realm_managment/host_realm_rmi.c
@@ -1768,7 +1768,8 @@
 }
 
 /* Handle RSI_MEM_SET_PERM_INDEX by P0, return true to return to realm, false to return to host */
-static bool host_realm_handle_s2ap_change(struct realm *realm, struct rmi_rec_run *run)
+static bool host_realm_handle_s2ap_change(struct realm *realm, struct rmi_rec_run *run,
+		u_register_t rec_num)
 {
 
 
@@ -1779,7 +1780,7 @@
 
 	while (new_base != top) {
 		ret = host_rmi_rtt_set_s2ap(realm->rd,
-				    realm->rec[0U],
+				    realm->rec[rec_num],
 				    new_base,
 				    top, &new_base,
 				    &rtt_tree);
@@ -1896,7 +1897,7 @@
 		    is_adr_in_par(realm, run->exit.s2ap_base) &&
 		    (realm->num_aux_planes > 0U)) {
 
-			re_enter_rec = host_realm_handle_s2ap_change(realm, run);
+			re_enter_rec = host_realm_handle_s2ap_change(realm, run, rec_num);
 		}
 
 		if (ret != RMI_SUCCESS) {