refactor(plat/common): use arch specific shared buf va and pa
The fake_host arch needs to use the same address as the allocated
memory for access. The xlat_table address translation is not relevant
for fake_host. Hence this patch allows to abstract the va
when initializing the rmm-el3-ifc and the pa when creating the xlat
tables for shared buffer region. This also solves an issue wherein
sometimes the shared buf address collided with the dummy values used
for mmap regions on fake_host thus failing the initialization.
The patch also moves the dummy symbols for fake_host regions from
import_sym.h to plat_cmn_arch.h.
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Change-Id: I70b9172573855e3fcf3508acabf3ee87ea19c57f
diff --git a/plat/common/src/plat_common_init.c b/plat/common/src/plat_common_init.c
index 93664cd..d7f7710 100644
--- a/plat/common/src/plat_common_init.c
+++ b/plat/common/src/plat_common_init.c
@@ -10,7 +10,7 @@
#include <debug.h>
#include <errno.h>
#include <gic.h>
-#include <plat_import_sym.h>
+#include <plat_cmn_arch.h>
#include <rmm_el3_ifc.h>
#include <sizes.h>
#include <stdint.h>
@@ -18,6 +18,14 @@
#include <xlat_contexts.h>
#include <xlat_tables.h>
+
+IMPORT_SYM(uintptr_t, rmm_text_start, RMM_CODE_START);
+IMPORT_SYM(uintptr_t, rmm_text_end, RMM_CODE_END);
+IMPORT_SYM(uintptr_t, rmm_ro_start, RMM_RO_START);
+IMPORT_SYM(uintptr_t, rmm_ro_end, RMM_RO_END);
+IMPORT_SYM(uintptr_t, rmm_rw_start, RMM_RW_START);
+IMPORT_SYM(uintptr_t, rmm_rw_end, RMM_RW_END);
+
/*
* Memory map REGIONS used for the RMM runtime (static mappings)
*/
@@ -41,6 +49,13 @@
MT_RW_DATA | MT_REALM)
/*
+ * Leave an invalid page between the end of RMM memory and the beginning
+ * of the shared buffer VA. This will help to detect any memory access
+ * underflow by RMM.
+ */
+#define RMM_SHARED_BUFFER_START (RMM_RW_END + SZ_4K)
+
+/*
* Some of the fields for the RMM_SHARED region will be populated
* at runtime.
*/
@@ -74,8 +89,8 @@
*
* This function should only be invoked once during cold boot
* and is expected to setup architecture and platform components
- * common for all PEs executing RMM.
- * The xlat tables and GIC driver are initialized by this function.
+ * common for all PEs executing RMM. The rmm_el3_ifc, the xlat tables
+ * and GIC driver are initialized by this function.
*/
int plat_cmn_setup(unsigned long x0, unsigned long x1,
unsigned long x2, unsigned long x3,
@@ -85,11 +100,6 @@
int ret;
unsigned int plat_offset, cmn_offset;
- (void)x0;
- (void)x1;
- (void)x2;
- (void)x3;
-
/* Common regions sorted by ascending VA */
struct xlat_mmap_region regions[COMMON_REGIONS] = {
RMM_CODE,
@@ -106,8 +116,16 @@
return -EINVAL;
}
+ /* Initialize the RMM <-> EL3 interface */
+ ret = rmm_el3_ifc_init(x0, x1, x2, x3, get_shared_buf_va(x3));
+ if (ret != 0) {
+ ERROR("%s (%u): Failed to initialize the RMM EL3 Interface\n",
+ __func__, __LINE__);
+ return ret;
+ }
+
/* Setup the parameters of the shared area */
- regions[3].base_pa = rmm_el3_ifc_get_shared_buf_pa();
+ regions[3].base_pa = get_shared_buf_pa();
regions[3].size = rmm_el3_ifc_get_shared_buf_size();
plat_offset = COMMON_REGIONS;