diff --git a/components/esp_hw_support/port/esp32c5/cpu_region_protect.c b/components/esp_hw_support/port/esp32c5/cpu_region_protect.c index d4d0b42e72..b9e1e0310f 100644 --- a/components/esp_hw_support/port/esp32c5/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32c5/cpu_region_protect.c @@ -94,7 +94,7 @@ void esp_cpu_configure_region_protection(void) * * 2. Application build with CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT enabled * - We split the SRAM into IRAM and DRAM such that IRAM region cannot be written to - * and DRAM region cannot be executed. We use _iram_end and _data_start markers to set the boundaries. + * and DRAM region cannot be executed. We use _iram_text_end and _data_start markers to set the boundaries. * We also lock these entries so the R/W/X permissions are enforced even for machine mode * * 3. Application build with CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT disabled @@ -142,7 +142,7 @@ void esp_cpu_configure_region_protection(void) _Static_assert(SOC_IRAM_LOW < SOC_IRAM_HIGH, "Invalid RAM region"); } else { #if CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT && !BOOTLOADER_BUILD - extern int _iram_end; + extern int _iram_text_end; /* Reset the corresponding PMP config because PMP_ENTRY_SET only sets the given bits * Bootloader might have given extra permissions and those won't be cleared */ @@ -150,7 +150,7 @@ void esp_cpu_configure_region_protection(void) PMP_ENTRY_CFG_RESET(6); PMP_ENTRY_CFG_RESET(7); PMP_ENTRY_SET(5, SOC_IRAM_LOW, NONE); - PMP_ENTRY_SET(6, (int)&_iram_end, PMP_TOR | RX); + PMP_ENTRY_SET(6, (int)&_iram_text_end, PMP_TOR | RX); PMP_ENTRY_SET(7, SOC_DRAM_HIGH, PMP_TOR | RW); #else PMP_ENTRY_SET(5, SOC_IRAM_LOW, CONDITIONAL_NONE); diff --git a/components/esp_hw_support/port/esp32c6/cpu_region_protect.c b/components/esp_hw_support/port/esp32c6/cpu_region_protect.c index 71cee55e40..ce9ca7581f 100644 --- a/components/esp_hw_support/port/esp32c6/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32c6/cpu_region_protect.c @@ -88,7 +88,7 @@ void esp_cpu_configure_region_protection(void) * * 2. Application build with CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT enabled * - We split the SRAM into IRAM and DRAM such that IRAM region cannot be written to - * and DRAM region cannot be executed. We use _iram_end and _data_start markers to set the boundaries. + * and DRAM region cannot be executed. We use _iram_text_end and _data_start markers to set the boundaries. * We also lock these entries so the R/W/X permissions are enforced even for machine mode * * 3. Application build with CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT disabled @@ -136,7 +136,7 @@ void esp_cpu_configure_region_protection(void) _Static_assert(SOC_IRAM_LOW < SOC_IRAM_HIGH, "Invalid RAM region"); } else { #if CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT && !BOOTLOADER_BUILD - extern int _iram_end; + extern int _iram_text_end; // 5. IRAM and DRAM /* Reset the corresponding PMP config because PMP_ENTRY_SET only sets the given bits * Bootloader might have given extra permissions and those won't be cleared @@ -145,7 +145,7 @@ void esp_cpu_configure_region_protection(void) PMP_ENTRY_CFG_RESET(6); PMP_ENTRY_CFG_RESET(7); PMP_ENTRY_SET(5, SOC_IRAM_LOW, NONE); - PMP_ENTRY_SET(6, (int)&_iram_end, PMP_TOR | RX); + PMP_ENTRY_SET(6, (int)&_iram_text_end, PMP_TOR | RX); PMP_ENTRY_SET(7, SOC_DRAM_HIGH, PMP_TOR | RW); #else // 5. IRAM and DRAM diff --git a/components/esp_hw_support/port/esp32h2/cpu_region_protect.c b/components/esp_hw_support/port/esp32h2/cpu_region_protect.c index c8817ca176..b60dc95d4a 100644 --- a/components/esp_hw_support/port/esp32h2/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32h2/cpu_region_protect.c @@ -88,7 +88,7 @@ void esp_cpu_configure_region_protection(void) * * 2. Application build with CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT enabled * - We split the SRAM into IRAM and DRAM such that IRAM region cannot be written to - * and DRAM region cannot be executed. We use _iram_end and _data_start markers to set the boundaries. + * and DRAM region cannot be executed. We use _iram_text_end and _data_start markers to set the boundaries. * We also lock these entries so the R/W/X permissions are enforced even for machine mode * * 3. Application build with CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT disabled @@ -136,7 +136,7 @@ void esp_cpu_configure_region_protection(void) _Static_assert(SOC_IRAM_LOW < SOC_IRAM_HIGH, "Invalid RAM region"); } else { #if CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT && !BOOTLOADER_BUILD - extern int _iram_end; + extern int _iram_text_end; // 5. IRAM and DRAM /* Reset the corresponding PMP config because PMP_ENTRY_SET only sets the given bits * Bootloader might have given extra permissions and those won't be cleared @@ -145,7 +145,7 @@ void esp_cpu_configure_region_protection(void) PMP_ENTRY_CFG_RESET(6); PMP_ENTRY_CFG_RESET(7); PMP_ENTRY_SET(5, SOC_IRAM_LOW, NONE); - PMP_ENTRY_SET(6, (int)&_iram_end, PMP_TOR | RX); + PMP_ENTRY_SET(6, (int)&_iram_text_end, PMP_TOR | RX); PMP_ENTRY_SET(7, SOC_DRAM_HIGH, PMP_TOR | RW); #else // 5. IRAM and DRAM diff --git a/components/esp_hw_support/port/esp32p4/cpu_region_protect.c b/components/esp_hw_support/port/esp32p4/cpu_region_protect.c index acf88eae27..6f8597dc58 100644 --- a/components/esp_hw_support/port/esp32p4/cpu_region_protect.c +++ b/components/esp_hw_support/port/esp32p4/cpu_region_protect.c @@ -113,7 +113,7 @@ void esp_cpu_configure_region_protection(void) * * 2. Application build with CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT enabled * - We split the SRAM into IRAM and DRAM such that IRAM region cannot be written to - * and DRAM region cannot be executed. We use _iram_end and _data_start markers to set the boundaries. + * and DRAM region cannot be executed. We use _iram_text_end and _data_start markers to set the boundaries. * We also lock these entries so the R/W/X permissions are enforced even for machine mode * * 3. Application build with CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT disabled @@ -166,7 +166,7 @@ void esp_cpu_configure_region_protection(void) _Static_assert(SOC_IRAM_LOW < SOC_IRAM_HIGH, "Invalid RAM region"); } else { #if CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT && !BOOTLOADER_BUILD - extern int _iram_end; + extern int _iram_text_end; // 4. IRAM and DRAM /* Reset the corresponding PMP config because PMP_ENTRY_SET only sets the given bits * Bootloader might have given extra permissions and those won't be cleared @@ -175,7 +175,7 @@ void esp_cpu_configure_region_protection(void) PMP_ENTRY_CFG_RESET(4); PMP_ENTRY_CFG_RESET(5); PMP_ENTRY_SET(3, SOC_IRAM_LOW, NONE); - PMP_ENTRY_SET(4, (int)&_iram_end, PMP_TOR | RX); + PMP_ENTRY_SET(4, (int)&_iram_text_end, PMP_TOR | RX); PMP_ENTRY_SET(5, SOC_DRAM_HIGH, PMP_TOR | RW); #else // 4. IRAM and DRAM diff --git a/components/esp_system/ld/esp32c6/sections.ld.in b/components/esp_system/ld/esp32c6/sections.ld.in index c9be5aae30..98b23613d3 100644 --- a/components/esp_system/ld/esp32c6/sections.ld.in +++ b/components/esp_system/ld/esp32c6/sections.ld.in @@ -173,6 +173,9 @@ SECTIONS /* Marks the end of IRAM code segment */ .iram0.text_end (NOLOAD) : { + /* Align the end of code region as per PMP region granularity */ + . = ALIGN(_esp_pmp_align_size); + ALIGNED_SYMBOL(4, _iram_text_end) } > sram_seg diff --git a/components/esp_system/ld/esp32c61/sections.ld.in b/components/esp_system/ld/esp32c61/sections.ld.in index a6db96dbb7..19514c8f7b 100644 --- a/components/esp_system/ld/esp32c61/sections.ld.in +++ b/components/esp_system/ld/esp32c61/sections.ld.in @@ -173,6 +173,9 @@ SECTIONS /* Marks the end of IRAM code segment */ .iram0.text_end (NOLOAD) : { + /* Align the end of code region as per PMP region granularity */ + . = ALIGN(_esp_pmp_align_size); + ALIGNED_SYMBOL(4, _iram_text_end) } > sram_seg diff --git a/components/esp_system/ld/esp32h2/sections.ld.in b/components/esp_system/ld/esp32h2/sections.ld.in index 57e8a7c513..5ffe1de81d 100644 --- a/components/esp_system/ld/esp32h2/sections.ld.in +++ b/components/esp_system/ld/esp32h2/sections.ld.in @@ -173,6 +173,9 @@ SECTIONS /* Marks the end of IRAM code segment */ .iram0.text_end (NOLOAD) : { + /* Align the end of code region as per PMP region granularity */ + . = ALIGN(_esp_pmp_align_size); + ALIGNED_SYMBOL(4, _iram_text_end) } > sram_seg