Re: [PATCHv2 2/2] tpm_ftpm_tee: register driver on TEE bus

From: Maxim Uvarov
Date: Mon May 25 2020 - 02:51:01 EST


On Fri, 22 May 2020 at 23:03, Jarkko Sakkinen
<jarkko.sakkinen@xxxxxxxxxxxxxxx> wrote:
>
> On Fri, May 22, 2020 at 10:29:44PM +0300, Maxim Uvarov wrote:
> > On Fri, 22 May 2020 at 20:15, Jarkko Sakkinen
> > <jarkko.sakkinen@xxxxxxxxxxxxxxx> wrote:
> > >
> > > On Thu, May 21, 2020 at 09:47:43AM +0300, Maxim Uvarov wrote:
> > > > Register driver on TEE bus. module tee registers bus,
> > >
> > > "on the TEE bus"
> > >
> > > "The module tee"
> > >
> > > > and module optee calls optee_enumerate_devices() to scan
> > > > all devices on the bus. Trusted Application for this driver
> > >
> > > Looking at drivers/tee, it shows that tee and optee are in fact the same
> > > module as opposed to what your commit message says.
> > >
> >
> > In the current kernel it's 2 different modules.
> >
> > > > can be Early TA's (can be compiled into optee-os). In that
> > > > case it will be on OPTEE bus before linux booting. Also
> > > > optee-suplicant application is needed to be loaded between
> > > > OPTEE module and ftpm module to maintain functionality
> > > > for fTPM driver.
> > >
> > > Why is this needed and why things worked before having this?
> > >
> >
> > Before these changes user space has to drive boot sequence. I.e. tee
> > and optee modules loads, then application tee-supplicant has to start
> > and only then module ftpm can be loaded. The reason for that is
> > storage services are implemented in userspace and driver needs them.
>
> Is the TPM implementation uploaded to TEE from user space and or what
> storage are we talking about? Not sure how these storage services
> connect to the TPM.
>
> /Jarkko

Jakko,
tee-supplicant application provides state machine over callbacks with
RPC messages.
https://github.com/OP-TEE/optee_client/blob/master/tee-supplicant/src/tee_supplicant.c#L614
It also allocates shm. Without running tee-supplicant
tee_client_open_session() will fail.
optee_open_session()->get_msg_arg()->tee_shm_alloc()->...
Optee team wanted to remove some dependencies from tee-supplicant with
moving code
to the kernel. But for now I think that should be out of the scope of
current patches due to
they fix driver initialization on tee bus without breaking current
functionality.

Maxim.