fix(lib/s2tt): NS attributes set by host are not checked during FOLD

Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com>
Change-Id: I6ffd4fc7be5d63b031accf615eeb9ceb5c01ab6a
diff --git a/lib/s2tt/src/s2tt.c b/lib/s2tt/src/s2tt.c
index 304b8ea..3ba0e13 100644
--- a/lib/s2tt/src/s2tt.c
+++ b/lib/s2tt/src/s2tt.c
@@ -1146,6 +1146,7 @@
 	unsigned long base_pa, ns_attr_host_mask;
 	unsigned long map_size = s2tte_map_size(level);
 	unsigned long s2tte = s2tte_read(&table[0]);
+	unsigned long s2tt_ns_attrs;
 	unsigned int i;
 
 	if (!s2tte_is_x(s2_ctx, s2tte, level)) {
@@ -1159,6 +1160,7 @@
 
 	ns_attr_host_mask = (s2_ctx->enable_lpa2 == true) ?
 		S2TTE_NS_ATTR_LPA2_MASK : S2TTE_NS_ATTR_MASK;
+	s2tt_ns_attrs  = s2tte & ns_attr_host_mask;
 
 	for (i = 1U; i < S2TTES_PER_S2TT; i++) {
 		unsigned long expected_pa = base_pa + (i * map_size);
@@ -1181,7 +1183,7 @@
 			 * We match all the attributes in the S2TTE
 			 * except for the AF bit.
 			 */
-			if ((s2tte & ns_attr_host_mask) != ns_attrs) {
+			if (s2tt_ns_attrs != ns_attrs) {
 				return false;
 			}
 		}