From c3fc7cffdaa2a20b6715707529a1e4193304d28f Mon Sep 17 00:00:00 2001 From: Armando Date: Tue, 16 Jul 2024 11:48:47 +0800 Subject: [PATCH] fix(aes): fixed aes wrong dma desc alignment --- components/mbedtls/port/aes/dma/esp_aes_dma_core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/mbedtls/port/aes/dma/esp_aes_dma_core.c b/components/mbedtls/port/aes/dma/esp_aes_dma_core.c index 5788b0c2f8..1fcf979533 100644 --- a/components/mbedtls/port/aes/dma/esp_aes_dma_core.c +++ b/components/mbedtls/port/aes/dma/esp_aes_dma_core.c @@ -622,7 +622,8 @@ int esp_aes_process_dma(esp_aes_context *ctx, const unsigned char *input, unsign } #if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE - if (esp_cache_msync(output_desc, ALIGN_UP(output_dma_desc_num * sizeof(crypto_dma_desc_t), output_cache_line_size), ESP_CACHE_MSYNC_FLAG_DIR_M2C) != ESP_OK) { + size_t output_desc_cache_line_size = get_cache_line_size(output_desc); + if (esp_cache_msync(output_desc, ALIGN_UP(output_dma_desc_num * sizeof(crypto_dma_desc_t), output_desc_cache_line_size), ESP_CACHE_MSYNC_FLAG_DIR_M2C) != ESP_OK) { ESP_LOGE(TAG, "Output DMA descriptor cache sync M2C failed"); ret = -1; goto cleanup; @@ -841,7 +842,8 @@ int esp_aes_process_dma_gcm(esp_aes_context *ctx, const unsigned char *input, un } #if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE - if (esp_cache_msync(output_desc, ALIGN_UP(output_dma_desc_num * sizeof(crypto_dma_desc_t), output_cache_line_size), ESP_CACHE_MSYNC_FLAG_DIR_M2C) != ESP_OK) { + size_t output_desc_cache_line_size = get_cache_line_size(output_desc); + if (esp_cache_msync(output_desc, ALIGN_UP(output_dma_desc_num * sizeof(crypto_dma_desc_t), output_desc_cache_line_size), ESP_CACHE_MSYNC_FLAG_DIR_M2C) != ESP_OK) { ESP_LOGE(TAG, "Output DMA descriptor cache sync M2C failed"); ret = -1; goto cleanup;