feat(rme): update FEAT_MPAM tests on Realms
Currently, to test that accessing a FEAT_MPAM register from a Realm
causes an undefined abort injected back to the Realm, we only test
by accessing a single register.
This patches updates the test by trying to access all MPAM registers
from the Realm to validate that an undefined abort is taken to the
Realm for all the registers.
Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com>
Change-Id: I16c88d467eb2a49342694536a1c7b6358416dc34
diff --git a/include/lib/aarch64/arch.h b/include/lib/aarch64/arch.h
index 09835b5..2e2e1df 100644
--- a/include/lib/aarch64/arch.h
+++ b/include/lib/aarch64/arch.h
@@ -1335,6 +1335,7 @@
* Definitions for system register interface to MPAM
******************************************************************************/
#define MPAMIDR_EL1 S3_0_C10_C4_4
+#define MPAMSM_EL1 S3_0_C10_C5_3
#define MPAM2_EL2 S3_4_C10_C5_0
#define MPAMHCR_EL2 S3_4_C10_C4_0
#define MPAM3_EL3 S3_6_C10_C5_0
diff --git a/include/lib/aarch64/arch_helpers.h b/include/lib/aarch64/arch_helpers.h
index 42e104c..ed705bf 100644
--- a/include/lib/aarch64/arch_helpers.h
+++ b/include/lib/aarch64/arch_helpers.h
@@ -525,6 +525,7 @@
DEFINE_RENAME_SYSREG_RW_FUNCS(mpam2_el2, MPAM2_EL2)
DEFINE_RENAME_SYSREG_RW_FUNCS(mpamhcr_el2, MPAMHCR_EL2)
DEFINE_RENAME_SYSREG_WRITE_FUNC(mpamidr_el1, MPAMIDR_EL1)
+DEFINE_RENAME_SYSREG_WRITE_FUNC(mpamsm_el1, MPAMSM_EL1)
DEFINE_RENAME_SYSREG_WRITE_FUNC(mpam0_el1, MPAM0_EL1)
DEFINE_RENAME_SYSREG_WRITE_FUNC(mpam1_el1, MPAM1_EL1)
diff --git a/realm/realm_mpam.c b/realm/realm_mpam.c
index 913e451..e38d045 100644
--- a/realm/realm_mpam.c
+++ b/realm/realm_mpam.c
@@ -7,16 +7,27 @@
#include <arch_helpers.h>
#include <sync.h>
#include <realm_helpers.h>
+#include <utils_def.h>
/* Check if Realm gets undefined abort when it access MPAM registers */
bool test_realm_mpam_undef_abort(void)
{
+ void (*write_reg[])(u_register_t) = {write_mpam0_el1,
+ write_mpam1_el1,
+ write_mpamsm_el1,
+ write_mpamidr_el1};
+ unsigned int n_access = ARRAY_SIZE(write_reg);
+
realm_reset_undef_abort_count();
/* Install exception handler to catch undefined abort */
register_custom_sync_exception_handler(realm_sync_exception_handler);
- write_mpam0_el1(0UL);
+
+ for (unsigned int i = 0U; i < n_access; i++) {
+ write_reg[i](0UL);
+ }
+
unregister_custom_sync_exception_handler();
- return (realm_get_undef_abort_count() != 0UL);
+ return (realm_get_undef_abort_count() == (unsigned long)n_access);
}