feat(realm): add support for RSI_IPA_STATE_GET/SET
Add support for realm API rsi_ipa_state_set, rsi_ipa_state_get
Add testcase for following
* Realm calls rsi_ipa_state_set to change RIPAS=RAM,
* Host accepts and call RMI_RTT_SET_RIPAS
* Realm verifies RIPAS change was successful
Change-Id: I4da6c7d25faa62afde1d0f682510bac6c8445821
Signed-off-by: Shruti Gupta <shruti.gupta@arm.com>
diff --git a/realm/realm_payload_main.c b/realm/realm_payload_main.c
index 563c643..9b2be83 100644
--- a/realm/realm_payload_main.c
+++ b/realm/realm_payload_main.c
@@ -20,7 +20,6 @@
static fpu_state_t rl_fpu_state_write;
static fpu_state_t rl_fpu_state_read;
-
/*
* This function reads sleep time in ms from shared buffer and spins PE
* in a loop for that time period.
@@ -61,6 +60,47 @@
return true;
}
+bool test_realm_set_ripas(void)
+{
+ u_register_t ret, base, new_base, top;
+ rsi_ripas_respose_type response;
+ rsi_ripas_type ripas;
+
+ base = realm_shared_data_get_my_host_val(HOST_ARG1_INDEX);
+ top = realm_shared_data_get_my_host_val(HOST_ARG2_INDEX);
+ realm_printf("base=0x%lx top =0x%lx\n", base, top);
+ ret = rsi_ipa_state_get(base, &ripas);
+ if (ripas != RSI_EMPTY) {
+ return false;
+ }
+
+ ret = rsi_ipa_state_set(base, top, RSI_RAM,
+ RSI_NO_CHANGE_DESTROYED, &new_base, &response);
+ if (ret != RSI_SUCCESS || response != RSI_ACCEPT) {
+ return false;
+ }
+ while (new_base < top) {
+ realm_printf("new_base=0x%lx top =0x%lx\n", new_base, top);
+ ret = rsi_ipa_state_set(new_base, top, RSI_RAM,
+ RSI_NO_CHANGE_DESTROYED, &new_base, &response);
+ if (ret != RSI_SUCCESS || response != RSI_ACCEPT) {
+ realm_printf("rsi_ipa_state_set failed\n");
+ return false;
+ }
+ }
+
+ /* Verify that RIAS has changed for range base-top. */
+ for (unsigned int i = 0U; (base + (PAGE_SIZE * i) < top); i++) {
+ ret = rsi_ipa_state_get(base + (PAGE_SIZE * i), &ripas);
+ if (ret != RSI_SUCCESS || ripas != RSI_RAM) {
+ realm_printf("rsi_ipa_state_get failed base=0x%lx, ripas=0x%x\n",
+ base + (PAGE_SIZE * i), ripas);
+ return false;
+ }
+ }
+ return true;
+}
+
/*
* This is the entry function for Realm payload, it first requests the shared buffer
* IPA address from Host using HOST_CALL/RSI, it reads the command to be executed,
@@ -122,6 +162,9 @@
test_succeed = !fpu_state_compare(&rl_fpu_state_write,
&rl_fpu_state_read);
break;
+ case REALM_SET_RIPAS_CMD:
+ test_succeed = test_realm_set_ripas();
+ break;
case REALM_SVE_RDVL:
test_succeed = test_realm_sve_rdvl();
break;