feat(qemu-sbsa): relocate DT after the RMM when RME is enabled

When RME is enabled, (1) the RMM is installed at the base of system RAM,
(2) the base of the system RAM is shifted upward, after the RMM and (3)
the device tree is relocated to the new system RAM base.

This patch relocates the device tree to the new system RAM base before
the RMM is installed in RAM.  From there, other accesses to the device
tree are using the new location.

Change-Id: I0cb4e060ca33a11becd78fe48fab4dc76f0b484b
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
This commit is contained in:
Mathieu Poirier 2024-10-10 15:07:49 -06:00
parent 26da60e2a0
commit 17af9597e2
5 changed files with 29 additions and 2 deletions

View file

@ -8,6 +8,7 @@ include lib/libfdt/libfdt.mk
include common/fdt_wrappers.mk
PLAT_INCLUDES := -Iinclude/plat/arm/common/ \
-I${PLAT_QEMU_COMMON_PATH}/ \
-I${PLAT_QEMU_COMMON_PATH}/include \
-I${PLAT_QEMU_PATH}/include \
-Iinclude/common/tbbr

View file

@ -81,8 +81,9 @@ static void update_dt(void)
#endif
int ret;
void *fdt = (void *)(uintptr_t)ARM_PRELOADED_DTB_BASE;
void *dst = plat_qemu_dt_runtime_address();
ret = fdt_open_into(fdt, fdt, PLAT_QEMU_DT_MAX_SIZE);
ret = fdt_open_into(fdt, dst, PLAT_QEMU_DT_MAX_SIZE);
if (ret < 0) {
ERROR("Invalid Device Tree at %p: error %d\n", fdt, ret);
return;

View file

@ -332,3 +332,25 @@ int plat_rmmd_load_manifest(struct rmm_manifest *manifest)
return 0;
}
#endif /* ENABLE_RME */
/**
* plat_qemu_dt_runtime_address() - Get the final DT location in RAM
*
* When support is enabled on SBSA, the device tree is relocated from its
* original place at the beginning of the NS RAM to after the RMM. This
* function returns the address of the final location in RAM of the device
* tree. See function update_dt() in qemu_bl2_setup.c
*
* Return: The address of the final location in RAM of the device tree
*/
#if (ENABLE_RME && PLAT_qemu_sbsa)
void *plat_qemu_dt_runtime_address(void)
{
return (void *)(uintptr_t)PLAT_QEMU_DT_BASE;
}
#else
void *plat_qemu_dt_runtime_address(void)
{
return (void *)(uintptr_t)ARM_PRELOADED_DTB_BASE;
}
#endif /* (ENABLE_RME && PLAT_qemu_sbsa) */

View file

@ -16,6 +16,7 @@ int qemu_io_register_sp_pkg(const char *name, const char *uuid,
uintptr_t load_addr);
unsigned int plat_qemu_calc_core_pos(u_register_t mpidr);
const mmap_region_t *plat_qemu_get_mmap(void);
void *plat_qemu_dt_runtime_address(void);
void qemu_console_init(void);

View file

@ -11,6 +11,8 @@
#include <sbsa_platform.h>
#include "qemu_private.h"
/* default platform version is 0.0 */
static int platform_version_major;
static int platform_version_minor;
@ -278,7 +280,7 @@ void sbsa_platform_init(void)
{
/* Read DeviceTree data before MMU is enabled */
void *dtb = (void *)(uintptr_t)ARM_PRELOADED_DTB_BASE;
void *dtb = plat_qemu_dt_runtime_address();
int err;
err = fdt_open_into(dtb, dtb, PLAT_QEMU_DT_MAX_SIZE);