test(realm): add test for enabling pmu with multiple rec
Test creates realm with less number of pmu counters than available
Test verifies that only programmed num of pmu counters are available in realm
Change-Id: I479dd8949950357b9814576b1b6cef142d21c75f
Signed-off-by: Shruti Gupta <shruti.gupta@arm.com>
diff --git a/realm/include/realm_tests.h b/realm/include/realm_tests.h
index 3016a4d..b58949b 100644
--- a/realm/include/realm_tests.h
+++ b/realm/include/realm_tests.h
@@ -9,6 +9,7 @@
#define REALM_TESTS_H
bool test_pmuv3_cycle_works_realm(void);
+bool test_pmuv3_counter(void);
bool test_pmuv3_event_works_realm(void);
bool test_pmuv3_rmm_preserves(void);
bool test_pmuv3_overflow_interrupt(void);
diff --git a/realm/realm_payload_main.c b/realm/realm_payload_main.c
index ce25f43..5eec5b8 100644
--- a/realm/realm_payload_main.c
+++ b/realm/realm_payload_main.c
@@ -252,6 +252,9 @@
case REALM_PMU_CYCLE:
test_succeed = test_pmuv3_cycle_works_realm();
break;
+ case REALM_PMU_COUNTER:
+ test_succeed = test_pmuv3_counter();
+ break;
case REALM_PMU_EVENT:
test_succeed = test_pmuv3_event_works_realm();
break;
diff --git a/realm/realm_pmuv3.c b/realm/realm_pmuv3.c
index 3ae597d..0d4782a 100644
--- a/realm/realm_pmuv3.c
+++ b/realm/realm_pmuv3.c
@@ -162,6 +162,21 @@
return false;
}
+/* Test if max counter available is same as that programmed by host */
+bool test_pmuv3_counter(void)
+{
+ uint64_t num_cnts, num_cnts_host;
+
+ num_cnts_host = realm_shared_data_get_my_host_val(HOST_ARG1_INDEX);
+ num_cnts = GET_PMU_CNT;
+ realm_printf("CPU=%u num_cnts=%lu num_cnts_host=%lu\n", read_mpidr_el1() & MPID_MASK,
+ num_cnts, num_cnts_host);
+ if (num_cnts == num_cnts_host) {
+ return true;
+ }
+ return false;
+}
+
/*
* Try an event counter with some NOPs to see if it works.
*/
@@ -170,7 +185,7 @@
u_register_t evcounter_start;
u_register_t evcounter_end;
- if (GET_CNT_NUM == 0) {
+ if (GET_PMU_CNT == 0) {
realm_printf("no event counters implemented\n");
return false;
}
@@ -208,7 +223,7 @@
u_register_t ctr_end[MAX_COUNTERS] = {0};
u_register_t ctr_cfg_end[MAX_COUNTERS] = {0};
u_register_t pmu_cfg_end[3];
- unsigned int impl_ev_ctrs = GET_CNT_NUM;
+ unsigned int impl_ev_ctrs = GET_PMU_CNT;
realm_printf("testing %u event counters\n", impl_ev_ctrs);