feat(esp_system,ulp): Make LP core reserved memory optionally executable in HP core

This commit is contained in:
andylinpersonal 2024-08-22 21:08:45 +08:00 committed by Marius Vikhammer
parent 6bfa408c7b
commit 0e30c42625
4 changed files with 22 additions and 1 deletions

View File

@ -206,7 +206,11 @@ void esp_cpu_configure_region_protection(void)
PMP_ENTRY_SET(9, SOC_RTC_IRAM_LOW, NONE); PMP_ENTRY_SET(9, SOC_RTC_IRAM_LOW, NONE);
// First part of LP mem is reserved for ULP coprocessor // First part of LP mem is reserved for ULP coprocessor
#if CONFIG_ESP_SYSTEM_PMP_LP_CORE_RESERVE_MEM_EXECUTABLE
PMP_ENTRY_SET(10, (int)&_rtc_text_start, PMP_TOR | RWX);
#else
PMP_ENTRY_SET(10, (int)&_rtc_text_start, PMP_TOR | RW); PMP_ENTRY_SET(10, (int)&_rtc_text_start, PMP_TOR | RW);
#endif
PMP_ENTRY_SET(11, (int)&_rtc_text_end, PMP_TOR | RX); PMP_ENTRY_SET(11, (int)&_rtc_text_end, PMP_TOR | RX);
PMP_ENTRY_SET(12, SOC_RTC_IRAM_HIGH, PMP_TOR | RW); PMP_ENTRY_SET(12, SOC_RTC_IRAM_HIGH, PMP_TOR | RW);

View File

@ -190,8 +190,11 @@ void esp_cpu_configure_region_protection(void)
PMP_ENTRY_SET(11, SOC_RTC_IRAM_LOW, NONE); PMP_ENTRY_SET(11, SOC_RTC_IRAM_LOW, NONE);
// First part of LP mem is reserved for ULP coprocessor // First part of LP mem is reserved for ULP coprocessor
#if CONFIG_ESP_SYSTEM_PMP_LP_CORE_RESERVE_MEM_EXECUTABLE
PMP_ENTRY_SET(12, (int)&_rtc_text_start, PMP_TOR | RWX);
#else
PMP_ENTRY_SET(12, (int)&_rtc_text_start, PMP_TOR | RW); PMP_ENTRY_SET(12, (int)&_rtc_text_start, PMP_TOR | RW);
#endif
PMP_ENTRY_SET(13, (int)&_rtc_text_end, PMP_TOR | RX); PMP_ENTRY_SET(13, (int)&_rtc_text_end, PMP_TOR | RX);
PMP_ENTRY_SET(14, SOC_RTC_IRAM_HIGH, PMP_TOR | RW); PMP_ENTRY_SET(14, SOC_RTC_IRAM_HIGH, PMP_TOR | RW);
#else #else

View File

@ -220,7 +220,11 @@ void esp_cpu_configure_region_protection(void)
PMP_ENTRY_SET(9, SOC_RTC_IRAM_LOW, NONE); PMP_ENTRY_SET(9, SOC_RTC_IRAM_LOW, NONE);
// First part of LP mem is reserved for RTC reserved mem (shared between bootloader and app) // First part of LP mem is reserved for RTC reserved mem (shared between bootloader and app)
// as well as memory for ULP coprocessor // as well as memory for ULP coprocessor
#if CONFIG_ESP_SYSTEM_PMP_LP_CORE_RESERVE_MEM_EXECUTABLE
PMP_ENTRY_SET(10, (int)&_rtc_text_start, PMP_TOR | RWX);
#else
PMP_ENTRY_SET(10, (int)&_rtc_text_start, PMP_TOR | RW); PMP_ENTRY_SET(10, (int)&_rtc_text_start, PMP_TOR | RW);
#endif
PMP_ENTRY_SET(11, (int)&_rtc_text_end, PMP_TOR | RX); PMP_ENTRY_SET(11, (int)&_rtc_text_end, PMP_TOR | RX);
PMP_ENTRY_SET(12, SOC_RTC_IRAM_HIGH, PMP_TOR | RW); PMP_ENTRY_SET(12, SOC_RTC_IRAM_HIGH, PMP_TOR | RW);
#else #else

View File

@ -138,6 +138,16 @@ menu "ESP System Settings"
for the data part (above the splitting address). The memory protection is effective for the data part (above the splitting address). The memory protection is effective
on all access through the IRAM0 and DRAM0 buses. on all access through the IRAM0 and DRAM0 buses.
config ESP_SYSTEM_PMP_LP_CORE_RESERVE_MEM_EXECUTABLE
bool "Make LP core reserved memory executable from HP core"
depends on IDF_TARGET_ARCH_RISCV && SOC_LP_CORE_SUPPORTED && ESP_SYSTEM_PMP_IDRAM_SPLIT
default "n"
help
If enabled, user can run code available in LP Core image.
Warning: on ESP32-P4 this will also mark the memory area used for BOOTLOADER_RESERVE_RTC_MEM
as executable. If you consider this a security risk then do not activate this option.
config ESP_SYSTEM_MEMPROT_FEATURE config ESP_SYSTEM_MEMPROT_FEATURE
bool "Enable memory protection" bool "Enable memory protection"
depends on SOC_MEMPROT_SUPPORTED depends on SOC_MEMPROT_SUPPORTED