From ac2e428c4be6bb876b160643984617911d60a5e6 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Tue, 25 Mar 2025 16:43:25 -0700 Subject: [PATCH] platform: rzfive: Call andes_pma_setup_regions() only during cold boot This function accesses the FDT blob, which means it is only valid to call during cold boot, before a lower privilege level has an opportunity to clobber that memory. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel Link: https://lore.kernel.org/r/20250325234342.711447-3-samuel.holland@sifive.com Signed-off-by: Anup Patel --- platform/generic/renesas/rzfive/rzfive.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/generic/renesas/rzfive/rzfive.c b/platform/generic/renesas/rzfive/rzfive.c index 59084c41..db523088 100644 --- a/platform/generic/renesas/rzfive/rzfive.c +++ b/platform/generic/renesas/rzfive/rzfive.c @@ -27,8 +27,16 @@ static const struct andes_pma_region renesas_rzfive_pma_regions[] = { static int renesas_rzfive_final_init(bool cold_boot, void *fdt, const struct fdt_match *match) { - return andes_pma_setup_regions(fdt, renesas_rzfive_pma_regions, - array_size(renesas_rzfive_pma_regions)); + int rc; + + if (cold_boot) { + rc = andes_pma_setup_regions(fdt, renesas_rzfive_pma_regions, + array_size(renesas_rzfive_pma_regions)); + if (rc) + return rc; + } + + return 0; } static int renesas_rzfive_early_init(bool cold_boot, const void *fdt,