feat(fake_host): add stub for xlat_enable_mmu_el2
This patch adds a stub for xlat_enable_mmu_el2 for the
for fake_host architecture.
Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com>
Change-Id: I7bf846bb02ca65b292a33254574f420409735799
diff --git a/lib/xlat/CMakeLists.txt b/lib/xlat/CMakeLists.txt
index ab727b8..9484bcc 100644
--- a/lib/xlat/CMakeLists.txt
+++ b/lib/xlat/CMakeLists.txt
@@ -23,7 +23,10 @@
"src/xlat_tables_arch.c"
"src/xlat_contexts.c")
-if(NOT RMM_ARCH STREQUAL fake_host)
+if(RMM_ARCH STREQUAL fake_host)
+ target_sources(rmm-lib-xlat
+ PRIVATE "src/fake_host/enable_mmu.c")
+else()
target_sources(rmm-lib-xlat
PRIVATE "src/aarch64/enable_mmu.S")
endif()
diff --git a/lib/xlat/src/fake_host/enable_mmu.c b/lib/xlat/src/fake_host/enable_mmu.c
new file mode 100644
index 0000000..25bcaea
--- /dev/null
+++ b/lib/xlat/src/fake_host/enable_mmu.c
@@ -0,0 +1,12 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
+ */
+
+#include <arch_helpers.h>
+
+void xlat_enable_mmu_el2(void)
+{
+ write_hcr_el2(read_hcr_el2() | HCR_RW);
+ write_sctlr_el2(SCTLR_EL2_WXN | SCTLR_EL2_M);
+}
diff --git a/plat/host/common/src/host_utils.c b/plat/host/common/src/host_utils.c
index 99fc708..8b0b08e 100644
--- a/plat/host/common/src/host_utils.c
+++ b/plat/host/common/src/host_utils.c
@@ -173,6 +173,9 @@
/* SCTLR_EL2 is reset to zero */
ret = host_util_set_default_sysreg_cb("sctlr_el2", 0UL);
+ /* HCR_EL2 is reset to zero */
+ ret = host_util_set_default_sysreg_cb("hcr_el2", 0UL);
+
/* TPIDR_EL2 is reset to zero */
ret = host_util_set_default_sysreg_cb("tpidr_el2", 0UL);
diff --git a/plat/host/host_test/src/test_helpers.c b/plat/host/host_test/src/test_helpers.c
index fb8ecbd..97e24e4 100644
--- a/plat/host/host_test/src/test_helpers.c
+++ b/plat/host/host_test/src/test_helpers.c
@@ -14,6 +14,7 @@
#include <string.h>
#include <test_private.h>
#include <utest_exit.h>
+#include <xlat_tables.h>
/* Implemented in init.c and needed here */
void rmm_warmboot_main(void);
@@ -35,14 +36,6 @@
static uintptr_t callbacks[CB_IDS];
-/*
- * Function to emulate the turn on of the MMU for the fake_host architecture.
- */
-static void enable_fake_mmu(void)
-{
- write_sctlr_el2(SCTLR_EL2_WXN | SCTLR_EL2_M);
-}
-
static void start_primary_pe(void)
{
host_util_set_cpuid(0U);
@@ -59,7 +52,7 @@
* Enable the MMU. This is needed as some initialization code
* called by rmm_main() asserts that the mmu is enabled.
*/
- enable_fake_mmu();
+ xlat_enable_mmu_el2();
/*
* rmm_main() finishhes the warmboot path.
@@ -87,7 +80,7 @@
* Enable the MMU. This is needed to avoid assertions during boot up
* that would otherwise occur if the MMU is disabled.
*/
- enable_fake_mmu();
+ xlat_enable_mmu_el2();
/*
* Finalize the warmboot path.