feat(rmm-eac4): change validate_realm_params()
Permit number of PMU counters, breakpoints and
watchpoints to be less than number supported by
the implementation as per RMM Specification 1.0-eac4.
If number of PMU counters is 0 and FEAT_HPMN0 is
not implemnted, return FALSE, otherwise assign
requested number to the 1st range by setting
MDCR_EL2.HPMN field.
This patch also fixes violations of MISRA C:2012
Rules 10.3, 12.1 and 18.4 in realm.c.
Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com>
Change-Id: I8cf69752527df8a6dddef3e395d86a3e9d30109d
diff --git a/lib/arch/include/arch_features.h b/lib/arch/include/arch_features.h
index 386b2ac..d846809 100644
--- a/lib/arch/include/arch_features.h
+++ b/lib/arch/include/arch_features.h
@@ -100,6 +100,17 @@
read_id_aa64dfr0_el1());
}
+/*
+ * Check if FEAT_HPMN0 is implemented.
+ * ID_AA64DFR0_EL1.HPMN0, bits [63:60]:
+ * 0b0001: Setting MDCR_EL2.HPMN to zero has defined behavior
+ */
+static inline bool is_feat_hpmn0_present(void)
+{
+ return (EXTRACT(ID_AA64DFR0_EL1_HPMN0,
+ read_id_aa64dfr0_el1()) == 1UL);
+}
+
unsigned int arch_feat_get_pa_width(void);
#endif /* ARCH_FEATURES_H */