fix(esp_hw_support): update memory pointer checks for SPM support

This commit is contained in:
wuzhenghui
2026-07-10 17:18:42 +08:00
parent e11c30437a
commit a3515f31fb
2 changed files with 16 additions and 6 deletions
@@ -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
;
}
@@ -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.