OP-TEE / optee_os

Trusted side of the TEE
Other
1.59k stars 1.07k forks source link

Question about mobj and fobj #6559

Closed NewDwarf closed 10 months ago

NewDwarf commented 11 months ago

What are the main purposes of mobj and fobj abstraction from the OP-TEE design perspective? It is interesting to know how they help to orginize the OP-TEE design and how difficult/inconvenient would be developing of OP-TEE in the case of missed mobj and fobj abstraction.

etienne-lms commented 11 months ago

A mobj is an abstraction of a memory object: shared memory, TA exec or read/write memory, FFA memory reference, etc... It is a convenient way to bind operations (map/unmap w/ refcount, get phys. addr./memroy type, ...) under a common API: consumers manipulate a mobj reference instead of a virtual address reference.

An fobj is a file abstraction for the content represented by a memory object. It is mainly designed for OP-TEE pager, for the page swapping mechanism. Elfloader also uses the fobj abstraction for ELF content loading of secure userland code/data (unless i missed somthing).

Due to pager constraint on the system, OP-TEE core needs a specific sequence to allocate external secure memory that you will find at several places (_ldelfloader.c, _ldelfsyscalls.c, _stmmsp.c, _securepartition.c):