Skip to content
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

optee_ta: close persistent object once synced #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions platform/NVMem.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ _plat__NvInitFromStorage()
i, bytesRead, objID, s_NVStore[i]);
#endif
}

/* Close object now, it will be opened back upon update */
TEE_CloseObject(s_NVStore[i]);
s_NVStore[i] = TEE_HANDLE_NULL;
}

// Storage objects are open and valid, next validate revision
Expand Down Expand Up @@ -296,8 +300,12 @@ _plat__NvWriteBack()
// Form storage object ID for this block.
objID = s_StorageObjectID + i;

// Move data position associated with handle to start of block.
Result = TEE_SeekObjectData(s_NVStore[i], 0, TEE_DATA_SEEK_SET);
// Open TEE persistent storage object: shall not fail
Result = TEE_OpenPersistentObject(TEE_STORAGE_PRIVATE,
(void *)&objID,
sizeof(objID),
TA_STORAGE_FLAGS,
&s_NVStore[i]);
if (Result != TEE_SUCCESS) {
goto Error;
}
Expand All @@ -310,18 +318,11 @@ _plat__NvWriteBack()
goto Error;
}

// Force storage stack to update its backing store
TEE_CloseObject(s_NVStore[i]);

Result = TEE_OpenPersistentObject(TEE_STORAGE_PRIVATE,
(void *)&objID,
sizeof(objID),
TA_STORAGE_FLAGS,
&s_NVStore[i]);
// Success?
if (Result != TEE_SUCCESS) {
goto Error;
}
// Close file to not waste secure resource in
// the dear TEE and force storage stack to update
// its backing store
TEE_CloseObject(s_NVStore[i]);
s_NVStore[i] = TEE_HANDLE_NULL;

// Clear dirty bit.
s_blockMap &= ~(0x1ULL << i);
Expand Down