fix(rmm): replace ARRAY_READ/WRITE macros with direct read/write
In sysregs.c 'rt' index of reads/writes from/to 'rec->regs[rt]'
is being checked for maximum possible value of 31 corresonding
to XZR and all these cases are handled safely, so there is no
need for using ARRAY_READ/WRITE macros which cause performance
deterioration.
This patch replaces usage of ARRAY_READ/WRITE macros with direct
read and writes commands and renames those macros to
SAFE_ARRAY_READ/WRITE.
The patch removes 'esr_sysreg_rt()' inline function
defined in esr.h and replaces calls to it with modified
ESR_EL2_SYSREG_ISS_RT macro.
Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com>
Change-Id: Ib2d9996ef380ffb9cdcafa320ded9fa991d9a378
diff --git a/lib/arch/include/arch.h b/lib/arch/include/arch.h
index a67baa4..5db3d08 100644
--- a/lib/arch/include/arch.h
+++ b/lib/arch/include/arch.h
@@ -882,10 +882,8 @@
#define ESR_EL2_SYSREG_IS_WRITE(esr) (!((esr) & ESR_EL2_SYSREG_DIRECTION))
#define ESR_IL(esr) ((esr) & ESR_EL2_IL_MASK)
-#define ESR_ISS(esr) ((esr) & ESR_EL2_ISS_MASK)
-#define ESR_EL2_SYSREG_ISS_RT(esr) \
- ((ESR_ISS(esr) & ESR_EL2_SYSREG_TRAP_RT_MASK) >> ESR_EL2_SYSREG_TRAP_RT_SHIFT)
+#define ESR_EL2_SYSREG_ISS_RT(esr) EXTRACT(ESR_EL2_SYSREG_TRAP_RT, esr)
#define ICC_HPPIR1_EL1_INTID_SHIFT 0
#define ICC_HPPIR1_EL1_INTID_WIDTH 24
diff --git a/lib/arch/include/esr.h b/lib/arch/include/esr.h
index a88b71c..da34f45 100644
--- a/lib/arch/include/esr.h
+++ b/lib/arch/include/esr.h
@@ -66,13 +66,4 @@
}
}
-/*
- * For a trapped msr/mrs sysreg access, get the transfer register in the
- * ESR_EL2.
- */
-static inline unsigned int esr_sysreg_rt(unsigned long esr)
-{
- return EXTRACT(ESR_EL2_SYSREG_TRAP_RT, esr);
-}
-
#endif /* ESR_H */
diff --git a/lib/common/include/utils_def.h b/lib/common/include/utils_def.h
index 2dc310a..604cd6e 100644
--- a/lib/common/include/utils_def.h
+++ b/lib/common/include/utils_def.h
@@ -85,7 +85,7 @@
* _i: index
* _v: variable/value to write
*/
-#define ARRAY_READ(_a, _i, _v) \
+#define SAFE_ARRAY_READ(_a, _i, _v) \
({ \
CHECK_ARRAY_TYPE(_a, _v); \
if (_i >= ARRAY_SIZE(_a)) { \
@@ -94,7 +94,7 @@
_v = _a[_i]; \
})
-#define ARRAY_WRITE(_a, _i, _v) \
+#define SAFE_ARRAY_WRITE(_a, _i, _v) \
({ \
CHECK_ARRAY_TYPE(_a, _v); \
if (_i >= ARRAY_SIZE(_a)) { \