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:
Angus Gratton
2017-01-05 15:51:02 +11:00
committed by Ivan Grokhotkov
parent 95c150fe2c
commit 36ccdee6ec
7 changed files with 170 additions and 6 deletions

View File

@@ -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);
}