feat(rmm): add 'hash_algo' RSI_REALM_CONFIG success condition
This patch makes the following changes as per
RMM Specification 1.0-eac2:
- adds 'enum hash_algo hash_algo' in 'realm_info'
structure set in smc_rec_create() function;
- defines RsiHashAlgorithm type macros
RSI_HASH_SHA_256 and RSI_HASH_SHA_512;
- adds 'hash_algo' field in 'rsi_realm_config'
structure of RsiRealmConfig type, which gets
set in handle_rsi_realm_config() as a success
condition of RSI_REALM_CONFIG command.
Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com>
Change-Id: Ib4f85af706f51560325a1993f1171b1b858020e2
diff --git a/lib/realm/include/rec.h b/lib/realm/include/rec.h
index 8140af1..34cc31b 100644
--- a/lib/realm/include/rec.h
+++ b/lib/realm/include/rec.h
@@ -178,6 +178,7 @@
struct granule *g_rd;
bool pmu_enabled;
unsigned int pmu_num_ctrs;
+ enum hash_algo hash_algo;
bool sve_enabled;
uint8_t sve_vq;
} realm_info;
diff --git a/lib/smc/include/smc-rsi.h b/lib/smc/include/smc-rsi.h
index ecc0acc..483b25d 100644
--- a/lib/smc/include/smc-rsi.h
+++ b/lib/smc/include/smc-rsi.h
@@ -118,9 +118,16 @@
*/
#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 */
- SET_MEMBER_RSI(unsigned long ipa_width, 0, 0x1000); /* Offset 0 */
+ SET_MEMBER_RSI(unsigned long ipa_width, 0, 8); /* Offset 0 */
+ /* Hash algorithm */
+ SET_MEMBER_RSI(unsigned long hash_algo, 8, 0x1000); /* Offset 8 */
};
#endif /* __ASSEMBLER__ */
diff --git a/lib/smc/src/smc-rmi-offsets.c b/lib/smc/src/smc-rmi-offsets.c
index 3b47ce9..5b9e05a 100644
--- a/lib/smc/src/smc-rmi-offsets.c
+++ b/lib/smc/src/smc-rmi-offsets.c
@@ -4,6 +4,7 @@
*/
#include <smc-rmi.h>
+#include <smc-rsi.h>
#include <stddef.h>
COMPILER_ASSERT(sizeof(struct rmi_realm_params) == 0x1000);
@@ -34,7 +35,6 @@
COMPILER_ASSERT(offsetof(struct rmi_rec_entry, gicv3_hcr) == 0x300);
COMPILER_ASSERT(offsetof(struct rmi_rec_entry, gicv3_lrs) == 0x308);
-
COMPILER_ASSERT(offsetof(struct rmi_rec_exit, exit_reason) == 0);
COMPILER_ASSERT(offsetof(struct rmi_rec_exit, esr) == 0x100);
COMPILER_ASSERT(offsetof(struct rmi_rec_exit, far) == 0x108);
diff --git a/lib/smc/src/smc-rsi-offsets.c b/lib/smc/src/smc-rsi-offsets.c
index cad29bce..06de173 100644
--- a/lib/smc/src/smc-rsi-offsets.c
+++ b/lib/smc/src/smc-rsi-offsets.c
@@ -9,6 +9,7 @@
COMPILER_ASSERT(sizeof(struct rsi_realm_config) == 0x1000);
COMPILER_ASSERT(offsetof(struct rsi_realm_config, ipa_width) == 0);
+COMPILER_ASSERT(offsetof(struct rsi_realm_config, hash_algo) == 8);
COMPILER_ASSERT(sizeof(struct rsi_host_call) == 0x100);
COMPILER_ASSERT(offsetof(struct rsi_host_call, imm) == 0);
diff --git a/runtime/rmi/rec.c b/runtime/rmi/rec.c
index 52ff304..abe58e2 100644
--- a/runtime/rmi/rec.c
+++ b/runtime/rmi/rec.c
@@ -282,11 +282,11 @@
rec->realm_info.s2_starting_level = realm_rtt_starting_level(rd);
rec->realm_info.g_rtt = rd->s2_ctx.g_rtt;
rec->realm_info.g_rd = g_rd;
- rec->realm_info.sve_enabled = rd->sve_enabled;
- rec->realm_info.sve_vq = rd->sve_vq;
-
rec->realm_info.pmu_enabled = rd->pmu_enabled;
rec->realm_info.pmu_num_ctrs = rd->pmu_num_ctrs;
+ rec->realm_info.hash_algo = rd->algorithm;
+ rec->realm_info.sve_enabled = rd->sve_enabled;
+ rec->realm_info.sve_vq = rd->sve_vq;
rec_params_measure(rd, &rec_params);
diff --git a/runtime/rsi/config.c b/runtime/rsi/config.c
index 63ec51c..800ef2a 100644
--- a/runtime/rsi/config.c
+++ b/runtime/rsi/config.c
@@ -46,6 +46,11 @@
/* Populate config structure */
config->ipa_width = rec->realm_info.ipa_bits;
+ if (rec->realm_info.hash_algo == HASH_SHA_256) {
+ config->hash_algo = RSI_HASH_SHA_256;
+ } else {
+ config->hash_algo = RSI_HASH_SHA_512;
+ }
/* Unmap Realm data granule */
buffer_unmap(config);