Hi Matt,
Thanks very much for your mail. It looks like it is indeed a problem here. Can you upstream a patch to help to fix them directly?
Thanks, Edison
-----Original Message----- From: TF-M tf-m-bounces@lists.trustedfirmware.org On Behalf Of lg via TF-M Sent: Thursday, December 12, 2019 9:43 AM To: tf-m@lists.trustedfirmware.org Subject: [TF-M] Secure storage and Internal trusted storage code logic check
Hi TFM Secure storage & Internal trusted storage experts,
It seems there are code logic errors in both files sst_flash_fs_mblock.c and its_flash_fs_mblock.c. There are following codes in function its_flash_fs_mblock_reset_metablock in its_flash_fs_mblock.c:
for (i = ITS_INIT_DBLOCK_START; i < ITS_NUM_DEDICATED_DBLOCKS; i++) { /* If a flash error is detected, the code erases the rest * of the blocks anyway to remove all data stored in them. */ err |= its_flash_erase_block(i); } This loop starts from ITS_INIT_DBLOCK_START and ends to ITS_NUM_DEDICATED_DBLOCKS. If there are four ITS blocks including meta blocks and data blocks in all, that means ITS_INIT_DBLOCK_START is 3 and ITS_NUM_DEDICATED_DBLOCKS is 1. But the above loop can not erase the data block any way. Should it be the following logic?
for (i = 0; i < ITS_NUM_DEDICATED_DBLOCKS; i++) { /* If a flash error is detected, the code erases the rest * of the blocks anyway to remove all data stored in them. */ err |= its_flash_erase_block(i+ITS_INIT_DBLOCK_START); } It is the same logic in function sst_flash_fs_mblock_reset_metablock in file sst_flash_fs_mblock.c.
Please help to check.
Thanks. Matt.
tf-m@lists.trustedfirmware.org