feat(rmm): fix update_ripas()
This patch fixes the following issues:
- smc_rtt_init_ripas() didn't return error if the s2tte was
assigned_empty
- smc_rtt_set_ripas() failed to properly do these transitions:
- unassigned_ram -> unassigned_empty
- assigned_empty -> unassigned_ram
- renames "ripas" variable/structure member of "enum ripas" type
to "ripas_val".
Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com>
Change-Id: I8ffc5d9c567786c9ae821116441c8dc3178e0242
diff --git a/lib/realm/src/s2tt.c b/lib/realm/src/s2tt.c
index 365ed7b..f422001 100644
--- a/lib/realm/src/s2tt.c
+++ b/lib/realm/src/s2tt.c
@@ -386,9 +386,9 @@
/*
* Creates a value which can be OR'd with an s2tte to set RIPAS=@ripas.
*/
-unsigned long s2tte_create_ripas(enum ripas ripas)
+unsigned long s2tte_create_ripas(enum ripas ripas_val)
{
- if (ripas == RIPAS_EMPTY) {
+ if (ripas_val == RIPAS_EMPTY) {
return S2TTE_INVALID_RIPAS_EMPTY;
}
return S2TTE_INVALID_RIPAS_RAM;
@@ -532,6 +532,22 @@
}
/*
+ * Returns true if s2tte has defined ripas value, namely if it is one of:
+ * - unassigned_empty
+ * - unassigned_ram
+ * - assigned_empty
+ * - assigned_ram
+ */
+bool s2tte_has_ripas(unsigned long s2tte, long level)
+{
+ if (s2tte_is_table(s2tte, level) || s2tte_is_destroyed(s2tte) ||
+ ((s2tte & S2TTE_NS) != 0UL)) {
+ return false;
+ }
+ return true;
+}
+
+/*
* Returns true if @s2tte has HIPAS=@hipas.
*/
static bool s2tte_has_hipas(unsigned long s2tte, unsigned long hipas)
@@ -561,14 +577,6 @@
}
/*
- * Returns true if @s2tte has HIPAS=UNASSIGNED or HIPAS=INVALID_NS.
- */
-bool s2tte_is_unassigned(unsigned long s2tte)
-{
- return s2tte_has_hipas(s2tte, S2TTE_INVALID_HIPAS_UNASSIGNED);
-}
-
-/*
* Returns true if @s2tte is an unassigned_empty.
*/
bool s2tte_is_unassigned_empty(unsigned long s2tte)
@@ -874,7 +882,7 @@
enum ripas *ripas_ptr)
{
unsigned long s2tte = s2tte_read(&table[0]);
- enum ripas ripas;
+ enum ripas ripas_val;
unsigned int i;
if (!s2tte_is_x(s2tte)) {
@@ -882,7 +890,7 @@
}
if (ripas_ptr != NULL) {
- ripas = s2tte_get_ripas(s2tte);
+ ripas_val = s2tte_get_ripas(s2tte);
}
for (i = 1U; i < S2TTES_PER_S2TT; i++) {
@@ -893,13 +901,13 @@
}
if ((ripas_ptr != NULL) &&
- (s2tte_get_ripas(s2tte) != ripas)) {
+ (s2tte_get_ripas(s2tte) != ripas_val)) {
return false;
}
}
if (ripas_ptr != NULL) {
- *ripas_ptr = ripas;
+ *ripas_ptr = ripas_val;
}
return true;