mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-16 04:22:22 +00:00
spi_flash: Flush flash cache if flash_mmap()ing a written-to page
Without this, it's possible for stale information to be read from cache via mmap, even if the MMU table entry had been invalidated prior to writing flash (if the same MMU table entry was re-used after writing flash.)
This commit is contained in:
committed by
Ivan Grokhotkov
parent
95c150fe2c
commit
36ccdee6ec
@@ -250,6 +250,11 @@ esp_err_t IRAM_ATTR spi_flash_write(size_t dst, const void *srcv, size_t size)
|
||||
}
|
||||
out:
|
||||
COUNTER_STOP(write);
|
||||
|
||||
spi_flash_op_lock();
|
||||
spi_flash_mark_modified_region(dst, size);
|
||||
spi_flash_op_unlock();
|
||||
|
||||
return spi_flash_translate_rc(rc);
|
||||
}
|
||||
|
||||
@@ -286,6 +291,11 @@ esp_err_t IRAM_ATTR spi_flash_write_encrypted(size_t dest_addr, const void *src,
|
||||
bzero(encrypt_buf, sizeof(encrypt_buf));
|
||||
}
|
||||
COUNTER_ADD_BYTES(write, size);
|
||||
|
||||
spi_flash_op_lock();
|
||||
spi_flash_mark_modified_region(dest_addr, size);
|
||||
spi_flash_op_unlock();
|
||||
|
||||
return spi_flash_translate_rc(rc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user