From a3515f31fbc9a0348d8e3a0640b1f3c486849c40 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Fri, 10 Jul 2026 12:38:47 +0800 Subject: [PATCH] fix(esp_hw_support): update memory pointer checks for SPM support --- .../esp_hw_support/include/esp_memory_utils.h | 7 +++++-- .../espcoredump/src/port/riscv/core_dump_port.c | 15 +++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/components/esp_hw_support/include/esp_memory_utils.h b/components/esp_hw_support/include/esp_memory_utils.h index deee9c9d725..f7dcd40b0e9 100644 --- a/components/esp_hw_support/include/esp_memory_utils.h +++ b/components/esp_hw_support/include/esp_memory_utils.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2010-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2010-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -400,7 +400,10 @@ inline static bool esp_stack_ptr_is_sane(uint32_t sp) || esp_stack_ptr_in_extram(sp) #endif #if CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP - || esp_ptr_in_rtc_dram_fast((void*) sp) + || (esp_ptr_in_rtc_dram_fast((void *)sp) && ((sp & 0xF) == 0)) +#endif +#if SOC_MEM_SPM_SUPPORTED + || (esp_ptr_in_spm((void *)sp) && ((sp & 0xF) == 0)) #endif ; } diff --git a/components/espcoredump/src/port/riscv/core_dump_port.c b/components/espcoredump/src/port/riscv/core_dump_port.c index 60a2ac39546..ddce759f40f 100644 --- a/components/espcoredump/src/port/riscv/core_dump_port.c +++ b/components/espcoredump/src/port/riscv/core_dump_port.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -37,7 +37,7 @@ const static char TAG[] __attribute__((unused)) = "esp_core_dump_port"; /** * Union representing the registers of the CPU as they will be written * in the core dump. - * Registers can be adressed with their names thanks to the structure, or as + * Registers can be addressed with their names thanks to the structure, or as * an array of 32 words. */ #define RISCV_GP_REGS_COUNT 32 @@ -227,6 +227,9 @@ static inline bool esp_core_dump_task_stack_end_is_sane(uint32_t sp) #endif #if CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP || esp_ptr_in_rtc_dram_fast((void*) sp) +#endif +#if SOC_MEM_SPM_SUPPORTED + || esp_ptr_in_spm((void *)sp) #endif ; } @@ -311,11 +314,15 @@ bool esp_core_dump_mem_seg_is_sane(uint32_t addr, uint32_t sz) || (esp_ptr_in_rtc_slow((void *)addr) && esp_ptr_in_rtc_slow((void *)(addr + sz - 1))) || (esp_ptr_in_rtc_dram_fast((void *)addr) && esp_ptr_in_rtc_dram_fast((void *)(addr + sz - 1))) || (esp_ptr_external_ram((void *)addr) && esp_ptr_external_ram((void *)(addr + sz - 1))) - || (esp_ptr_in_iram((void *)addr) && esp_ptr_in_iram((void *)(addr + sz - 1))); + || (esp_ptr_in_iram((void *)addr) && esp_ptr_in_iram((void *)(addr + sz - 1))) +#if SOC_MEM_SPM_SUPPORTED + || (esp_ptr_in_spm((void *)addr) && esp_ptr_in_spm((void *)(addr + sz - 1))) +#endif + ; } /** - * Get the task's registers dump when the panic occured. + * Get the task's registers dump when the panic occurred. * Returns the size, in bytes, of the data pointed by reg_dumps. * The data pointed by reg_dump are allocated statically, thus, they must be * used (or copied) before calling this function again.