test(realm): enhance realm memory exception tests for planes

Extend memory exception tests for planes.

Change-Id: Ifc98b8c67e85b04b36a78f16971d17f05d6a87d2
Signed-off-by: Shruti Gupta <shruti.gupta@arm.com>
diff --git a/realm/realm_plane.c b/realm/realm_plane.c
index 3b79aff..656c688 100644
--- a/realm/realm_plane.c
+++ b/realm/realm_plane.c
@@ -19,6 +19,7 @@
 
 static bool is_plane0;
 static unsigned int plane_num;
+static bool plane_init[MAX_PLANE_COUNT];
 
 bool realm_is_plane0(void)
 {
@@ -168,11 +169,16 @@
 	run->enter.pc = base;
 
 	/* Perm init */
+	if (plane_init[plane_index]) {
+		return true;
+	}
+
 	ret = rsi_mem_set_perm_value(plane_index, perm_index, PERM_LABEL_RW_upX);
 	if (ret != RSI_SUCCESS) {
 		ERROR("rsi_mem_set_perm_value failed %u\n", plane_index);
 		return false;
 	}
+	plane_init[plane_index] = true;
 	return true;
 }