diff --git a/components/bootloader_support/bootloader_flash/src/bootloader_flash.c b/components/bootloader_support/bootloader_flash/src/bootloader_flash.c index b21b9d4f04d..0a4a9edf3de 100644 --- a/components/bootloader_support/bootloader_flash/src/bootloader_flash.c +++ b/components/bootloader_support/bootloader_flash/src/bootloader_flash.c @@ -426,8 +426,8 @@ void bootloader_munmap(const void *mapping) mmu_hal_unmap_all(); #else cache_hal_suspend(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL); - mmu_hal_unmap_region(0, FLASH_MMAP_VADDR, current_mapped_size); cache_hal_invalidate_addr(FLASH_MMAP_VADDR, current_mapped_size); + mmu_hal_unmap_region(0, FLASH_MMAP_VADDR, current_mapped_size); cache_hal_resume(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL); #endif #endif diff --git a/components/esp_tee/CMakeLists.txt b/components/esp_tee/CMakeLists.txt index fc58bbed717..777187b9a0e 100644 --- a/components/esp_tee/CMakeLists.txt +++ b/components/esp_tee/CMakeLists.txt @@ -9,7 +9,7 @@ idf_build_get_property(target IDF_TARGET) # ESP-TEE is currently supported only on the ESP32-C6, H2 and C5 SoCs set(SUPPORTED_TARGETS "esp32c6" "esp32h2" "esp32c5") if(NOT target IN_LIST SUPPORTED_TARGETS) - message(STATUS "ESP-TEE is currently supported only on the ${SUPPORTED_TARGETS} SoCs") + # ESP-TEE Kconfig is gated on the supported targets; nothing to register elsewhere. return() endif() diff --git a/components/esp_tee/subproject/main/common/multi_heap.c b/components/esp_tee/subproject/main/common/multi_heap.c index ade9f35f759..97d613d6fe3 100644 --- a/components/esp_tee/subproject/main/common/multi_heap.c +++ b/components/esp_tee/subproject/main/common/multi_heap.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "esp_rom_tlsf.h" #include "esp_rom_sys.h" #include "tlsf_block_functions.h" @@ -63,6 +64,9 @@ esp_err_t esp_tee_heap_init(void *start_ptr, size_t size) return ESP_ERR_INVALID_SIZE; } + /* Zeroize the entire region before registering it as the TEE heap*/ + memset(start_ptr, 0, size); + #if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 void *heap = tlsf_create_with_pool(start_ptr + sizeof(heap_t), usable_size); size_t overhead = tlsf_size(); @@ -229,7 +233,7 @@ void esp_tee_heap_dump_info(void) /* Definitions for functions from the heap component, used in files shared with ESP-IDF */ -void *heap_caps_malloc(size_t alignment, size_t size, uint32_t caps) +void *heap_caps_malloc(size_t size, uint32_t caps) { (void) caps; return esp_tee_heap_malloc(size); diff --git a/components/esp_tee/subproject/main/core/esp_tee_init.c b/components/esp_tee/subproject/main/core/esp_tee_init.c index d1e6ca662cb..d427f71d6c9 100644 --- a/components/esp_tee/subproject/main/core/esp_tee_init.c +++ b/components/esp_tee/subproject/main/core/esp_tee_init.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -24,6 +24,9 @@ /* TEE symbols */ extern uint32_t _tee_stack; +extern uint32_t _tee_stack_bottom; +extern uint32_t _tee_intr_stack; +extern uint32_t _tee_intr_stack_bottom; extern uint32_t _tee_bss_start; extern uint32_t _tee_bss_end; extern uint32_t _tee_s_intr_handler; @@ -117,6 +120,9 @@ void __attribute__((noreturn)) esp_tee_init(uint32_t ree_entry_addr, uint32_t re { /* Clear BSS */ memset(&_tee_bss_start, 0, (&_tee_bss_end - &_tee_bss_start) * sizeof(_tee_bss_start)); + /* Clear the TEE stack and interrupt stack */ + memset(&_tee_stack_bottom, 0, (&_tee_stack - &_tee_stack_bottom) * sizeof(_tee_stack_bottom)); + memset(&_tee_intr_stack_bottom, 0, (&_tee_intr_stack - &_tee_intr_stack_bottom) * sizeof(_tee_intr_stack_bottom)); static uint32_t btld_sp; diff --git a/components/esp_tee/test_apps/tee_cli_app/sdkconfig.ci.sb_fe b/components/esp_tee/test_apps/tee_cli_app/sdkconfig.ci.sb_fe index ab5093cb612..70b543c2f95 100644 --- a/components/esp_tee/test_apps/tee_cli_app/sdkconfig.ci.sb_fe +++ b/components/esp_tee/test_apps/tee_cli_app/sdkconfig.ci.sb_fe @@ -4,8 +4,8 @@ # Increasing TEE I/DRAM sizes # 38KB CONFIG_SECURE_TEE_IRAM_SIZE=0x9800 -# 18KB -CONFIG_SECURE_TEE_DRAM_SIZE=0x4800 +# 18.5KB +CONFIG_SECURE_TEE_DRAM_SIZE=0x4A00 # Security features - build-only configuration CONFIG_PARTITION_TABLE_OFFSET=0xf000