From 7557ec0951ab991e0beb7f0c91ae2eb494ff92cf Mon Sep 17 00:00:00 2001 From: John Boiles Date: Tue, 20 May 2025 20:23:39 -0700 Subject: [PATCH] fix(memory-utils): Add _instruction_reserved_start/end to esp_psram_check_ptr_addr Adds missing range check that can be used when SPIRAM_XIP_FROM_PSRAM is enabled. --- components/esp_psram/system_layer/esp_psram.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/esp_psram/system_layer/esp_psram.c b/components/esp_psram/system_layer/esp_psram.c index c0358902e5..e22a93db24 100644 --- a/components/esp_psram/system_layer/esp_psram.c +++ b/components/esp_psram/system_layer/esp_psram.c @@ -66,6 +66,7 @@ extern uint8_t _rodata_reserved_end; #endif /* CONFIG_SPIRAM_RODATA */ #if CONFIG_SPIRAM_FETCH_INSTRUCTIONS +extern uint8_t _instruction_reserved_start; extern uint8_t _instruction_reserved_end; #endif /* CONFIG_SPIRAM_FETCH_INSTRUCTIONS */ @@ -483,6 +484,12 @@ bool IRAM_ATTR esp_psram_check_ptr_addr(const void *p) } #endif /* CONFIG_SPIRAM_FETCH_INSTRUCTIONS && SOC_MMU_DI_VADDR_SHARED */ +#if CONFIG_SPIRAM_FETCH_INSTRUCTIONS + if ((intptr_t)p >= (uint32_t)&_instruction_reserved_start && (intptr_t)p < (uint32_t)&_instruction_reserved_end) { + return true; + } +#endif /* CONFIG_SPIRAM_FETCH_INSTRUCTIONS */ + return false; }