linaro-swg / optee_examples

OP-TEE Sample Applications
Other
163 stars 140 forks source link

plugins: example of using supplicant syslog plugin from TA code #79

Closed anisyanka closed 3 years ago

anisyanka commented 3 years ago

TEE clients can add to the tee-supplicant an own plugin. This feature makes the supplicant a bit more flexible in terms of providing services. Any external TEE services can be designed as a tee-supplicant plugin.

User TAs and also the OP-TEE kernel code can interact with the plugins with the help of the special PRC.

This patch adds example of using the plugin framework. By default in tee-supplicant there is 'syslog' plugin. It can write log messages from OP-TEE (TAs or kernel) to system log. You can find the implementation of the plugin in 'tee-supplicant/plugins/syslog/syslog_plugin.c' file.

This example adds a new TA, which interacts with 'syslog' plugin with the help of the plugin-pta. This TA increments a value and prints some strings to the syslog. Also patch adds a host CA, which calls the TA 'TA_PING_CNT' times.

If the example works successfully, we can find the following strings in the log file (for qemu it's '/var/log/messages' file):

21:18:05 buildroot daemon.info tee-supplicant[92]: Hello, plugin! value = 0x0
21:18:07 buildroot daemon.info tee-supplicant[92]: Hello, plugin! value = 0x1
21:18:09 buildroot daemon.info tee-supplicant[92]: Hello, plugin! value = 0x2
21:18:11 buildroot daemon.info tee-supplicant[92]: Hello, plugin! value = 0x3
21:18:13 buildroot daemon.info tee-supplicant[92]: Hello, plugin! value = 0x4

Signed-off-by: Aleksandr Anisimov a.anisimov@omprussia.ru

anisyanka commented 3 years ago

The example relates to: https://github.com/OP-TEE/optee_client/pull/239 https://github.com/OP-TEE/optee_os/pull/4248

anisyanka commented 3 years ago

It would be nice to have a Cmake script. I'll see if I can help.

Do you mean Cmake script to build syslog plugin here? Or maybe you need script in optee-client repo to build any future plugins?

The supplicant plugin syslog shall be built as a .so and installed in /usr/lib/tee-supplicant/plugins/ right?

Yes, it's right.

anisyanka commented 3 years ago

All comments have been addressed

anisyanka commented 3 years ago

All comments have been addressed

anisyanka commented 3 years ago

All comments have been addressed

jenswi-linaro commented 3 years ago

Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

anisyanka commented 3 years ago

The commit updated, thanks for the review!