File tree Expand file tree Collapse file tree 4 files changed +20
-2
lines changed
Expand file tree Collapse file tree 4 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ choice SPIRAM_USE
6969 return SPI RAM pointers.
7070
7171 config SPIRAM_USE_MEMMAP
72+ depends on IDF_TARGET_ESP32
7273 bool "Integrate RAM into memory map"
7374 config SPIRAM_USE_CAPS_ALLOC
7475 bool "Make RAM allocatable using heap_caps_malloc(..., MALLOC_CAP_SPIRAM)"
Original file line number Diff line number Diff line change @@ -114,6 +114,11 @@ static const DRAM_ATTR char TAG[] = "esp_psram";
114114ESP_SYSTEM_INIT_FN (add_psram_to_heap , CORE , BIT (0 ), 103 )
115115{
116116#if CONFIG_SPIRAM_BOOT_INIT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC )
117+
118+ #if (CONFIG_IDF_TARGET_ESP32C5 && CONFIG_ESP32C5_REV_MIN_FULL <= 100 ) || (CONFIG_IDF_TARGET_ESP32C61 && CONFIG_ESP32C61_REV_MIN_FULL <= 100 )
119+ ESP_EARLY_LOGW (TAG , "Due to hardware issue on ESP32-C5/C61 (Rev v1.0), PSRAM contents won't be encrypted (for flash encryption enabled case)" );
120+ ESP_EARLY_LOGW (TAG , "Please avoid using PSRAM for security sensitive data e.g., TLS stack allocations (CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC)" );
121+ #endif
117122 if (esp_psram_is_initialized ()) {
118123 esp_err_t r = esp_psram_extram_add_to_heap_allocator ();
119124 if (r != ESP_OK ) {
@@ -383,6 +388,10 @@ esp_err_t esp_psram_init(void)
383388 __attribute__((unused )) uint32_t start_page = 0 ;
384389
385390#if CONFIG_SPIRAM_FETCH_INSTRUCTIONS || CONFIG_SPIRAM_RODATA
391+ #if (CONFIG_IDF_TARGET_ESP32C5 && CONFIG_ESP32C5_REV_MIN_FULL <= 100 ) || (CONFIG_IDF_TARGET_ESP32C61 && CONFIG_ESP32C61_REV_MIN_FULL <= 100 )
392+ ESP_EARLY_LOGW (TAG , "Due to hardware issue on ESP32-C5/C61 (Rev v1.0), PSRAM contents won't be encrypted (for flash encryption enabled case)" );
393+ ESP_EARLY_LOGW (TAG , "Please avoid using PSRAM for execution as the code/rodata shall be copied as plaintext and this could pose a security risk." );
394+ #endif
386395 s_xip_psram_placement (& psram_available_size , & start_page );
387396#endif
388397
Original file line number Diff line number Diff line change 1717#include "hal/mmu_types.h"
1818#if SOC_EFUSE_SUPPORTED
1919#include "hal/efuse_ll.h"
20+ #include "hal/efuse_hal.h"
2021#endif
2122
2223
@@ -214,7 +215,10 @@ __attribute__((always_inline)) static inline void mmu_ll_write_entry(uint32_t mm
214215{
215216 uint32_t mmu_raw_value ;
216217 if (mmu_ll_cache_encryption_enabled ()) {
217- mmu_val |= SOC_MMU_SENSITIVE ;
218+ // For PSRAM case, avoid encryption due to a bug in the hardware
219+ if (!(target == MMU_TARGET_PSRAM0 && efuse_hal_chip_revision () <= 100 )) {
220+ mmu_val |= SOC_MMU_SENSITIVE ;
221+ }
218222 }
219223 mmu_val |= (target == MMU_TARGET_FLASH0 ) ? SOC_MMU_ACCESS_FLASH : SOC_MMU_ACCESS_SPIRAM ;
220224
Original file line number Diff line number Diff line change 1313#include "hal/assert.h"
1414#include "hal/mmu_types.h"
1515#include "hal/efuse_ll.h"
16+ #include "hal/efuse_hal.h"
1617
1718// TODO: [ESP32C61] IDF-9265, inherit from c6
1819
@@ -216,7 +217,10 @@ __attribute__((always_inline)) static inline void mmu_ll_write_entry(uint32_t mm
216217 (void )mmu_id ;
217218 uint32_t mmu_raw_value ;
218219 if (mmu_ll_cache_encryption_enabled ()) {
219- mmu_val |= SOC_MMU_SENSITIVE ;
220+ // For PSRAM case, avoid encryption due to a bug in the hardware
221+ if (!(target == MMU_TARGET_PSRAM0 && efuse_hal_chip_revision () <= 100 )) {
222+ mmu_val |= SOC_MMU_SENSITIVE ;
223+ }
220224 }
221225 mmu_val |= (target == MMU_TARGET_FLASH0 ) ? SOC_MMU_ACCESS_FLASH : SOC_MMU_ACCESS_SPIRAM ;
222226
You can’t perform that action at this time.
0 commit comments