feat(rmm): update API of RSI_IPA_STATE_SET command
This patch makes the changes listed below:
- API of RSI_IPA_STATE_SET command is updated as
per RMM Specification 1.0-eac2 by adding "flags"
parameter passed in X4;
- Added "change_destroyed" member in "set_ripas"
structure;
- Removed *rtt_level parameter of realm_ipa_get_ripas()
function, which now returns WALK_FAIL if
the entry does not have a valid ripas value.
- Function handle_rsi_ipa_state_get() always
returns to Realm for all cases of ripas values,
including RIPAS_DESTROYED.
Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com>
Change-Id: I60d9be4aba17819ccd4af69dc8c19434f3b13ae2
diff --git a/lib/realm/include/realm.h b/lib/realm/include/realm.h
index e49d918..4389afe 100644
--- a/lib/realm/include/realm.h
+++ b/lib/realm/include/realm.h
@@ -260,6 +260,7 @@
struct s2_walk_result *res);
enum s2_walk_status realm_ipa_get_ripas(struct rec *rec, unsigned long ipa,
- enum ripas *ripas_ptr,
- unsigned long *rtt_level);
+ enum ripas *ripas_ptr);
+int realm_ipa_check_ripas_range(struct rec *rec, unsigned long base,
+ unsigned long top);
#endif /* REALM_H */
diff --git a/lib/realm/include/rec.h b/lib/realm/include/rec.h
index 34cc31b..6b5b6a2 100644
--- a/lib/realm/include/rec.h
+++ b/lib/realm/include/rec.h
@@ -166,6 +166,7 @@
unsigned long top;
unsigned long addr;
enum ripas ripas_val;
+ enum ripas_change_destroyed change_destroyed;
} set_ripas;
/*
diff --git a/lib/realm/include/ripas.h b/lib/realm/include/ripas.h
index 53350c5..2143d8f 100644
--- a/lib/realm/include/ripas.h
+++ b/lib/realm/include/ripas.h
@@ -7,6 +7,7 @@
#define RIPAS_H
#include <smc-rmi.h>
+#include <smc-rsi.h>
/*
* The RmmRipas enumeration represents realm IPA state.
@@ -19,4 +20,19 @@
RIPAS_DESTROYED = RMI_DESTROYED /* IPA is inaccessible to the Realm */
};
+/*
+ * The RmmRipasChangeDestroyed enumeration represents whether a RIPAS change
+ * from DESTROYED should be permitted.
+ *
+ * Map RmmRipasChangeDestroyed to RsiRipasChangeDestroyed to simplify check
+ * operation.
+ */
+enum ripas_change_destroyed {
+ /* A RIPAS change from DESTROYED should not be permitted */
+ NO_CHANGE_DESTROYED = RSI_NO_CHANGE_DESTROYED,
+
+ /* A RIPAS change from DESTROYED should be permitted */
+ CHANGE_DESTROYED = RSI_CHANGE_DESTROYED
+};
+
#endif /* RIPAS_H */
diff --git a/lib/realm/src/s2tt.c b/lib/realm/src/s2tt.c
index 3b2fda7..d127034 100644
--- a/lib/realm/src/s2tt.c
+++ b/lib/realm/src/s2tt.c
@@ -82,25 +82,29 @@
* 4. RIPAS field [6:5]
* 5. NS field [55]
*
- * s2tte type level DESC_TYPE[1:0] HIPAS[5:2] RIPAS[6] NS OA alignment
- * =============================================================================
- * unassigned_empty any invalid[0] unassigned[0] empty[0] 0 n/a
- * -----------------------------------------------------------------------------
- * unassigned_ram any invalid[0] unassigned[0] ram[1] 0 n/a
- * -----------------------------------------------------------------------------
- * assigned_empty 2,3 invalid[0] assigned[1] empty[0] 0 to level
- * -----------------------------------------------------------------------------
- * assigned_ram 3 page[1] n/a n/a 0 to level
- * 2 block[3] n/a n/a 0 to level
- * -----------------------------------------------------------------------------
- * destroyed any invalid[0] destroyed[2] n/a 0 n/a
- * =============================================================================
- * unassigned_ns any invalid[0] unassigned[0] n/a 1 n/a
- * -----------------------------------------------------------------------------
- * assigned_ns 3 page[1] n/a n/a 1 to level
- * 2 block[3] n/a n/a 1 to level
- * =============================================================================
- * table <=2 table[1] n/a n/a n/a to 4K
+ * ======================================================================================
+ * s2tte type level DESC_TYPE[1:0] HIPAS[4:2] RIPAS[6:5] NS OA alignment
+ * ======================================================================================
+ * unassigned_empty any invalid[0] unassigned[0] empty[0] 0 n/a
+ * --------------------------------------------------------------------------------------
+ * unassigned_ram any invalid[0] unassigned[0] ram[1] 0 n/a
+ * --------------------------------------------------------------------------------------
+ * unassigned_destroyed any invalid[0] unassigned[0] destroyed[2] 0 n/a
+ * --------------------------------------------------------------------------------------
+ * assigned_empty 2,3 invalid[0] assigned[1] empty[0] 0 to level
+ * --------------------------------------------------------------------------------------
+ * assigned_ram 3 page[3] n/a n/a 0 to level
+ * 2 block[1] n/a n/a 0 to level
+ * --------------------------------------------------------------------------------------
+ * assigned_destroyed any invalid[0] assigned[1] destroyed[2] 0 n/a
+ * ======================================================================================
+ * unassigned_ns any invalid[0] unassigned[0] n/a 1 n/a
+ * --------------------------------------------------------------------------------------
+ * assigned_ns 3 page[3] n/a n/a 1 to level
+ * 2 block[1] n/a n/a 1 to level
+ * ======================================================================================
+ * table <=2 table[3] n/a n/a n/a to 4K
+ * ======================================================================================
*/
#define S2TTE_INVALID_HIPAS_SHIFT 2
@@ -552,7 +556,7 @@
unsigned long desc_type = s2tte & DESC_TYPE_MASK;
unsigned long invalid_desc_hipas = s2tte & S2TTE_INVALID_HIPAS_MASK;
- return ((desc_type == S2TTE_Lx_INVALID) && (invalid_desc_hipas == hipas));
+ return ((desc_type == S2TTE_INVALID) && (invalid_desc_hipas == hipas));
}
/*
@@ -694,7 +698,7 @@
* bit is 1 (S2AP is set to RW for lower EL), which corresponds
* to RIPAS_RAM (bits[6:5] = b01) on a valid descriptor.
*/
- if (((s2tte & DESC_TYPE_MASK) != S2TTE_Lx_INVALID) &&
+ if (((s2tte & DESC_TYPE_MASK) != S2TTE_INVALID) &&
(desc_ripas != S2TTE_INVALID_RIPAS_RAM)) {
assert(false);
}
diff --git a/lib/smc/include/smc-rsi.h b/lib/smc/include/smc-rsi.h
index 483b25d..dbd9e8c 100644
--- a/lib/smc/include/smc-rsi.h
+++ b/lib/smc/include/smc-rsi.h
@@ -38,23 +38,39 @@
#define SMC_RSI_ABI_VERSION SMC64_RSI_FID(U(0x0))
-/* RSI Status code enumeration as per Section D4.3.6 of the RMM Spec */
+/*
+ * RsiCommandReturnCode enumeration
+ * representing a return code from an RSI command.
+ */
/* Command completed successfully */
-#define RSI_SUCCESS U(0)
+#define RSI_SUCCESS UL(0)
/* The value of a command input value caused the command to fail */
-#define RSI_ERROR_INPUT U(1)
+#define RSI_ERROR_INPUT UL(1)
/*
* The state of the current Realm or current REC
* does not match the state expected by the command
*/
-#define RSI_ERROR_STATE U(2)
+#define RSI_ERROR_STATE UL(2)
/* The operation requested by the command is not complete */
-#define RSI_INCOMPLETE U(3)
+#define RSI_INCOMPLETE UL(3)
-#define RSI_ERROR_COUNT U(4)
+#define RSI_ERROR_COUNT UL(4)
+
+/* RsiHashAlgorithm */
+#define RSI_HASH_SHA_256 U(0)
+#define RSI_HASH_SHA_512 U(1)
+
+/*
+ * RsiRipasChangeDestroyed:
+ * RIPAS change from DESTROYED should not be permitted
+ */
+#define RSI_NO_CHANGE_DESTROYED U(0)
+
+/* A RIPAS change from DESTROYED should be permitted */
+#define RSI_CHANGE_DESTROYED U(1)
/*
* Returns a measurement.
@@ -118,10 +134,6 @@
*/
#define SET_MEMBER_RSI SET_MEMBER
-/* RsiHashAlgorithm type */
-#define RSI_HASH_SHA_256 U(0)
-#define RSI_HASH_SHA_512 U(1)
-
/* RsiRealmConfig structure containing realm configuration */
struct rsi_realm_config {
/* IPA width in bits */
@@ -141,6 +153,7 @@
* arg0 == Base IPA address of target region
* arg1 == Top address of target region
* arg2 == RIPAS value
+ * arg3 == flags
* ret0 == Status / error
* ret1 == Top of modified IPA range
*/