diff --git a/components/esp_hw_support/cpu.c b/components/esp_hw_support/cpu.c index 9e2817c96b..79f2f4cec6 100644 --- a/components/esp_hw_support/cpu.c +++ b/components/esp_hw_support/cpu.c @@ -454,11 +454,13 @@ extern int _data_start; #define CONDITIONAL_NONE 0x0 #define CONDITIONAL_RX PMP_R | PMP_X #define CONDITIONAL_RW PMP_R | PMP_W +#define CONDITIONAL_RWX PMP_R | PMP_W | PMP_X #else // With L bit set #define CONDITIONAL_NONE NONE #define CONDITIONAL_RX RX #define CONDITIONAL_RW RW +#define CONDITIONAL_RWX RWX #endif void esp_cpu_configure_region_protection(void) @@ -525,7 +527,12 @@ void esp_cpu_configure_region_protection(void) } else { // 1. IRAM PMP_ENTRY_SET(0, SOC_DIRAM_IRAM_LOW, CONDITIONAL_NONE); + +#if CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT PMP_ENTRY_SET(1, IRAM_END, PMP_TOR | CONDITIONAL_RX); +#else + PMP_ENTRY_SET(1, IRAM_END, PMP_TOR | CONDITIONAL_RWX); +#endif // 2. DRAM PMP_ENTRY_SET(2, DRAM_START, CONDITIONAL_NONE); diff --git a/components/heap/test_apps/main/test_diram.c b/components/heap/test_apps/main/test_diram.c index 569139f93b..c3db5e7c81 100644 --- a/components/heap/test_apps/main/test_diram.c +++ b/components/heap/test_apps/main/test_diram.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -15,8 +15,6 @@ #define ALLOC_SZ 1024 -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) -//IDF-5167 #ifndef CONFIG_ESP_SYSTEM_MEMPROT_FEATURE static void *malloc_block_diram(uint32_t caps) { @@ -81,4 +79,3 @@ TEST_CASE("Allocate D/IRAM as IRAM", "[heap]") free(iram); } #endif // CONFIG_ESP_SYSTEM_MEMPROT_FEATURE -#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) diff --git a/components/heap/test_apps/main/test_malloc_caps.c b/components/heap/test_apps/main/test_malloc_caps.c index 2eb69625db..7a925dca49 100644 --- a/components/heap/test_apps/main/test_malloc_caps.c +++ b/components/heap/test_apps/main/test_malloc_caps.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -18,9 +18,6 @@ #include #include - -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) -//IDF-5167 #ifndef CONFIG_ESP_SYSTEM_MEMPROT_FEATURE TEST_CASE("Capabilities allocator test", "[heap]") { @@ -112,7 +109,6 @@ TEST_CASE("Capabilities allocator test", "[heap]") printf("Done.\n"); } #endif // CONFIG_ESP_SYSTEM_MEMPROT_FEATURE -#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) #ifdef CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY TEST_CASE("IRAM_8BIT capability test", "[heap]") @@ -175,8 +171,6 @@ TEST_CASE("heap_caps metadata test", "[heap]") TEST_ASSERT(after.minimum_free_bytes < original.total_free_bytes); } -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) -//IDF-5167 /* Small function runs from IRAM to check that malloc/free/realloc all work OK when cache is disabled... */ @@ -203,7 +197,6 @@ TEST_CASE("heap_caps_xxx functions work with flash cache disabled", "[heap]") TEST_ASSERT( iram_malloc_test() ); } #endif // CONFIG_ESP_SYSTEM_MEMPROT_FEATURE -#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) #ifdef CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS TEST_CASE("When enabled, allocation operation failure generates an abort", "[heap][reset=abort,SW_CPU_RESET]") diff --git a/components/heap/test_apps/main/test_realloc.c b/components/heap/test_apps/main/test_realloc.c index d6e91e940d..9a25d4fbfa 100644 --- a/components/heap/test_apps/main/test_realloc.c +++ b/components/heap/test_apps/main/test_realloc.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -28,8 +28,6 @@ TEST_CASE("realloc shrink buffer in place", "[heap]") #endif -#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) -//IDF-5167 #ifndef CONFIG_ESP_SYSTEM_MEMPROT_FEATURE TEST_CASE("realloc shrink buffer with EXEC CAPS", "[heap]") { @@ -70,4 +68,3 @@ TEST_CASE("realloc move data to a new heap type", "[heap]") free(c); } #endif // CONFIG_ESP_SYSTEM_MEMPROT_FEATURE -#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32C2) diff --git a/components/heap/test_apps/sdkconfig.defaults b/components/heap/test_apps/sdkconfig.defaults index bbd0363cd0..40fc15f7a7 100644 --- a/components/heap/test_apps/sdkconfig.defaults +++ b/components/heap/test_apps/sdkconfig.defaults @@ -1,6 +1,7 @@ CONFIG_COMPILER_DUMP_RTL_FILES=y CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=n # memory protection needs to be disabled for certain tests +CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT=n # for c2 and c6 this config must be disabled for certain tests CONFIG_COMPILER_STACK_CHECK_MODE_ALL=y CONFIG_COMPILER_STACK_CHECK=y