From b32a1dfd3d85ff80c55b98350553312792294937 Mon Sep 17 00:00:00 2001 From: Jani Paalijarvi Date: Wed, 5 Jun 2024 12:20:53 +0300 Subject: [PATCH] risc-v/mpfs: Add error handling for PMP conf Check return value of mpfs_board_pmp_setup() and jump to mpfs_board_pmp_error() in case of error. Signed-off-by: Jani Paalijarvi --- arch/risc-v/src/mpfs/Kconfig | 3 ++- arch/risc-v/src/mpfs/mpfs_entrypoints.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/risc-v/src/mpfs/Kconfig b/arch/risc-v/src/mpfs/Kconfig index c84284c533d..290332d1d5b 100644 --- a/arch/risc-v/src/mpfs/Kconfig +++ b/arch/risc-v/src/mpfs/Kconfig @@ -52,7 +52,8 @@ config MPFS_BOARD_PMP default n ---help--- If true, the board must provide "mpfs_board_pmp_setup" for PMP - configuration. If false, set ALL memory accessible for every + configuration and "mpfs_board_pmp_error" for PMP error handling. + If false, set ALL memory accessible for every configured HART. Only the bootloader should do this. config MPFS_OPENSBI diff --git a/arch/risc-v/src/mpfs/mpfs_entrypoints.c b/arch/risc-v/src/mpfs/mpfs_entrypoints.c index 2480253f783..52c8415e4c0 100644 --- a/arch/risc-v/src/mpfs/mpfs_entrypoints.c +++ b/arch/risc-v/src/mpfs/mpfs_entrypoints.c @@ -107,6 +107,7 @@ void mpfs_jump_to_app(void) "la sp, g_mpfs_boot_stacks\n" /* Stack area base */ "add sp, sp, t0\n" /* Set stack pointer */ "call mpfs_board_pmp_setup\n" /* Run PMP configuration */ + "bne a0, x0, mpfs_board_pmp_error\n" /* If ret != 0, jump to errhan */ "csrr a0, mhartid\n" /* Restore hartid */ #else "li t0, -1\n" /* Open the whole SoC */