Merge "test(realm): add test for validating RTT calls"
diff --git a/tftf/tests/runtime_services/realm_payload/host_realm_lpa2_tests.c b/tftf/tests/runtime_services/realm_payload/host_realm_lpa2_tests.c
index 34c684c..9a6341d 100644
--- a/tftf/tests/runtime_services/realm_payload/host_realm_lpa2_tests.c
+++ b/tftf/tests/runtime_services/realm_payload/host_realm_lpa2_tests.c
@@ -80,6 +80,62 @@
 }
 
 /*
+ * @Test_Aim@ Create a Realm with LPA2 disabled but FEAT_LPA2 present
+ * on the platform.
+ * Test that RMI_RTT_MAP_UNPROTECTED and RMI_RTT_CREATE commands fails if PA >= 48 bits
+ */
+test_result_t host_test_data_bound_non_lpa2_realm_on_lpa2plat(void)
+{
+	u_register_t rec_flag[1] = {RMI_RUNNABLE};
+	struct realm realm;
+	u_register_t ret, base, base_ipa;
+	test_result_t result = TEST_RESULT_FAIL;
+
+	SKIP_TEST_IF_RME_NOT_SUPPORTED_OR_RMM_IS_TRP();
+
+	if (is_feat_52b_on_4k_2_supported() == false) {
+		return TEST_RESULT_SKIPPED;
+	}
+
+	if (!host_create_activate_realm_payload(&realm, (u_register_t)REALM_IMAGE_BASE,
+			INPLACE(RMI_FEATURE_REGISTER_0_S2SZ, 48UL),
+			RTT_MIN_LEVEL, rec_flag, 1U)) {
+		return TEST_RESULT_FAIL;
+	}
+
+	/* Can choose any unprotected IPA adr, TFTF_BASE chosen for convenience */
+	base = TFTF_BASE;
+	base = base | (1UL << 48UL);
+
+	ret = host_realm_map_unprotected(&realm, base, PAGE_SIZE);
+
+	if (ret == REALM_SUCCESS) {
+		ERROR("host_realm_map_unprotected should have failed\n");
+		goto destroy_realm;
+	}
+
+	base_ipa = base | (1UL <<
+			(EXTRACT(RMI_FEATURE_REGISTER_0_S2SZ, realm.rmm_feat_reg0) - 1UL));
+
+	ret = host_rmi_create_rtt_levels(&realm, base_ipa, RTT_MIN_LEVEL, 3);
+
+	if (ret == REALM_SUCCESS) {
+		ERROR("host_rmi_create_rtt_levels should have failed\n");
+		goto destroy_realm;
+	}
+
+	result = TEST_RESULT_SUCCESS;
+
+destroy_realm:
+	if (!host_destroy_realm(&realm)) {
+		ERROR("%s(): failed to destroy realm\n", __func__);
+		return TEST_RESULT_FAIL;
+	}
+
+	return result;
+}
+
+/*
  * @Test_Aim@ Test creating a Realm payload with LPA2 enabled on a platform
  * which does not implement FEAT_LPA2.
  * Realm creation must fail.
diff --git a/tftf/tests/tests-realm-payload.xml b/tftf/tests/tests-realm-payload.xml
index 0d2f7c9..36fc52b 100644
--- a/tftf/tests/tests-realm-payload.xml
+++ b/tftf/tests/tests-realm-payload.xml
@@ -124,6 +124,8 @@
 	  function="host_test_realm_no_lpa2_invalid_s2sz" />
 	  <testcase name="Test Realm creation with LPA2 disabled but FEAT_LPA2 present on platform"
 	  function="host_test_non_lpa2_realm_on_lpa2plat" />
+	  <testcase name="Test Data bound with LPA2 disabled but FEAT_LPA2 present on platform"
+	  function="host_test_data_bound_non_lpa2_realm_on_lpa2plat" />
 	  <testcase name="Test Realm creation with LPA2 enabled but FEAT_LPA2 absent on platform"
 	  function="host_test_lpa2_realm_on_non_lpa2plat" />
 	  <!-- Test cases related to Attestation -->