-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connecting RPMB to the storage APIs #296
Comments
Hi @youssefesmat , thanks for your proposal, please let us have some time to digest and discuss your suggestions. We will come back with an answer soon again. |
Hi @youssefesmat , Sorry for taking some time to get back to you, but now we have been looking at
|
Thank you very much @jbech-linaro for looking at this. I will apply your feedback. |
Hi @youssefesmat , So, finally we have a plan from Linaro and it is as follows:
After that we will probably look into the optimizations. As you've already indicated, the FAT look-a-like file system might not be the most efficient way of handling the data. I would like to close this particular "issue" now, since the work actually is ongoing as we're speaking and related to this I would believe that we should close #323, since those patches is more or less the same kind of code as we can find in the fork you gave us (which is what we're trying to rebase and use)? Right? Please let me know if you're OK with my proposal? |
I will close this issue based on @jbech-linaro previous comment, please feel free to re-open if you have additional comments and questions about this topic. |
Hello,
I have been working with Paul (paswan-ms) on RPMB support in OP-TEE. The following is a proposal for RPMB support that builds upon the encrypted FS changes (pull request 231).
Connecting the APIs
The proposal here is to add another tee_file_operations table that can be updated by the platform.
Today, the tee_svc_storage_XX APIs (tee_svc_storage.c) call the lower level APIs using the tee_file_ops function table. This table was changed with the security changes to call the tee_enc_fs_XX APIs. Internally the tee_enc_fs_XX APIs call the lower level tee_common_fs_XX APIs.
This change will add another table that the tee_enc_fs_XX APIs can use to call the lower layer physical storage APIs called tee_phy_file_ops. Thus, instead of tee_enc_fs_XX APIs calling tee_common_fs directly they will call tee_phy_file_ops.XX.
The table will be prototyped in tee_fs.h as follows:
The table will be defined in tee_ fs_common.c in the following way:
And tee_file_ops in tee_enc_fs.c will be changed to:
The platform can then define CFG_PHY_FS and define the table in platform specific files. In our case the platform will provide another definition for the table pointing to the RPMB APIs. Such as the following:
RPMB APIs
The current implementation of RPMB implements a FAT like table that stores the file name, location and size in the RPMB block. The FAT table sits in the beginning of the RRMB block.
Directory Support
Directory support is missing from the current RPMB implementation that needs to be added to support calls from the higher level encryption APIs. In OPTEE today there is only a one-level deep directory hierarchy defined as TA_ID/OBJECT_ID. There is a directory for every TA that contains the objects that that TA owns.
Short Term Solution
The quickest short term solution to add “directory” support to the current implementation of RPMB is to store the full path as the name of the file in the FAT table. The FAT table supports a maximum file name of 48 characters. The object ID maximum length is 64 character, plus the size of the UUID for the TA is 16 plus one for the directory divisor character would require us to change the maximum file size to 81 characters or to (sizeof(TEE_UUID) + TEE_OBJECT_ID_MAX_LEN + 1).
With this approach the RPMB APIs that need to be implemented will be as follows:
Optimizations
One performance issue that arrises from the proposed solution is that the entire FAT needs to be traversed to find a particular UUID/OBJECT_ID file instead of just traversing the directory files. This can be improved by:
Currently, the RPMB code generates a tee_mm_pool_t to represent the FAT structure on every write call. This can be done during initialization and stored in memory avoiding the need to traverse the FAT and build the pool on every write call. Also an in memory representation of the FAT will save the need to read the FAT and issue RPC calls to normal world.
Open Questions
1. Is there a current ETA for pull request 231 such that we can take a dependency on it? 2. How is locking handled to the lower level RPCs? In other words can two threads attempt to write to the RPMB block at the same time?The text was updated successfully, but these errors were encountered: