From cf2f0c3a9791f54f371ca67799394cbfa3ad9193 Mon Sep 17 00:00:00 2001 From: Gurumoorthy Santhakumar Date: Wed, 7 Feb 2024 16:18:34 +0530 Subject: [PATCH] ipqsoc: Skip reset in crash dump path. Skip reset in crash dump path which give access to user to perform secure authentication. in crash path, bootipq cmd only authenticate kernel/rootfs. booting to kernel is restircted. Enable CONFIG_SKIP_RESET to skip reset in crashdump path. Change-Id: I28fdd4dc6475d4d26b20a87aa039cef165db1375 Signed-off-by: Gurumoorthy Santhakumar --- arch/arm/cpu/armv7/qca/common/Kconfig | 4 ++++ .../include/asm/arch-qca-common/qca_common.h | 1 + board/qca/arm/common/cmd_bootqca.c | 11 +++++++++++ board/qca/arm/common/crashdump.c | 19 ++++++++++++++----- common/autoboot.c | 4 ++-- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/arch/arm/cpu/armv7/qca/common/Kconfig b/arch/arm/cpu/armv7/qca/common/Kconfig index 14e2731af8..84a2cd57f9 100644 --- a/arch/arm/cpu/armv7/qca/common/Kconfig +++ b/arch/arm/cpu/armv7/qca/common/Kconfig @@ -1,2 +1,6 @@ config QCA_COMMON bool "QCA Common IPs" + +config SKIP_RESET + bool "Skip reset after crash dump" + default n diff --git a/arch/arm/include/asm/arch-qca-common/qca_common.h b/arch/arm/include/asm/arch-qca-common/qca_common.h index b1b5df2a1c..4c5d706e26 100644 --- a/arch/arm/include/asm/arch-qca-common/qca_common.h +++ b/arch/arm/include/asm/arch-qca-common/qca_common.h @@ -109,6 +109,7 @@ void set_flash_secondary_type(qca_smem_flash_info_t *); void dump_func(unsigned int dump_level); int do_dumpqca_flash_data(const char *); int do_dumpqca_usb_data(unsigned int dump_level); +void crashdump_exit(void); int apps_iscrashed(void); int ipq_read_tcsr_boot_misc(void); int set_uuid_bootargs(char *boot_args, char *part_name, int buflen, bool gpt_flag); diff --git a/board/qca/arm/common/cmd_bootqca.c b/board/qca/arm/common/cmd_bootqca.c index b6a52c05b5..cc7d169883 100644 --- a/board/qca/arm/common/cmd_bootqca.c +++ b/board/qca/arm/common/cmd_bootqca.c @@ -757,6 +757,12 @@ static int do_boot_signedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const a } #endif } + +#ifdef CONFIG_SKIP_RESET + if (apps_iscrashed()) + return 1; +#endif + /* * This sys call will switch the CE1 channel to ADM usage * so that HLOS can use it. @@ -940,6 +946,11 @@ static int do_boot_unsignedimg(cmd_tbl_t *cmdtp, int flag, int argc, char *const } } +#ifdef CONFIG_SKIP_RESET + if (apps_iscrashed()) + return 1; +#endif + if (ret < 0 || boot_os(1, arg) != CMD_RET_SUCCESS) { #ifdef CONFIG_USB_XHCI_IPQ ipq_board_usb_init(); diff --git a/board/qca/arm/common/crashdump.c b/board/qca/arm/common/crashdump.c index 629c6f6a1b..ac6460628a 100644 --- a/board/qca/arm/common/crashdump.c +++ b/board/qca/arm/common/crashdump.c @@ -179,6 +179,15 @@ __weak int scm_set_boot_addr(bool enable_sec_core) return -1; } +__weak void crashdump_exit(void) +{ +#ifdef CONFIG_SKIP_RESET + run_command("bootipq", 0); +#else + reset_board(); +#endif +} + static int krait_release_secondary(void) { writel(0xa4, CPU1_APCS_SAW2_VCTL); @@ -971,7 +980,7 @@ void dump_func(unsigned int dump_level) printf("Using serverip from env %s\n", serverip); } else { printf("\nServer ip not found, run dhcp or configure\n"); - goto reset; + goto exit; } printf("Trying to ping server.....\n"); snprintf(runcmd, sizeof(runcmd), "ping %s", serverip); @@ -985,11 +994,11 @@ void dump_func(unsigned int dump_level) } if (ping_status != 1) { printf("Ping failed\n"); - goto reset; + goto exit; } if (do_dumpqca_data(dump_level) == CMD_RET_FAILURE) printf("Crashdump saving failed!\n"); - goto reset; + goto exit; } else { etime = get_timer_masked() + (10 * CONFIG_SYS_HZ); printf("\nHit any key within 10s to stop dump activity..."); @@ -1012,8 +1021,8 @@ void dump_func(unsigned int dump_level) /* reset the system, some images might not be loaded * when crashmagic is found */ -reset: - reset_board(); +exit: + crashdump_exit(); } #ifdef CONFIG_MTD_DEVICE diff --git a/common/autoboot.c b/common/autoboot.c index 806ca2a234..a2de120355 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -386,13 +386,13 @@ void autoboot_command(const char *s) if (s) { if (strncmp(s, "1", sizeof("1"))) { printf("\nError: Invalid variable dump_minimal \n"); - reset_board(); + crashdump_exit(); } } } if (s) { do_dumpqca_minimal_data(s); - reset_board(); + crashdump_exit(); } else dump_func(FULL_DUMP);