forked from espressif/esp-idf
Merge branch 'fix/esp32_hw_mpi_data_corruption_v5.0' into 'release/v5.0'
esp32/mpi: Added alternate workaround for MPI data corruption issue (v5.0) See merge request espressif/esp-idf!22581
This commit is contained in:
@ -22,11 +22,11 @@
|
|||||||
#define IDF_PERFORMANCE_MAX_TIME_SHA512_32KB 4500
|
#define IDF_PERFORMANCE_MAX_TIME_SHA512_32KB 4500
|
||||||
|
|
||||||
#define IDF_PERFORMANCE_MAX_RSA_2048KEY_PUBLIC_OP 19000
|
#define IDF_PERFORMANCE_MAX_RSA_2048KEY_PUBLIC_OP 19000
|
||||||
#define IDF_PERFORMANCE_MAX_RSA_2048KEY_PRIVATE_OP 420000
|
#define IDF_PERFORMANCE_MAX_RSA_2048KEY_PRIVATE_OP 450000
|
||||||
#define IDF_PERFORMANCE_MAX_RSA_3072KEY_PUBLIC_OP 33000
|
#define IDF_PERFORMANCE_MAX_RSA_3072KEY_PUBLIC_OP 33000
|
||||||
#define IDF_PERFORMANCE_MAX_RSA_3072KEY_PRIVATE_OP 950000
|
#define IDF_PERFORMANCE_MAX_RSA_3072KEY_PRIVATE_OP 950000
|
||||||
#define IDF_PERFORMANCE_MAX_RSA_4096KEY_PUBLIC_OP 90000
|
#define IDF_PERFORMANCE_MAX_RSA_4096KEY_PUBLIC_OP 90000
|
||||||
#define IDF_PERFORMANCE_MAX_RSA_4096KEY_PRIVATE_OP 1700000
|
#define IDF_PERFORMANCE_MAX_RSA_4096KEY_PRIVATE_OP 1900000
|
||||||
|
|
||||||
#define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_POLLING 15
|
#define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_POLLING 15
|
||||||
#define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_POLLING_NO_DMA 15
|
#define IDF_PERFORMANCE_MAX_SPI_PER_TRANS_POLLING_NO_DMA 15
|
||||||
|
@ -69,22 +69,22 @@ void esp_mpi_interrupt_clear( void )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Please see detailed note inside the function body below.
|
/* Please see detailed note inside the function body below.
|
||||||
* Relevant: https://github.com/espressif/esp-idf/issues/8710 and IDF-6029
|
* Relevant: IDF-6029
|
||||||
|
https://github.com/espressif/esp-idf/issues/8710
|
||||||
|
https://github.com/espressif/esp-idf/issues/10403
|
||||||
*/
|
*/
|
||||||
static inline void __attribute__((optimize("-fno-tree-loop-distribute-patterns")))
|
static inline void mpi_to_mem_block(uint32_t mem_base, const mbedtls_mpi *mpi, size_t hw_words)
|
||||||
mpi_to_mem_block(uint32_t mem_base, const mbedtls_mpi *mpi, size_t hw_words)
|
|
||||||
{
|
{
|
||||||
uint32_t *pbase = (uint32_t *)mem_base;
|
|
||||||
uint32_t copy_words = MIN(hw_words, mpi->MBEDTLS_PRIVATE(n));
|
uint32_t copy_words = MIN(hw_words, mpi->MBEDTLS_PRIVATE(n));
|
||||||
|
|
||||||
/* Copy MPI data to memory block registers */
|
/* Copy MPI data to memory block registers */
|
||||||
for (uint32_t i = 0; i < copy_words; i++) {
|
for (uint32_t i = 0; i < copy_words; i++) {
|
||||||
pbase[i] = mpi->MBEDTLS_PRIVATE(p[i]);
|
DPORT_REG_WRITE(mem_base + i * 4, mpi->MBEDTLS_PRIVATE(p[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Zero any remaining memory block data */
|
/* Zero any remaining memory block data */
|
||||||
for (uint32_t i = copy_words; i < hw_words; i++) {
|
for (uint32_t i = copy_words; i < hw_words; i++) {
|
||||||
pbase[i] = 0;
|
DPORT_REG_WRITE(mem_base + i * 4, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if _INTERNAL_DEBUG_PURPOSE
|
#if _INTERNAL_DEBUG_PURPOSE
|
||||||
@ -94,14 +94,9 @@ static inline void __attribute__((optimize("-fno-tree-loop-distribute-patterns")
|
|||||||
* specific write (store) operation to the MPI peripheral block was getting lost erroneously.
|
* specific write (store) operation to the MPI peripheral block was getting lost erroneously.
|
||||||
* Following data re-verify loop could catch it during runtime.
|
* Following data re-verify loop could catch it during runtime.
|
||||||
*
|
*
|
||||||
* As a workaround, we are disabling loop distribute patterns for this function and hence
|
* As a workaround, we are using DPORT_WRITE_REG (volatile writes) wrappers to write to
|
||||||
* compiler does not enforce usage of `memset` (or `memcpy`) calls for this routine. It
|
* the MPI peripheral.
|
||||||
* appears that `-ftree-loop-distribute-patterns` was enabled with O2/Os starting from
|
|
||||||
* GCC-10.x. It is quite possible that there is some issue with DPORT write with sequence of
|
|
||||||
* store instructions as generated by `memset` call, but for now this should serve as good
|
|
||||||
* interim workaround without any impact on the performance.
|
|
||||||
*
|
*
|
||||||
* Please see IDF-6029 for more details.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//for (uint32_t i = copy_words; i < hw_words; i++) { assert(pbase[i] == 0); }
|
//for (uint32_t i = copy_words; i < hw_words; i++) { assert(pbase[i] == 0); }
|
||||||
|
Reference in New Issue
Block a user