[RFC] hello_world: add demo code for using custom ree service - #63
[RFC] hello_world: add demo code for using custom ree service#63divneil wants to merge 3 commits into
Conversation
|
This one is just POC. I did this just to test dynamic library/message queue calls are working okay for my use-case. |
| return TEE_ERROR_BAD_PARAMETERS; | ||
|
|
||
| IMSG("Got value: %u from NW", params[0].value.a); | ||
| EMSG("Got value: %u from NW", params[0].value.a); |
There was a problem hiding this comment.
I think it still should be en I[informal] message and not an E[rror] message here and my other places in this function. Error should only be used when it's indeed an error.
There was a problem hiding this comment.
I will fix the optee-examples fully before you can review in more detail. It was just POC intended for giving a view how to use the TEE -> REE service.
| TEE_UUID ree_uuid = TA_HELLO_WORLD_REE_UUID; | ||
| TEE_Result result = TEE_SUCCESS; | ||
| TEE_REESessionHandle ree_sess = NULL; | ||
| uint32_t ret_origin = 0, paramTypes; |
There was a problem hiding this comment.
Please put paramTypes on its own line (and initialize the variable).
| result = TEE_OpenREESession(&ree_uuid, 0, 0, NULL, | ||
| &ree_sess, &ret_origin); | ||
| if (result != TEE_SUCCESS) { | ||
| DMSG("Failed to open up REE Session\n"); |
There was a problem hiding this comment.
This is indeed an error, so here you should use EMSG.
| result = TEE_InvokeREECommand(ree_sess, 0, HELLO_WORLD_MSG, | ||
| paramTypes, ree_params, &ret_origin); | ||
| if (result != TEE_SUCCESS) { | ||
| DMSG("Failed to invoke REE command\n"); |
| TEE_REESessionHandle ree_sess = NULL; | ||
| uint32_t ret_origin = 0, paramTypes; | ||
| char msg[] = "Hello! from TEE"; | ||
| TEE_Param ree_params[4]; |
There was a problem hiding this comment.
Nothing wrong as such, but I think the general convention seems to be to just simply call this "params"
| void *service; | ||
| REEC_UUID ree_uuid = TA_HELLO_WORLD_REE_UUID; | ||
|
|
||
| #if 0 |
There was a problem hiding this comment.
I will refactor the code, so, as to clearly demonstrate the functionality. I think you may have already figured out, that there are 2 methods to avail REE custom service.
o msgq
o dynlib
So, for my testing purposes, I was enabling either 1 of them.
On a side note, I need help in putting the generated dynlib into filesystem tarball which is generated in the end. I didn't spend enough time in the build system, as a quick hack (from out-br folder) was available to copy dynlib to the running board.
There was a problem hiding this comment.
What's dynlib? Is msgq Posix Message Queues?
There was a problem hiding this comment.
dynlib -> dynamic library (.so).
msgq -> Yes Posix Message Queue.
| TEEC_CloseSession(&sess); | ||
|
|
||
| TEEC_FinalizeContext(&ctx); | ||
| #if 0 |
There was a problem hiding this comment.
Ditto? If this is something we don't want to use by default, then I think it's better to add a compile time flag.
There was a problem hiding this comment.
I will create separate flows for message queues and dynamic lib, so, both will be enabled by default.
|
Another suggestion here would be to create a new folder |
Signed-off-by: Divneil Rai Wadhawan <divneil.r.wadhawan@intel.com>
I thought of creating a new folder |
I'm not too picky about that, try to come up with a name of a folder that has something to do with the example host/ta that you're trying to implement. You can see the rationale behind the ones we already have here: https://optee.readthedocs.io/en/latest/building/gits/optee_examples/optee_examples.html#example-applications But the concept is the same in all for them. ./aes
./aes/ta
./aes/host
./hello_world
./hello_world/ta
./hello_world/host
....If you need to add other code/libraries to fulfill the implementation of your example, then put it under "your" example folder. I've said a lot, did I manage to answer your question? :) Btw, when you're code has been merged, I'd kindly ask you to also submit a documentation update for things like this. |
Honestly, I am unable to come up with a small catchy name. I will try with Hmm, I will rephrase the question. Earlier, I was pretty abstract. So, if I need push a patch in let's say
Definitely. |
- Supporting both message receiving: msgq and dll - Reverted changes done in hello_world Signed-off-by: Divneil Rai Wadhawan <divneil.r.wadhawan@intel.com>
o one artifact remained in hello_world. Deleted it. Signed-off-by: Divneil Rai Wadhawan <divneil.r.wadhawan@intel.com>
| * | ||
| * - Dynamic Library : The library needs to be developed with a specific | ||
| * function signature and compiled as .so and placed | ||
| * in a PATH (/lib64) where tee-supplicant can find |
There was a problem hiding this comment.
suggest to replace /lib64 with i.e. /lib64 or even /lib.
| #include <string.h> | ||
| #include <stdlib.h> | ||
| #include <errno.h> | ||
| #include <pthread.h> |
There was a problem hiding this comment.
minor: sort in alpha ordering
| @@ -0,0 +1,13 @@ | |||
| CFG_TEE_TA_LOG_LEVEL ?= 4 | |||
There was a problem hiding this comment.
minor: maybe 2 or 3 as default trace level.
| ree_session_handle ree_sess = NULL; | ||
| TEE_Result result = TEE_SUCCESS; | ||
| TEE_Param ree_params[4] = {0}; | ||
| uint32_t param_types; |
There was a problem hiding this comment.
prefer always initialize local variables where defined, here add = 0.
| * to be careful while reading the string data and not read | ||
| * more than the buffer allocated. This is just for reference. | ||
| */ | ||
| EMSG("REE filled buffer: %s\n", (char *)ree_params[2].memref.buffer); |
There was a problem hiding this comment.
As this is not an effective error, prefer MSG().
Regarding comment above, I think this print should also implement required checks: buffer size still <= 64 and contains a terminal \0.
| */ | ||
|
|
||
| #ifndef __TA_HELLO_REE_H__ | ||
| #define __TA_HELLO_REE_H__ |
There was a problem hiding this comment.
__HELLO_REE_TA_H__ as per filename.
Signed-off-by: Divneil Rai Wadhawan divneil.r.wadhawan@intel.com