fix(esp_tee): Miscellaneous optimizations and fixes

Closes https://github.com/espressif/esp-idf/issues/18591
This commit is contained in:
Laukik Hase
2026-07-06 13:48:12 +05:30
parent 5fb2dc6c74
commit 4861cd58c3
4 changed files with 14 additions and 4 deletions

View File

@@ -416,8 +416,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

View File

@@ -9,7 +9,7 @@ idf_build_get_property(target IDF_TARGET)
# ESP-TEE is currently supported only on the ESP32-C6, H2, C5 and C61 SoCs
set(SUPPORTED_TARGETS "esp32c6" "esp32h2" "esp32c5" "esp32c61")
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()

View File

@@ -6,6 +6,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include "rom_patch_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();
@@ -227,7 +231,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);

View File

@@ -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
*/
@@ -26,6 +26,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;
@@ -119,6 +122,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;