Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-29 Thread Jens Wiklander
On Fri, Jun 26, 2020 at 08:11:21AM -0700, James Bottomley wrote:
> On Fri, 2020-06-26 at 12:29 +0100, Daniel Thompson wrote:
> > On Fri, Jun 26, 2020 at 10:40:41AM +0530, Sumit Garg wrote:
> > > On Fri, 26 Jun 2020 at 05:01, James Bottomley
> > >  wrote:
> > > > 
> > > > On Thu, 2020-06-25 at 19:54 +0530, Sumit Garg wrote:
> > > > > On Wed, 24 Jun 2020 at 20:51, James Bottomley
> > > > >  wrote:
> > > > > > 
> > > > > > On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> > > > > > > Apologies for delay in my reply as I was busy with some
> > > > > > > other stuff.
> > > > > > > 
> > > > > > > On Fri, 19 Jun 2020 at 20:30, James Bottomley
> > > > > > >  wrote:
> > > > > > 
> > > > > > [...]
> > > > > > > > it's about consistency with what the kernel types
> > > > > > > > mean.  When some checker detects your using little endian
> > > > > > > > operations on a big endian structure (like in the prink
> > > > > > > > for instance) they're going to keep emailing you about
> > > > > > > > it.
> > > > > > > 
> > > > > > > As mentioned above, using different terminology is meant to
> > > > > > > cause more confusion than just difference in endianness
> > > > > > > which is manageable inside TEE.
> > > > > > > 
> > > > > > > And I think it's safe to say that the kernel implements
> > > > > > > UUID in big endian format and thus uses %pUb whereas OP-TEE
> > > > > > > implements UUID in little endian format and thus uses %pUl.
> > > > > > 
> > > > > > So what I think you're saying is that if we still had uuid_be
> > > > > > and uuid_le you'd use uuid_le, because that's exactly the
> > > > > > structure described in the docs.  But because we renamed
> > > > > > 
> > > > > > uuid_be -> uuid_t
> > > > > > uuid_le -> guid_t
> > > > > > 
> > > > > > You can't use guid_t as a kernel type because it has the
> > > > > > wrong name?
> > > > > 
> > > > > Isn't the rename commit description [1] pretty clear about
> > > > > which is the true UUID type from Linux point of view?
> > > > 
> > > > I don't think the kernel code takes a position on eternal verity,
> > > > just on logical or arithmetic truth.  We just have to deal with
> > > > both LE and BE UUIDs so we have appropriate types for them and
> > > > the LE type is now named guid_t.  They're both equally correct to
> > > > use provided the use case matches the designed one. So does the
> > > > name really matter?
> > > 
> > > Yes it does. I guess I have provided enough reasoning for that.
> > > Also, the rename commit itself illustrates its importance and
> > > clarifies the use case for which they are meant to be used.
> > > 
> > > > If we did
> > > > 
> > > > #define uuid_le_t guid_t
> > > > 
> > > > would you be happy? (not that the kernel cares about karmic
> > > > emotional states either ...)
> > > 
> > > It's not about me being happy but more about confusion and
> > > inconsistency it will bring.
> > > 
> > > IMO, either kernel should be opinionated about UUID endianness like
> > > currently it is:
> > > 
> > > uuid_t and its corresponding helpers (eg. UUID_INIT) follows BE
> > > format.
> > > 
> > > or support both endianness for UUID (no common type: uuid_t) like
> > > we had earlier prior to rename commit:
> > > 
> > > uuid_be_t and its corresponding helpers (eg. UUID_BE_INIT) follow
> > > BE format. uuid_le_t and its corresponding helpers (eg.
> > > UUID_LE_INIT) follow LE format.
> > > 
> > > But even if we consider later case as well, I am still not sure if
> > > we can switch to uuid_le_t as it's been part of TEE core ABI
> > > (open_session) where UUID is passed in BE format (see LE to BE
> > > conversion in TEE client [1] and vice-versa in OP-TEE OS [2]) and
> > > won't be a backwards compatible change.
> > > 
> > > [1] https://github.com/OP-TEE/optee_client/blob/master/libteec/src/
> > > tee_client_api.c#L595
> > > [2] https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/ke
> > > rnel/ree_fs_ta.c#L92
> > 
> > I'm struck that all references here are to code that does not run in
> > kernel space. Frankly on LKML I don't know if we should even *care*
> > what format UUIDs are stored in other address spaces.
> > 
> > We care about is the endianness of the UUID on the interface
> > boundaries into and out of the kernel[1] and we care that we use the
> > correct kernel type to describe it.
> > 
> > I understood from Jerome's post that the UUID that the kernel
> > manipulates are, in fact, big endian and that they should be called
> > uuid_t.
> > 
> > Is there more going on here or is that it?
> 
> As you say, a UUID to the kernel is a binary blob except for input,
> which to the kernel is INIT_UUID or INIT_GUID and output, which is
> either printk %Ub for uuid_t or %Ul for guid_t.
> 
> The bit I objected to was doing a %Ul on a uuid_t because it's going to
> trip the static checkers.  That shows me there's a confusion in the
> code between little and big endian UUID types, but I haven't looked
> further than that.

Thanks for bringing our attention to 

Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-29 Thread Sumit Garg
On Fri, 26 Jun 2020 at 20:41, James Bottomley
 wrote:
>
> On Fri, 2020-06-26 at 12:29 +0100, Daniel Thompson wrote:
> > On Fri, Jun 26, 2020 at 10:40:41AM +0530, Sumit Garg wrote:
> > > On Fri, 26 Jun 2020 at 05:01, James Bottomley
> > >  wrote:
> > > >
> > > > On Thu, 2020-06-25 at 19:54 +0530, Sumit Garg wrote:
> > > > > On Wed, 24 Jun 2020 at 20:51, James Bottomley
> > > > >  wrote:
> > > > > >
> > > > > > On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> > > > > > > Apologies for delay in my reply as I was busy with some
> > > > > > > other stuff.
> > > > > > >
> > > > > > > On Fri, 19 Jun 2020 at 20:30, James Bottomley
> > > > > > >  wrote:
> > > > > >
> > > > > > [...]
> > > > > > > > it's about consistency with what the kernel types
> > > > > > > > mean.  When some checker detects your using little endian
> > > > > > > > operations on a big endian structure (like in the prink
> > > > > > > > for instance) they're going to keep emailing you about
> > > > > > > > it.
> > > > > > >
> > > > > > > As mentioned above, using different terminology is meant to
> > > > > > > cause more confusion than just difference in endianness
> > > > > > > which is manageable inside TEE.
> > > > > > >
> > > > > > > And I think it's safe to say that the kernel implements
> > > > > > > UUID in big endian format and thus uses %pUb whereas OP-TEE
> > > > > > > implements UUID in little endian format and thus uses %pUl.
> > > > > >
> > > > > > So what I think you're saying is that if we still had uuid_be
> > > > > > and uuid_le you'd use uuid_le, because that's exactly the
> > > > > > structure described in the docs.  But because we renamed
> > > > > >
> > > > > > uuid_be -> uuid_t
> > > > > > uuid_le -> guid_t
> > > > > >
> > > > > > You can't use guid_t as a kernel type because it has the
> > > > > > wrong name?
> > > > >
> > > > > Isn't the rename commit description [1] pretty clear about
> > > > > which is the true UUID type from Linux point of view?
> > > >
> > > > I don't think the kernel code takes a position on eternal verity,
> > > > just on logical or arithmetic truth.  We just have to deal with
> > > > both LE and BE UUIDs so we have appropriate types for them and
> > > > the LE type is now named guid_t.  They're both equally correct to
> > > > use provided the use case matches the designed one. So does the
> > > > name really matter?
> > >
> > > Yes it does. I guess I have provided enough reasoning for that.
> > > Also, the rename commit itself illustrates its importance and
> > > clarifies the use case for which they are meant to be used.
> > >
> > > > If we did
> > > >
> > > > #define uuid_le_t guid_t
> > > >
> > > > would you be happy? (not that the kernel cares about karmic
> > > > emotional states either ...)
> > >
> > > It's not about me being happy but more about confusion and
> > > inconsistency it will bring.
> > >
> > > IMO, either kernel should be opinionated about UUID endianness like
> > > currently it is:
> > >
> > > uuid_t and its corresponding helpers (eg. UUID_INIT) follows BE
> > > format.
> > >
> > > or support both endianness for UUID (no common type: uuid_t) like
> > > we had earlier prior to rename commit:
> > >
> > > uuid_be_t and its corresponding helpers (eg. UUID_BE_INIT) follow
> > > BE format. uuid_le_t and its corresponding helpers (eg.
> > > UUID_LE_INIT) follow LE format.
> > >
> > > But even if we consider later case as well, I am still not sure if
> > > we can switch to uuid_le_t as it's been part of TEE core ABI
> > > (open_session) where UUID is passed in BE format (see LE to BE
> > > conversion in TEE client [1] and vice-versa in OP-TEE OS [2]) and
> > > won't be a backwards compatible change.
> > >
> > > [1] https://github.com/OP-TEE/optee_client/blob/master/libteec/src/
> > > tee_client_api.c#L595
> > > [2] https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/ke
> > > rnel/ree_fs_ta.c#L92
> >
> > I'm struck that all references here are to code that does not run in
> > kernel space. Frankly on LKML I don't know if we should even *care*
> > what format UUIDs are stored in other address spaces.
> >
> > We care about is the endianness of the UUID on the interface
> > boundaries into and out of the kernel[1] and we care that we use the
> > correct kernel type to describe it.
> >
> > I understood from Jerome's post that the UUID that the kernel
> > manipulates are, in fact, big endian and that they should be called
> > uuid_t.
> >
> > Is there more going on here or is that it?
>
> As you say, a UUID to the kernel is a binary blob except for input,
> which to the kernel is INIT_UUID or INIT_GUID and output, which is
> either printk %Ub for uuid_t or %Ul for guid_t.
>
> The bit I objected to was doing a %Ul on a uuid_t because it's going to
> trip the static checkers.

This is exactly which is fixed in v9 patch-set to use %Ub on a uuid_t.

>  That shows me there's a confusion in the
> code between little and big endian UUID types, but I haven't looked
> further than that.

Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-26 Thread James Bottomley
On Fri, 2020-06-26 at 12:29 +0100, Daniel Thompson wrote:
> On Fri, Jun 26, 2020 at 10:40:41AM +0530, Sumit Garg wrote:
> > On Fri, 26 Jun 2020 at 05:01, James Bottomley
> >  wrote:
> > > 
> > > On Thu, 2020-06-25 at 19:54 +0530, Sumit Garg wrote:
> > > > On Wed, 24 Jun 2020 at 20:51, James Bottomley
> > > >  wrote:
> > > > > 
> > > > > On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> > > > > > Apologies for delay in my reply as I was busy with some
> > > > > > other stuff.
> > > > > > 
> > > > > > On Fri, 19 Jun 2020 at 20:30, James Bottomley
> > > > > >  wrote:
> > > > > 
> > > > > [...]
> > > > > > > it's about consistency with what the kernel types
> > > > > > > mean.  When some checker detects your using little endian
> > > > > > > operations on a big endian structure (like in the prink
> > > > > > > for instance) they're going to keep emailing you about
> > > > > > > it.
> > > > > > 
> > > > > > As mentioned above, using different terminology is meant to
> > > > > > cause more confusion than just difference in endianness
> > > > > > which is manageable inside TEE.
> > > > > > 
> > > > > > And I think it's safe to say that the kernel implements
> > > > > > UUID in big endian format and thus uses %pUb whereas OP-TEE
> > > > > > implements UUID in little endian format and thus uses %pUl.
> > > > > 
> > > > > So what I think you're saying is that if we still had uuid_be
> > > > > and uuid_le you'd use uuid_le, because that's exactly the
> > > > > structure described in the docs.  But because we renamed
> > > > > 
> > > > > uuid_be -> uuid_t
> > > > > uuid_le -> guid_t
> > > > > 
> > > > > You can't use guid_t as a kernel type because it has the
> > > > > wrong name?
> > > > 
> > > > Isn't the rename commit description [1] pretty clear about
> > > > which is the true UUID type from Linux point of view?
> > > 
> > > I don't think the kernel code takes a position on eternal verity,
> > > just on logical or arithmetic truth.  We just have to deal with
> > > both LE and BE UUIDs so we have appropriate types for them and
> > > the LE type is now named guid_t.  They're both equally correct to
> > > use provided the use case matches the designed one. So does the
> > > name really matter?
> > 
> > Yes it does. I guess I have provided enough reasoning for that.
> > Also, the rename commit itself illustrates its importance and
> > clarifies the use case for which they are meant to be used.
> > 
> > > If we did
> > > 
> > > #define uuid_le_t guid_t
> > > 
> > > would you be happy? (not that the kernel cares about karmic
> > > emotional states either ...)
> > 
> > It's not about me being happy but more about confusion and
> > inconsistency it will bring.
> > 
> > IMO, either kernel should be opinionated about UUID endianness like
> > currently it is:
> > 
> > uuid_t and its corresponding helpers (eg. UUID_INIT) follows BE
> > format.
> > 
> > or support both endianness for UUID (no common type: uuid_t) like
> > we had earlier prior to rename commit:
> > 
> > uuid_be_t and its corresponding helpers (eg. UUID_BE_INIT) follow
> > BE format. uuid_le_t and its corresponding helpers (eg.
> > UUID_LE_INIT) follow LE format.
> > 
> > But even if we consider later case as well, I am still not sure if
> > we can switch to uuid_le_t as it's been part of TEE core ABI
> > (open_session) where UUID is passed in BE format (see LE to BE
> > conversion in TEE client [1] and vice-versa in OP-TEE OS [2]) and
> > won't be a backwards compatible change.
> > 
> > [1] https://github.com/OP-TEE/optee_client/blob/master/libteec/src/
> > tee_client_api.c#L595
> > [2] https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/ke
> > rnel/ree_fs_ta.c#L92
> 
> I'm struck that all references here are to code that does not run in
> kernel space. Frankly on LKML I don't know if we should even *care*
> what format UUIDs are stored in other address spaces.
> 
> We care about is the endianness of the UUID on the interface
> boundaries into and out of the kernel[1] and we care that we use the
> correct kernel type to describe it.
> 
> I understood from Jerome's post that the UUID that the kernel
> manipulates are, in fact, big endian and that they should be called
> uuid_t.
> 
> Is there more going on here or is that it?

As you say, a UUID to the kernel is a binary blob except for input,
which to the kernel is INIT_UUID or INIT_GUID and output, which is
either printk %Ub for uuid_t or %Ul for guid_t.

The bit I objected to was doing a %Ul on a uuid_t because it's going to
trip the static checkers.  That shows me there's a confusion in the
code between little and big endian UUID types, but I haven't looked
further than that.

James



Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-26 Thread Daniel Thompson
On Fri, Jun 26, 2020 at 10:40:41AM +0530, Sumit Garg wrote:
> On Fri, 26 Jun 2020 at 05:01, James Bottomley
>  wrote:
> >
> > On Thu, 2020-06-25 at 19:54 +0530, Sumit Garg wrote:
> > > On Wed, 24 Jun 2020 at 20:51, James Bottomley
> > >  wrote:
> > > >
> > > > On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> > > > > Apologies for delay in my reply as I was busy with some other
> > > > > stuff.
> > > > >
> > > > > On Fri, 19 Jun 2020 at 20:30, James Bottomley
> > > > >  wrote:
> > > >
> > > > [...]
> > > > > > it's about consistency with what the kernel types mean.  When
> > > > > > some checker detects your using little endian operations on a
> > > > > > big endian structure (like in the prink for instance) they're
> > > > > > going to keep emailing you about it.
> > > > >
> > > > > As mentioned above, using different terminology is meant to cause
> > > > > more confusion than just difference in endianness which is
> > > > > manageable inside TEE.
> > > > >
> > > > > And I think it's safe to say that the kernel implements UUID in
> > > > > big endian format and thus uses %pUb whereas OP-TEE implements
> > > > > UUID in little endian format and thus uses %pUl.
> > > >
> > > > So what I think you're saying is that if we still had uuid_be and
> > > > uuid_le you'd use uuid_le, because that's exactly the structure
> > > > described in the docs.  But because we renamed
> > > >
> > > > uuid_be -> uuid_t
> > > > uuid_le -> guid_t
> > > >
> > > > You can't use guid_t as a kernel type because it has the wrong
> > > > name?
> > >
> > > Isn't the rename commit description [1] pretty clear about which is
> > > the true UUID type from Linux point of view?
> >
> > I don't think the kernel code takes a position on eternal verity, just
> > on logical or arithmetic truth.  We just have to deal with both LE and
> > BE UUIDs so we have appropriate types for them and the LE type is now
> > named guid_t.  They're both equally correct to use provided the use
> > case matches the designed one. So does the name really matter?
> 
> Yes it does. I guess I have provided enough reasoning for that. Also,
> the rename commit itself illustrates its importance and clarifies the
> use case for which they are meant to be used.
> 
> > If we
> > did
> >
> > #define uuid_le_t guid_t
> >
> > would you be happy? (not that the kernel cares about karmic emotional
> > states either ...)
> 
> It's not about me being happy but more about confusion and
> inconsistency it will bring.
> 
> IMO, either kernel should be opinionated about UUID endianness like
> currently it is:
> 
> uuid_t and its corresponding helpers (eg. UUID_INIT) follows BE format.
> 
> or support both endianness for UUID (no common type: uuid_t) like we
> had earlier prior to rename commit:
> 
> uuid_be_t and its corresponding helpers (eg. UUID_BE_INIT) follow BE format.
> uuid_le_t and its corresponding helpers (eg. UUID_LE_INIT) follow LE format.
> 
> But even if we consider later case as well, I am still not sure if we
> can switch to uuid_le_t as it's been part of TEE core ABI
> (open_session) where UUID is passed in BE format (see LE to BE
> conversion in TEE client [1] and vice-versa in OP-TEE OS [2]) and
> won't be a backwards compatible change.
> 
> [1] 
> https://github.com/OP-TEE/optee_client/blob/master/libteec/src/tee_client_api.c#L595
> [2] 
> https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/kernel/ree_fs_ta.c#L92

I'm struck that all references here are to code that does not run in
kernel space. Frankly on LKML I don't know if we should even *care* what
format UUIDs are stored in other address spaces.

We care about is the endianness of the UUID on the interface boundaries
into and out of the kernel[1] and we care that we use the correct kernel
type to describe it.

I understood from Jerome's post that the UUID that the kernel
manipulates are, in fact, big endian and that they should be called
uuid_t.

Is there more going on here or is that it?


Daniel.


[1] I guess we'd also like those interface boundaries to be reasonably
sane but if they already exist and are the interface is consistent
about endianness then I find it hard to see no reason for a
gratuitous endianness change.


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-26 Thread Andy Shevchenko
On Fri, Jun 26, 2020 at 8:18 AM Sumit Garg  wrote:
> On Thu, 25 Jun 2020 at 18:22, Maxim Uvarov  wrote:

...

> I guess you missed the point that uuid_t is implemented in BE format
> in the kernel which is compliant as per RFC 4122.

I guess you missed the point. Kernel doesn't have anything special
about these types and does NOT compliant as per RFC.
The only things the kernel distinguishes are a) byte order (always),
and b) version bits when you get a random UUID (whatever you call it).

I guess this discussion takes too much time. The idea is that kernel
types are just for kernel use with as little intrusion as possible.
The main principle, we get something, we carry it w/o modifications
inside the kernel.

So, you may use whatever you want and LE/BE is purely based on a) and b) above.

-- 
With Best Regards,
Andy Shevchenko


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-26 Thread Sumit Garg
On Fri, 26 Jun 2020 at 10:40, Sumit Garg  wrote:
>
> On Fri, 26 Jun 2020 at 05:01, James Bottomley
>  wrote:
> >
> > On Thu, 2020-06-25 at 19:54 +0530, Sumit Garg wrote:
> > > On Wed, 24 Jun 2020 at 20:51, James Bottomley
> > >  wrote:
> > > >
> > > > On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> > > > > Apologies for delay in my reply as I was busy with some other
> > > > > stuff.
> > > > >
> > > > > On Fri, 19 Jun 2020 at 20:30, James Bottomley
> > > > >  wrote:
> > > >
> > > > [...]
> > > > > > it's about consistency with what the kernel types mean.  When
> > > > > > some checker detects your using little endian operations on a
> > > > > > big endian structure (like in the prink for instance) they're
> > > > > > going to keep emailing you about it.
> > > > >
> > > > > As mentioned above, using different terminology is meant to cause
> > > > > more confusion than just difference in endianness which is
> > > > > manageable inside TEE.
> > > > >
> > > > > And I think it's safe to say that the kernel implements UUID in
> > > > > big endian format and thus uses %pUb whereas OP-TEE implements
> > > > > UUID in little endian format and thus uses %pUl.
> > > >
> > > > So what I think you're saying is that if we still had uuid_be and
> > > > uuid_le you'd use uuid_le, because that's exactly the structure
> > > > described in the docs.  But because we renamed
> > > >
> > > > uuid_be -> uuid_t
> > > > uuid_le -> guid_t
> > > >
> > > > You can't use guid_t as a kernel type because it has the wrong
> > > > name?
> > >
> > > Isn't the rename commit description [1] pretty clear about which is
> > > the true UUID type from Linux point of view?
> >
> > I don't think the kernel code takes a position on eternal verity, just
> > on logical or arithmetic truth.  We just have to deal with both LE and
> > BE UUIDs so we have appropriate types for them and the LE type is now
> > named guid_t.  They're both equally correct to use provided the use
> > case matches the designed one. So does the name really matter?
>
> Yes it does. I guess I have provided enough reasoning for that. Also,
> the rename commit itself illustrates its importance and clarifies the
> use case for which they are meant to be used.
>
> > If we
> > did
> >
> > #define uuid_le_t guid_t
> >
> > would you be happy? (not that the kernel cares about karmic emotional
> > states either ...)
>
> It's not about me being happy but more about confusion and
> inconsistency it will bring.
>
> IMO, either kernel should be opinionated about UUID endianness like
> currently it is:
>
> uuid_t and its corresponding helpers (eg. UUID_INIT) follows BE format.
>
> or support both endianness for UUID (no common type: uuid_t) like we
> had earlier prior to rename commit:
>
> uuid_be_t and its corresponding helpers (eg. UUID_BE_INIT) follow BE format.
> uuid_le_t and its corresponding helpers (eg. UUID_LE_INIT) follow LE format.
>
> But even if we consider later case as well, I am still not sure if we
> can switch to uuid_le_t as it's been part of TEE core ABI
> (open_session) where UUID is passed in BE format (see LE to BE
> conversion in TEE client [1] and vice-versa in OP-TEE OS [2]) and
> won't be a backwards compatible change.
>
> [1] 
> https://github.com/OP-TEE/optee_client/blob/master/libteec/src/tee_client_api.c#L595
> [2] 
> https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/kernel/ree_fs_ta.c#L92

Sorry, the second reference is incorrect, correct one is:

[2] 
https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/tee/entry_std.c#L279

-Sumit

>
> -Sumit
>
> >
> > James
> >


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-25 Thread Sumit Garg
On Thu, 25 Jun 2020 at 18:22, Maxim Uvarov  wrote:
>
> On Wed, 24 Jun 2020 at 18:44, Jerome Forissier  wrote:
> >
> >
> >
> > On 6/24/20 5:21 PM, James Bottomley wrote:
> > > On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> > >> Apologies for delay in my reply as I was busy with some other stuff.
> > >>
> > >> On Fri, 19 Jun 2020 at 20:30, James Bottomley
> > >>  wrote:
> > > [...]
> > >>> it's about consistency with what the kernel types mean.  When some
> > >>> checker detects your using little endian operations on a big endian
> > >>> structure (like in the prink for instance) they're going to keep
> > >>> emailing you about it.
> > >>
> > >> As mentioned above, using different terminology is meant to cause
> > >> more confusion than just difference in endianness which is manageable
> > >> inside TEE.
> > >>
> > >> And I think it's safe to say that the kernel implements UUID in big
> > >> endian format and thus uses %pUb whereas OP-TEE implements UUID in
> > >> little endian format and thus uses %pUl.
> > >
> > > So what I think you're saying is that if we still had uuid_be and
> > > uuid_le you'd use uuid_le, because that's exactly the structure
> > > described in the docs.  But because we renamed
> > >
> > > uuid_be -> uuid_t
> > > uuid_le -> guid_t
> > >
> > > You can't use guid_t as a kernel type because it has the wrong name?
> >
> > Let me try to clear the confusion that I introduce myself I believe :-/
> > IMO:
> >
> > - optee_register_device(const uuid_t *device_uuid) *is* the correct
> > prototype.
> > - device_uuid is *guaranteed* to be BE because OP-TEE makes this
> > guarantee (it converts from its internal LE representation to BE when
> > enumerating the devices, but it doesn't matter to the kernel).
> > - Therefore %pUb is the correct format.
> >
> > I'm sorry for doubting the BE order initially. I am so used to OP-TEE
> > using LE internally, that I missed the fact that we have an explicit
> > conversion...
> >
> > Does this sound good?
> >
> > Thanks,
> > --
> > Jerome
>
> I think your description is correct. But I think this problem  would
> be solved outside of the current patchset.
> All places should use one single format (LE):
> -  internal optee representation;
> -  device enumeration pta;
> -  this kernel driver which creates sysfs entry and sets
> uid_copy(_device->id.uuid, device_uuid);
> -  matching function;
> -  drivers use UUID_INIT();
>
> In that way everything will be consistent. But it will require
> changing other pieces, not just the kernel. While
> these patches add functionality to support current device enumeration
> in optee os.
> So I think this version is ok to be applied.

I guess here you meant v9 patch-set. If yes then it's fine with me as well.

-Sumit

>
> Regards,
> Maxim.


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-25 Thread Sumit Garg
On Thu, 25 Jun 2020 at 18:22, Maxim Uvarov  wrote:
>
> On Wed, 24 Jun 2020 at 18:44, Jerome Forissier  wrote:
> >
> >
> >
> > On 6/24/20 5:21 PM, James Bottomley wrote:
> > > On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> > >> Apologies for delay in my reply as I was busy with some other stuff.
> > >>
> > >> On Fri, 19 Jun 2020 at 20:30, James Bottomley
> > >>  wrote:
> > > [...]
> > >>> it's about consistency with what the kernel types mean.  When some
> > >>> checker detects your using little endian operations on a big endian
> > >>> structure (like in the prink for instance) they're going to keep
> > >>> emailing you about it.
> > >>
> > >> As mentioned above, using different terminology is meant to cause
> > >> more confusion than just difference in endianness which is manageable
> > >> inside TEE.
> > >>
> > >> And I think it's safe to say that the kernel implements UUID in big
> > >> endian format and thus uses %pUb whereas OP-TEE implements UUID in
> > >> little endian format and thus uses %pUl.
> > >
> > > So what I think you're saying is that if we still had uuid_be and
> > > uuid_le you'd use uuid_le, because that's exactly the structure
> > > described in the docs.  But because we renamed
> > >
> > > uuid_be -> uuid_t
> > > uuid_le -> guid_t
> > >
> > > You can't use guid_t as a kernel type because it has the wrong name?
> >
> > Let me try to clear the confusion that I introduce myself I believe :-/
> > IMO:
> >
> > - optee_register_device(const uuid_t *device_uuid) *is* the correct
> > prototype.
> > - device_uuid is *guaranteed* to be BE because OP-TEE makes this
> > guarantee (it converts from its internal LE representation to BE when
> > enumerating the devices, but it doesn't matter to the kernel).
> > - Therefore %pUb is the correct format.
> >
> > I'm sorry for doubting the BE order initially. I am so used to OP-TEE
> > using LE internally, that I missed the fact that we have an explicit
> > conversion...
> >
> > Does this sound good?
> >
> > Thanks,
> > --
> > Jerome
>
> I think your description is correct. But I think this problem  would
> be solved outside of the current patchset.
> All places should use one single format (LE):

I guess you missed the point that uuid_t is implemented in BE format
in the kernel which is compliant as per RFC 4122.

> -  internal optee representation;
> -  device enumeration pta;
> -  this kernel driver which creates sysfs entry and sets
> uid_copy(_device->id.uuid, device_uuid);
> -  matching function;
> -  drivers use UUID_INIT();

See carefully the implementation of UUID_INIT() which is in BE format.

-Sumit

>
> In that way everything will be consistent. But it will require
> changing other pieces, not just the kernel. While
> these patches add functionality to support current device enumeration
> in optee os.
> So I think this version is ok to be applied.
>
> Regards,
> Maxim.


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-25 Thread Sumit Garg
On Fri, 26 Jun 2020 at 05:01, James Bottomley
 wrote:
>
> On Thu, 2020-06-25 at 19:54 +0530, Sumit Garg wrote:
> > On Wed, 24 Jun 2020 at 20:51, James Bottomley
> >  wrote:
> > >
> > > On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> > > > Apologies for delay in my reply as I was busy with some other
> > > > stuff.
> > > >
> > > > On Fri, 19 Jun 2020 at 20:30, James Bottomley
> > > >  wrote:
> > >
> > > [...]
> > > > > it's about consistency with what the kernel types mean.  When
> > > > > some checker detects your using little endian operations on a
> > > > > big endian structure (like in the prink for instance) they're
> > > > > going to keep emailing you about it.
> > > >
> > > > As mentioned above, using different terminology is meant to cause
> > > > more confusion than just difference in endianness which is
> > > > manageable inside TEE.
> > > >
> > > > And I think it's safe to say that the kernel implements UUID in
> > > > big endian format and thus uses %pUb whereas OP-TEE implements
> > > > UUID in little endian format and thus uses %pUl.
> > >
> > > So what I think you're saying is that if we still had uuid_be and
> > > uuid_le you'd use uuid_le, because that's exactly the structure
> > > described in the docs.  But because we renamed
> > >
> > > uuid_be -> uuid_t
> > > uuid_le -> guid_t
> > >
> > > You can't use guid_t as a kernel type because it has the wrong
> > > name?
> >
> > Isn't the rename commit description [1] pretty clear about which is
> > the true UUID type from Linux point of view?
>
> I don't think the kernel code takes a position on eternal verity, just
> on logical or arithmetic truth.  We just have to deal with both LE and
> BE UUIDs so we have appropriate types for them and the LE type is now
> named guid_t.  They're both equally correct to use provided the use
> case matches the designed one. So does the name really matter?

Yes it does. I guess I have provided enough reasoning for that. Also,
the rename commit itself illustrates its importance and clarifies the
use case for which they are meant to be used.

> If we
> did
>
> #define uuid_le_t guid_t
>
> would you be happy? (not that the kernel cares about karmic emotional
> states either ...)

It's not about me being happy but more about confusion and
inconsistency it will bring.

IMO, either kernel should be opinionated about UUID endianness like
currently it is:

uuid_t and its corresponding helpers (eg. UUID_INIT) follows BE format.

or support both endianness for UUID (no common type: uuid_t) like we
had earlier prior to rename commit:

uuid_be_t and its corresponding helpers (eg. UUID_BE_INIT) follow BE format.
uuid_le_t and its corresponding helpers (eg. UUID_LE_INIT) follow LE format.

But even if we consider later case as well, I am still not sure if we
can switch to uuid_le_t as it's been part of TEE core ABI
(open_session) where UUID is passed in BE format (see LE to BE
conversion in TEE client [1] and vice-versa in OP-TEE OS [2]) and
won't be a backwards compatible change.

[1] 
https://github.com/OP-TEE/optee_client/blob/master/libteec/src/tee_client_api.c#L595
[2] 
https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/kernel/ree_fs_ta.c#L92

-Sumit

>
> James
>


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-25 Thread James Bottomley
On Thu, 2020-06-25 at 19:54 +0530, Sumit Garg wrote:
> On Wed, 24 Jun 2020 at 20:51, James Bottomley
>  wrote:
> > 
> > On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> > > Apologies for delay in my reply as I was busy with some other
> > > stuff.
> > > 
> > > On Fri, 19 Jun 2020 at 20:30, James Bottomley
> > >  wrote:
> > 
> > [...]
> > > > it's about consistency with what the kernel types mean.  When
> > > > some checker detects your using little endian operations on a
> > > > big endian structure (like in the prink for instance) they're
> > > > going to keep emailing you about it.
> > > 
> > > As mentioned above, using different terminology is meant to cause
> > > more confusion than just difference in endianness which is
> > > manageable inside TEE.
> > > 
> > > And I think it's safe to say that the kernel implements UUID in
> > > big endian format and thus uses %pUb whereas OP-TEE implements
> > > UUID in little endian format and thus uses %pUl.
> > 
> > So what I think you're saying is that if we still had uuid_be and
> > uuid_le you'd use uuid_le, because that's exactly the structure
> > described in the docs.  But because we renamed
> > 
> > uuid_be -> uuid_t
> > uuid_le -> guid_t
> > 
> > You can't use guid_t as a kernel type because it has the wrong
> > name?
> 
> Isn't the rename commit description [1] pretty clear about which is
> the true UUID type from Linux point of view?

I don't think the kernel code takes a position on eternal verity, just
on logical or arithmetic truth.  We just have to deal with both LE and
BE UUIDs so we have appropriate types for them and the LE type is now
named guid_t.  They're both equally correct to use provided the use
case matches the designed one. So does the name really matter?  If we
did

#define uuid_le_t guid_t

would you be happy? (not that the kernel cares about karmic emotional
states either ...)

James



Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-25 Thread Sumit Garg
On Wed, 24 Jun 2020 at 20:51, James Bottomley
 wrote:
>
> On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> > Apologies for delay in my reply as I was busy with some other stuff.
> >
> > On Fri, 19 Jun 2020 at 20:30, James Bottomley
> >  wrote:
> [...]
> > > it's about consistency with what the kernel types mean.  When some
> > > checker detects your using little endian operations on a big endian
> > > structure (like in the prink for instance) they're going to keep
> > > emailing you about it.
> >
> > As mentioned above, using different terminology is meant to cause
> > more confusion than just difference in endianness which is manageable
> > inside TEE.
> >
> > And I think it's safe to say that the kernel implements UUID in big
> > endian format and thus uses %pUb whereas OP-TEE implements UUID in
> > little endian format and thus uses %pUl.
>
> So what I think you're saying is that if we still had uuid_be and
> uuid_le you'd use uuid_le, because that's exactly the structure
> described in the docs.  But because we renamed
>
> uuid_be -> uuid_t
> uuid_le -> guid_t
>
> You can't use guid_t as a kernel type because it has the wrong name?

Isn't the rename commit description [1] pretty clear about which is
the true UUID type from Linux point of view?

[1]
commit f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
Author: Christoph Hellwig 
Date:   Wed May 17 10:02:48 2017 +0200

uuid: rename uuid types

Our "little endian" UUID really is a Wintel GUID, so rename it and its
helpers such (guid_t).  The big endian UUID is the **only true** one, so
give it the name uuid_t.  The uuid_le and uuid_be names are retained for
now, but will hopefully go away soon.  The exception to that are the _cmp
helpers that will be replaced by better primitives ASAP and thus don't
get the new names.

Also the _to_bin helpers are named to match the better named uuid_parse
routine in userspace.

Also remove the existing typedef in XFS that's now been superceeded by
the generic type name.

Signed-off-by: Christoph Hellwig 
[andy: also update the UUID_LE/UUID_BE macros including fallout]
Signed-off-by: Andy Shevchenko 
Reviewed-by: Amir Goldstein 
Reviewed-by: Darrick J. Wong 
Reviewed-by: Andy Shevchenko 

Signed-off-by: Christoph Hellwig 

-Sumit

>
> James
>


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-25 Thread Maxim Uvarov
On Wed, 24 Jun 2020 at 18:44, Jerome Forissier  wrote:
>
>
>
> On 6/24/20 5:21 PM, James Bottomley wrote:
> > On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> >> Apologies for delay in my reply as I was busy with some other stuff.
> >>
> >> On Fri, 19 Jun 2020 at 20:30, James Bottomley
> >>  wrote:
> > [...]
> >>> it's about consistency with what the kernel types mean.  When some
> >>> checker detects your using little endian operations on a big endian
> >>> structure (like in the prink for instance) they're going to keep
> >>> emailing you about it.
> >>
> >> As mentioned above, using different terminology is meant to cause
> >> more confusion than just difference in endianness which is manageable
> >> inside TEE.
> >>
> >> And I think it's safe to say that the kernel implements UUID in big
> >> endian format and thus uses %pUb whereas OP-TEE implements UUID in
> >> little endian format and thus uses %pUl.
> >
> > So what I think you're saying is that if we still had uuid_be and
> > uuid_le you'd use uuid_le, because that's exactly the structure
> > described in the docs.  But because we renamed
> >
> > uuid_be -> uuid_t
> > uuid_le -> guid_t
> >
> > You can't use guid_t as a kernel type because it has the wrong name?
>
> Let me try to clear the confusion that I introduce myself I believe :-/
> IMO:
>
> - optee_register_device(const uuid_t *device_uuid) *is* the correct
> prototype.
> - device_uuid is *guaranteed* to be BE because OP-TEE makes this
> guarantee (it converts from its internal LE representation to BE when
> enumerating the devices, but it doesn't matter to the kernel).
> - Therefore %pUb is the correct format.
>
> I'm sorry for doubting the BE order initially. I am so used to OP-TEE
> using LE internally, that I missed the fact that we have an explicit
> conversion...
>
> Does this sound good?
>
> Thanks,
> --
> Jerome

I think your description is correct. But I think this problem  would
be solved outside of the current patchset.
All places should use one single format (LE):
-  internal optee representation;
-  device enumeration pta;
-  this kernel driver which creates sysfs entry and sets
uid_copy(_device->id.uuid, device_uuid);
-  matching function;
-  drivers use UUID_INIT();

In that way everything will be consistent. But it will require
changing other pieces, not just the kernel. While
these patches add functionality to support current device enumeration
in optee os.
So I think this version is ok to be applied.

Regards,
Maxim.


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-24 Thread Jerome Forissier



On 6/24/20 5:21 PM, James Bottomley wrote:
> On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
>> Apologies for delay in my reply as I was busy with some other stuff.
>>
>> On Fri, 19 Jun 2020 at 20:30, James Bottomley
>>  wrote:
> [...]
>>> it's about consistency with what the kernel types mean.  When some
>>> checker detects your using little endian operations on a big endian
>>> structure (like in the prink for instance) they're going to keep
>>> emailing you about it.
>>
>> As mentioned above, using different terminology is meant to cause
>> more confusion than just difference in endianness which is manageable
>> inside TEE.
>>
>> And I think it's safe to say that the kernel implements UUID in big
>> endian format and thus uses %pUb whereas OP-TEE implements UUID in
>> little endian format and thus uses %pUl.
> 
> So what I think you're saying is that if we still had uuid_be and
> uuid_le you'd use uuid_le, because that's exactly the structure
> described in the docs.  But because we renamed
> 
> uuid_be -> uuid_t
> uuid_le -> guid_t
> 
> You can't use guid_t as a kernel type because it has the wrong name?

Let me try to clear the confusion that I introduce myself I believe :-/
IMO:

- optee_register_device(const uuid_t *device_uuid) *is* the correct
prototype.
- device_uuid is *guaranteed* to be BE because OP-TEE makes this
guarantee (it converts from its internal LE representation to BE when
enumerating the devices, but it doesn't matter to the kernel).
- Therefore %pUb is the correct format.

I'm sorry for doubting the BE order initially. I am so used to OP-TEE
using LE internally, that I missed the fact that we have an explicit
conversion...

Does this sound good?

Thanks,
-- 
Jerome


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-24 Thread James Bottomley
On Wed, 2020-06-24 at 16:17 +0530, Sumit Garg wrote:
> Apologies for delay in my reply as I was busy with some other stuff.
> 
> On Fri, 19 Jun 2020 at 20:30, James Bottomley
>  wrote:
[...]
> > it's about consistency with what the kernel types mean.  When some
> > checker detects your using little endian operations on a big endian
> > structure (like in the prink for instance) they're going to keep
> > emailing you about it.
> 
> As mentioned above, using different terminology is meant to cause
> more confusion than just difference in endianness which is manageable
> inside TEE.
> 
> And I think it's safe to say that the kernel implements UUID in big
> endian format and thus uses %pUb whereas OP-TEE implements UUID in
> little endian format and thus uses %pUl.

So what I think you're saying is that if we still had uuid_be and
uuid_le you'd use uuid_le, because that's exactly the structure
described in the docs.  But because we renamed

uuid_be -> uuid_t
uuid_le -> guid_t

You can't use guid_t as a kernel type because it has the wrong name?

James



Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-24 Thread Sumit Garg
Apologies for delay in my reply as I was busy with some other stuff.

On Fri, 19 Jun 2020 at 20:30, James Bottomley
 wrote:
>
> On Fri, 2020-06-19 at 13:42 +0530, Sumit Garg wrote:
> > On Fri, 19 Jun 2020 at 00:49, James Bottomley
> >  wrote:
> > >
> > > On Thu, 2020-06-18 at 10:42 +0530, Sumit Garg wrote:
> > > > On Thu, 18 Jun 2020 at 10:29, Sumit Garg 
> > > > wrote:
> > >
> > > [...]
> > > > > > typedef struct
> > > > > > {
> > > > > > uint32_t timeLow;
> > > > > > uint16_t timeMid;
> > > > > > uint16_t timeHiAndVersion;
> > > > > > uint8_t clockSeqAndNode[8];
> > > > > > } TEE_UUID;
> > > > > >
> > > > > > (GlobalPlatform TEE Internal Core API spec v1.2.1 section
> > > > > > 3.2.4)
> > > > > >
> > > > > > - The spec does not mandate any particular endianness and
> > > > > > simply
> > > > > > warnsabout possible issues if secure and non-secure worlds
> > > > > > differ
> > > > > > in endianness.
> > > > > > - OP-TEE uses %pUl assuming that host order is little endian
> > > > > > (that is true for the Arm platforms that run OP-TEE
> > > > > > currently).
> > > > > > By the same logic %pUl should be fine in the kernel.
> > > >
> > > > I think Linux adheres to this RFC [1] for UUID byte order. See
> > > > below
> > > > snippet from section: "Layout and Byte Order":
> > > >
> > > >The fields are encoded as 16 octets, with the sizes and order
> > > > of
> > > > the
> > > >fields defined above, and with each field encoded with the
> > > > Most
> > > >Significant Byte first (known as network byte order).  Note
> > > > that
> > > > the
> > > >field names, particularly for multiplexed fields, follow
> > > > historical
> > > >practice.
> > >
> > > Actually, that's not quite true.  We used to support both little
> > > and
> > > big endian uuids until we realised it was basically microsoft vs
> > > everyone else (as codified by RFC 4122).  Now we support UUIDs
> > > which
> > > are big endian and GUIDs which are little endian.  This was the
> > > commit
> > > that sorted out the confusion:
> > >
> > > commit f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
> > > Author: Christoph Hellwig 
> > > Date:   Wed May 17 10:02:48 2017 +0200
> > >
> > > uuid: rename uuid types
> > >
> >
> > Thanks for providing the background here.
> >
> > > so if you're using a little endian uuid, you should probably be
> > > using GUID for TEE_UUID.
> >
> > IMO, using GUID in kernel for TEE_UUID in OP-TEE OS will lead to
> > deviation from GlobalPlatform TEE client spec [1] as the spec only
> > references it as UUID and we would like to keep kernel TEE client
> > interface to be compatible with GP specs.
> >
> > [1] https://globalplatform.org/specs-library/tee-client-api-specifica
> > tion/
>
> So having read the above, you know uuid_t is for big endian and guid_t
> for little endian.  However in your patch:
>
> > -static int optee_register_device(const uuid_t *device_uuid, u32
> > device_id)
> > +static int optee_register_device(const uuid_t *device_uuid)
> >
>
> You're using uuid_t for little endian, you should be using guid_t.

It's not just about implementation differences but about terminology
as well. AFAIK about GUID, it's been typically used in Microsoft
centric softwares as compared to UUID which is generically defined by
RFC 4122.

AFAIU about the differences [1] among UUID and GUID, it seems like
UUID is a subset of GUID. IOW, we can't say that every GUID can be
represented as UUID as per RFC 4122.

So by using different terminology in the kernel with respect to a TEE
implementation is meant to cause more confusion among users than
difference in implementation details (like endianness).

[1] 
https://stackoverflow.com/questions/246930/is-there-any-difference-between-a-guid-and-a-uuid

> It's not about consistency with the OP-TEE docs (although I'm pretty
> sure they don't mandate what kernel type to use),

The document which I shared wasn't OP-TEE specific but a generic TEE
specification defined by GlobalPlatform. And that spec doesn't put any
restrictions on UUID endianness. So it is very much possible that
another TEE implementation could implement UUID in big endian format
as the kernel does.

> it's about
> consistency with what the kernel types mean.  When some checker detects
> your using little endian operations on a big endian structure (like in
> the prink for instance) they're going to keep emailing you about it.

As mentioned above, using different terminology is meant to cause more
confusion than just difference in endianness which is manageable
inside TEE.

And I think it's safe to say that the kernel implements UUID in big
endian format and thus uses %pUb whereas OP-TEE implements UUID in
little endian format and thus uses %pUl.

-Sumit

>
> James
>


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-24 Thread Jens Wiklander
On Fri, Jun 19, 2020 at 08:00:44AM -0700, James Bottomley wrote:
> On Fri, 2020-06-19 at 13:42 +0530, Sumit Garg wrote:
> > On Fri, 19 Jun 2020 at 00:49, James Bottomley
> >  wrote:
> > > 
> > > On Thu, 2020-06-18 at 10:42 +0530, Sumit Garg wrote:
> > > > On Thu, 18 Jun 2020 at 10:29, Sumit Garg 
> > > > wrote:
> > > 
> > > [...]
> > > > > > typedef struct
> > > > > > {
> > > > > > uint32_t timeLow;
> > > > > > uint16_t timeMid;
> > > > > > uint16_t timeHiAndVersion;
> > > > > > uint8_t clockSeqAndNode[8];
> > > > > > } TEE_UUID;
> > > > > > 
> > > > > > (GlobalPlatform TEE Internal Core API spec v1.2.1 section
> > > > > > 3.2.4)
> > > > > > 
> > > > > > - The spec does not mandate any particular endianness and
> > > > > > simply
> > > > > > warnsabout possible issues if secure and non-secure worlds
> > > > > > differ
> > > > > > in endianness.
> > > > > > - OP-TEE uses %pUl assuming that host order is little endian
> > > > > > (that is true for the Arm platforms that run OP-TEE
> > > > > > currently).
> > > > > > By the same logic %pUl should be fine in the kernel.
> > > > 
> > > > I think Linux adheres to this RFC [1] for UUID byte order. See
> > > > below
> > > > snippet from section: "Layout and Byte Order":
> > > > 
> > > >The fields are encoded as 16 octets, with the sizes and order
> > > > of
> > > > the
> > > >fields defined above, and with each field encoded with the
> > > > Most
> > > >Significant Byte first (known as network byte order).  Note
> > > > that
> > > > the
> > > >field names, particularly for multiplexed fields, follow
> > > > historical
> > > >practice.
> > > 
> > > Actually, that's not quite true.  We used to support both little
> > > and
> > > big endian uuids until we realised it was basically microsoft vs
> > > everyone else (as codified by RFC 4122).  Now we support UUIDs
> > > which
> > > are big endian and GUIDs which are little endian.  This was the
> > > commit
> > > that sorted out the confusion:
> > > 
> > > commit f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
> > > Author: Christoph Hellwig 
> > > Date:   Wed May 17 10:02:48 2017 +0200
> > > 
> > > uuid: rename uuid types
> > > 
> > 
> > Thanks for providing the background here.
> > 
> > > so if you're using a little endian uuid, you should probably be
> > > using GUID for TEE_UUID.
> > 
> > IMO, using GUID in kernel for TEE_UUID in OP-TEE OS will lead to
> > deviation from GlobalPlatform TEE client spec [1] as the spec only
> > references it as UUID and we would like to keep kernel TEE client
> > interface to be compatible with GP specs.
> > 
> > [1] https://globalplatform.org/specs-library/tee-client-api-specifica
> > tion/
> 
> So having read the above, you know uuid_t is for big endian and guid_t
> for little endian.  However in your patch:
> 
> > -static int optee_register_device(const uuid_t *device_uuid, u32
> > device_id)
> > +static int optee_register_device(const uuid_t *device_uuid)
> > 
> 
> You're using uuid_t for little endian, you should be using guid_t. 
> It's not about consistency with the OP-TEE docs (although I'm pretty
> sure they don't mandate what kernel type to use), it's about
> consistency with what the kernel types mean.  When some checker detects
> your using little endian operations on a big endian structure (like in
> the prink for instance) they're going to keep emailing you about it.

Thanks for the clarification. Sumit, Maxim, please take care of this.

Cheers,
Jens

> 
> James
> 


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-19 Thread James Bottomley
On Fri, 2020-06-19 at 13:42 +0530, Sumit Garg wrote:
> On Fri, 19 Jun 2020 at 00:49, James Bottomley
>  wrote:
> > 
> > On Thu, 2020-06-18 at 10:42 +0530, Sumit Garg wrote:
> > > On Thu, 18 Jun 2020 at 10:29, Sumit Garg 
> > > wrote:
> > 
> > [...]
> > > > > typedef struct
> > > > > {
> > > > > uint32_t timeLow;
> > > > > uint16_t timeMid;
> > > > > uint16_t timeHiAndVersion;
> > > > > uint8_t clockSeqAndNode[8];
> > > > > } TEE_UUID;
> > > > > 
> > > > > (GlobalPlatform TEE Internal Core API spec v1.2.1 section
> > > > > 3.2.4)
> > > > > 
> > > > > - The spec does not mandate any particular endianness and
> > > > > simply
> > > > > warnsabout possible issues if secure and non-secure worlds
> > > > > differ
> > > > > in endianness.
> > > > > - OP-TEE uses %pUl assuming that host order is little endian
> > > > > (that is true for the Arm platforms that run OP-TEE
> > > > > currently).
> > > > > By the same logic %pUl should be fine in the kernel.
> > > 
> > > I think Linux adheres to this RFC [1] for UUID byte order. See
> > > below
> > > snippet from section: "Layout and Byte Order":
> > > 
> > >The fields are encoded as 16 octets, with the sizes and order
> > > of
> > > the
> > >fields defined above, and with each field encoded with the
> > > Most
> > >Significant Byte first (known as network byte order).  Note
> > > that
> > > the
> > >field names, particularly for multiplexed fields, follow
> > > historical
> > >practice.
> > 
> > Actually, that's not quite true.  We used to support both little
> > and
> > big endian uuids until we realised it was basically microsoft vs
> > everyone else (as codified by RFC 4122).  Now we support UUIDs
> > which
> > are big endian and GUIDs which are little endian.  This was the
> > commit
> > that sorted out the confusion:
> > 
> > commit f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
> > Author: Christoph Hellwig 
> > Date:   Wed May 17 10:02:48 2017 +0200
> > 
> > uuid: rename uuid types
> > 
> 
> Thanks for providing the background here.
> 
> > so if you're using a little endian uuid, you should probably be
> > using GUID for TEE_UUID.
> 
> IMO, using GUID in kernel for TEE_UUID in OP-TEE OS will lead to
> deviation from GlobalPlatform TEE client spec [1] as the spec only
> references it as UUID and we would like to keep kernel TEE client
> interface to be compatible with GP specs.
> 
> [1] https://globalplatform.org/specs-library/tee-client-api-specifica
> tion/

So having read the above, you know uuid_t is for big endian and guid_t
for little endian.  However in your patch:

> -static int optee_register_device(const uuid_t *device_uuid, u32
> device_id)
> +static int optee_register_device(const uuid_t *device_uuid)
> 

You're using uuid_t for little endian, you should be using guid_t. 
It's not about consistency with the OP-TEE docs (although I'm pretty
sure they don't mandate what kernel type to use), it's about
consistency with what the kernel types mean.  When some checker detects
your using little endian operations on a big endian structure (like in
the prink for instance) they're going to keep emailing you about it.

James



Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-19 Thread Sumit Garg
On Fri, 19 Jun 2020 at 00:49, James Bottomley
 wrote:
>
> On Thu, 2020-06-18 at 10:42 +0530, Sumit Garg wrote:
> > On Thu, 18 Jun 2020 at 10:29, Sumit Garg 
> > wrote:
> [...]
> > > > typedef struct
> > > > {
> > > > uint32_t timeLow;
> > > > uint16_t timeMid;
> > > > uint16_t timeHiAndVersion;
> > > > uint8_t clockSeqAndNode[8];
> > > > } TEE_UUID;
> > > >
> > > > (GlobalPlatform TEE Internal Core API spec v1.2.1 section 3.2.4)
> > > >
> > > > - The spec does not mandate any particular endianness and simply
> > > > warnsabout possible issues if secure and non-secure worlds differ
> > > > in endianness.
> > > > - OP-TEE uses %pUl assuming that host order is little endian
> > > > (that is true for the Arm platforms that run OP-TEE currently).
> > > > By the same logic %pUl should be fine in the kernel.
> >
> > I think Linux adheres to this RFC [1] for UUID byte order. See below
> > snippet from section: "Layout and Byte Order":
> >
> >The fields are encoded as 16 octets, with the sizes and order of
> > the
> >fields defined above, and with each field encoded with the Most
> >Significant Byte first (known as network byte order).  Note that
> > the
> >field names, particularly for multiplexed fields, follow
> > historical
> >practice.
>
> Actually, that's not quite true.  We used to support both little and
> big endian uuids until we realised it was basically microsoft vs
> everyone else (as codified by RFC 4122).  Now we support UUIDs which
> are big endian and GUIDs which are little endian.  This was the commit
> that sorted out the confusion:
>
> commit f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
> Author: Christoph Hellwig 
> Date:   Wed May 17 10:02:48 2017 +0200
>
> uuid: rename uuid types
>

Thanks for providing the background here.

> so if you're using a little endian uuid, you should probably be using
> GUID for TEE_UUID.

IMO, using GUID in kernel for TEE_UUID in OP-TEE OS will lead to
deviation from GlobalPlatform TEE client spec [1] as the spec only
references it as UUID and we would like to keep kernel TEE client
interface to be compatible with GP specs.

[1] https://globalplatform.org/specs-library/tee-client-api-specification/

-Sumit

>
> James
>


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-18 Thread James Bottomley
On Thu, 2020-06-18 at 10:42 +0530, Sumit Garg wrote:
> On Thu, 18 Jun 2020 at 10:29, Sumit Garg 
> wrote:
[...]
> > > typedef struct
> > > {
> > > uint32_t timeLow;
> > > uint16_t timeMid;
> > > uint16_t timeHiAndVersion;
> > > uint8_t clockSeqAndNode[8];
> > > } TEE_UUID;
> > > 
> > > (GlobalPlatform TEE Internal Core API spec v1.2.1 section 3.2.4)
> > > 
> > > - The spec does not mandate any particular endianness and simply
> > > warnsabout possible issues if secure and non-secure worlds differ
> > > in endianness.
> > > - OP-TEE uses %pUl assuming that host order is little endian
> > > (that is true for the Arm platforms that run OP-TEE currently).
> > > By the same logic %pUl should be fine in the kernel.
> 
> I think Linux adheres to this RFC [1] for UUID byte order. See below
> snippet from section: "Layout and Byte Order":
> 
>The fields are encoded as 16 octets, with the sizes and order of
> the
>fields defined above, and with each field encoded with the Most
>Significant Byte first (known as network byte order).  Note that
> the
>field names, particularly for multiplexed fields, follow
> historical
>practice.

Actually, that's not quite true.  We used to support both little and
big endian uuids until we realised it was basically microsoft vs
everyone else (as codified by RFC 4122).  Now we support UUIDs which
are big endian and GUIDs which are little endian.  This was the commit
that sorted out the confusion:

commit f9727a17db9bab71ddae91f74f11a8a2f9a0ece6
Author: Christoph Hellwig 
Date:   Wed May 17 10:02:48 2017 +0200

uuid: rename uuid types

so if you're using a little endian uuid, you should probably be using
GUID for TEE_UUID.

James



Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-18 Thread Maxim Uvarov
There was a comment about a new mailing list address in Documentation.
Which one I should specify now?

On Thu, 18 Jun 2020 at 09:57, Jerome Forissier  wrote:
>
> On 6/18/20 6:59 AM, Sumit Garg wrote:
> > Hi Jerome,
> >
> > On Wed, 17 Jun 2020 at 20:46, Jerome Forissier  wrote:
> >>
> >>
> >>
> >> On 6/17/20 3:58 PM, Sumit Garg wrote:
> >>> Hi Maxim,
> >>>
> >>> On Thu, 4 Jun 2020 at 23:28, Maxim Uvarov  wrote:
> 
>  With the evolving use-cases for TEE bus, now it's required to support
>  multi-stage enumeration process. But using a simple index doesn't
>  suffice this requirement and instead leads to duplicate sysfs entries.
>  So instead switch to use more informative device UUID for sysfs entry
>  like:
>  /sys/bus/tee/devices/optee-ta-
> 
>  Signed-off-by: Maxim Uvarov 
>  Reviewed-by: Sumit Garg 
>  ---
>   Documentation/ABI/testing/sysfs-bus-optee-devices | 8 
>   MAINTAINERS   | 1 +
>   drivers/tee/optee/device.c| 9 ++---
>   3 files changed, 15 insertions(+), 3 deletions(-)
>   create mode 100644 Documentation/ABI/testing/sysfs-bus-optee-devices
> 
>  diff --git a/Documentation/ABI/testing/sysfs-bus-optee-devices 
>  b/Documentation/ABI/testing/sysfs-bus-optee-devices
>  new file mode 100644
>  index ..0ae04ae5374a
>  --- /dev/null
>  +++ b/Documentation/ABI/testing/sysfs-bus-optee-devices
>  @@ -0,0 +1,8 @@
>  +What:  /sys/bus/tee/devices/optee-ta-/
>  +Date:   May 2020
>  +KernelVersion   5.7
>  +Contact:tee-...@lists.linaro.org
>  +Description:
>  +   OP-TEE bus provides reference to registered drivers 
>  under this directory. The 
>  +   matches Trusted Application (TA) driver and 
>  corresponding TA in secure OS. Drivers
>  +   are free to create needed API under optee-ta- 
>  directory.
>  diff --git a/MAINTAINERS b/MAINTAINERS
>  index ecc0749810b0..6717afef2de3 100644
>  --- a/MAINTAINERS
>  +++ b/MAINTAINERS
>  @@ -12516,6 +12516,7 @@ OP-TEE DRIVER
>   M: Jens Wiklander 
>   L: tee-...@lists.linaro.org
>   S: Maintained
>  +F: Documentation/ABI/testing/sysfs-bus-optee-devices
>   F: drivers/tee/optee/
> 
>   OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER
>  diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
>  index e3a148521ec1..23d264c8146e 100644
>  --- a/drivers/tee/optee/device.c
>  +++ b/drivers/tee/optee/device.c
>  @@ -65,7 +65,7 @@ static int get_devices(struct tee_context *ctx, u32 
>  session,
>  return 0;
>   }
> 
>  -static int optee_register_device(const uuid_t *device_uuid, u32 
>  device_id)
>  +static int optee_register_device(const uuid_t *device_uuid)
>   {
>  struct tee_client_device *optee_device = NULL;
>  int rc;
>  @@ -75,7 +75,10 @@ static int optee_register_device(const uuid_t 
>  *device_uuid, u32 device_id)
>  return -ENOMEM;
> 
>  optee_device->dev.bus = _bus_type;
>  -   dev_set_name(_device->dev, "optee-clnt%u", device_id);
>  +   if (dev_set_name(_device->dev, "optee-ta-%pUl", 
>  device_uuid)) {
> >>>
> >>> You should be using format specifier as: "%pUb" instead of "%pUl" as
> >>> UUID representation for TAs is in big endian format. See below:
> >>
> >> Where does device_uuid come from? If it comes directly from OP-TEE, then
> >> it should be a pointer to the following struct:
> >>
> >> typedef struct
> >> {
> >> uint32_t timeLow;
> >> uint16_t timeMid;
> >> uint16_t timeHiAndVersion;
> >> uint8_t clockSeqAndNode[8];
> >> } TEE_UUID;
> >>
> >> (GlobalPlatform TEE Internal Core API spec v1.2.1 section 3.2.4)
> >>
> >> - The spec does not mandate any particular endianness and simply warns
> >> about possible issues if secure and non-secure worlds differ in endianness.
> >> - OP-TEE uses %pUl assuming that host order is little endian (that is
> >> true for the Arm platforms that run OP-TEE currently). By the same logic
> >> %pUl should be fine in the kernel.
> >> - On the other hand, the UUID in a Trusted App header is always encoded
> >> big endian by the Python script that signs and optionally encrypts the
> >> TA. This should not have any visible impact on UUIDs exchanged between
> >> the secure and non-secure world though.
> >>
> >> So I am wondering why you had to use %pUb. There must be some
> >> inconsistency somewhere :-/
> >
> > Yes there is. Linux stores UUID in big endian format (16 byte octets)
> > and OP-TEE stores UUID in little endian format (in form of struct you
> > referenced above).
> >
> > And format conversion APIs [1] in OP-TEE OS are used while passing
> > UUID among Linux and OP-TEE.
> >
> > So we 

Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-18 Thread Jerome Forissier
On 6/18/20 6:59 AM, Sumit Garg wrote:
> Hi Jerome,
> 
> On Wed, 17 Jun 2020 at 20:46, Jerome Forissier  wrote:
>>
>>
>>
>> On 6/17/20 3:58 PM, Sumit Garg wrote:
>>> Hi Maxim,
>>>
>>> On Thu, 4 Jun 2020 at 23:28, Maxim Uvarov  wrote:

 With the evolving use-cases for TEE bus, now it's required to support
 multi-stage enumeration process. But using a simple index doesn't
 suffice this requirement and instead leads to duplicate sysfs entries.
 So instead switch to use more informative device UUID for sysfs entry
 like:
 /sys/bus/tee/devices/optee-ta-

 Signed-off-by: Maxim Uvarov 
 Reviewed-by: Sumit Garg 
 ---
  Documentation/ABI/testing/sysfs-bus-optee-devices | 8 
  MAINTAINERS   | 1 +
  drivers/tee/optee/device.c| 9 ++---
  3 files changed, 15 insertions(+), 3 deletions(-)
  create mode 100644 Documentation/ABI/testing/sysfs-bus-optee-devices

 diff --git a/Documentation/ABI/testing/sysfs-bus-optee-devices 
 b/Documentation/ABI/testing/sysfs-bus-optee-devices
 new file mode 100644
 index ..0ae04ae5374a
 --- /dev/null
 +++ b/Documentation/ABI/testing/sysfs-bus-optee-devices
 @@ -0,0 +1,8 @@
 +What:  /sys/bus/tee/devices/optee-ta-/
 +Date:   May 2020
 +KernelVersion   5.7
 +Contact:tee-...@lists.linaro.org
 +Description:
 +   OP-TEE bus provides reference to registered drivers under 
 this directory. The 
 +   matches Trusted Application (TA) driver and corresponding 
 TA in secure OS. Drivers
 +   are free to create needed API under optee-ta- 
 directory.
 diff --git a/MAINTAINERS b/MAINTAINERS
 index ecc0749810b0..6717afef2de3 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
 @@ -12516,6 +12516,7 @@ OP-TEE DRIVER
  M: Jens Wiklander 
  L: tee-...@lists.linaro.org
  S: Maintained
 +F: Documentation/ABI/testing/sysfs-bus-optee-devices
  F: drivers/tee/optee/

  OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER
 diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
 index e3a148521ec1..23d264c8146e 100644
 --- a/drivers/tee/optee/device.c
 +++ b/drivers/tee/optee/device.c
 @@ -65,7 +65,7 @@ static int get_devices(struct tee_context *ctx, u32 
 session,
 return 0;
  }

 -static int optee_register_device(const uuid_t *device_uuid, u32 device_id)
 +static int optee_register_device(const uuid_t *device_uuid)
  {
 struct tee_client_device *optee_device = NULL;
 int rc;
 @@ -75,7 +75,10 @@ static int optee_register_device(const uuid_t 
 *device_uuid, u32 device_id)
 return -ENOMEM;

 optee_device->dev.bus = _bus_type;
 -   dev_set_name(_device->dev, "optee-clnt%u", device_id);
 +   if (dev_set_name(_device->dev, "optee-ta-%pUl", 
 device_uuid)) {
>>>
>>> You should be using format specifier as: "%pUb" instead of "%pUl" as
>>> UUID representation for TAs is in big endian format. See below:
>>
>> Where does device_uuid come from? If it comes directly from OP-TEE, then
>> it should be a pointer to the following struct:
>>
>> typedef struct
>> {
>> uint32_t timeLow;
>> uint16_t timeMid;
>> uint16_t timeHiAndVersion;
>> uint8_t clockSeqAndNode[8];
>> } TEE_UUID;
>>
>> (GlobalPlatform TEE Internal Core API spec v1.2.1 section 3.2.4)
>>
>> - The spec does not mandate any particular endianness and simply warns
>> about possible issues if secure and non-secure worlds differ in endianness.
>> - OP-TEE uses %pUl assuming that host order is little endian (that is
>> true for the Arm platforms that run OP-TEE currently). By the same logic
>> %pUl should be fine in the kernel.
>> - On the other hand, the UUID in a Trusted App header is always encoded
>> big endian by the Python script that signs and optionally encrypts the
>> TA. This should not have any visible impact on UUIDs exchanged between
>> the secure and non-secure world though.
>>
>> So I am wondering why you had to use %pUb. There must be some
>> inconsistency somewhere :-/
> 
> Yes there is. Linux stores UUID in big endian format (16 byte octets)
> and OP-TEE stores UUID in little endian format (in form of struct you
> referenced above).
> 
> And format conversion APIs [1] in OP-TEE OS are used while passing
> UUID among Linux and OP-TEE.
> 
> So we need to use %pUb in case of Linux and %pUl in case of OP-TEE.
> 
> [1] https://github.com/OP-TEE/optee_os/blob/master/core/tee/uuid.c


Got it now. The TA enumeration function in OP-TEE performs  the
conversion here:
https://github.com/OP-TEE/optee_os/blob/3.9.0/core/pta/device.c#L34

Thanks for clarifying.

-- 
Jerome


Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-17 Thread Sumit Garg
On Thu, 18 Jun 2020 at 10:29, Sumit Garg  wrote:
>
> Hi Jerome,
>
> On Wed, 17 Jun 2020 at 20:46, Jerome Forissier  wrote:
> >
> >
> >
> > On 6/17/20 3:58 PM, Sumit Garg wrote:
> > > Hi Maxim,
> > >
> > > On Thu, 4 Jun 2020 at 23:28, Maxim Uvarov  wrote:
> > >>
> > >> With the evolving use-cases for TEE bus, now it's required to support
> > >> multi-stage enumeration process. But using a simple index doesn't
> > >> suffice this requirement and instead leads to duplicate sysfs entries.
> > >> So instead switch to use more informative device UUID for sysfs entry
> > >> like:
> > >> /sys/bus/tee/devices/optee-ta-
> > >>
> > >> Signed-off-by: Maxim Uvarov 
> > >> Reviewed-by: Sumit Garg 
> > >> ---
> > >>  Documentation/ABI/testing/sysfs-bus-optee-devices | 8 
> > >>  MAINTAINERS   | 1 +
> > >>  drivers/tee/optee/device.c| 9 ++---
> > >>  3 files changed, 15 insertions(+), 3 deletions(-)
> > >>  create mode 100644 Documentation/ABI/testing/sysfs-bus-optee-devices
> > >>
> > >> diff --git a/Documentation/ABI/testing/sysfs-bus-optee-devices 
> > >> b/Documentation/ABI/testing/sysfs-bus-optee-devices
> > >> new file mode 100644
> > >> index ..0ae04ae5374a
> > >> --- /dev/null
> > >> +++ b/Documentation/ABI/testing/sysfs-bus-optee-devices
> > >> @@ -0,0 +1,8 @@
> > >> +What:  /sys/bus/tee/devices/optee-ta-/
> > >> +Date:   May 2020
> > >> +KernelVersion   5.7
> > >> +Contact:tee-...@lists.linaro.org
> > >> +Description:
> > >> +   OP-TEE bus provides reference to registered drivers 
> > >> under this directory. The 
> > >> +   matches Trusted Application (TA) driver and 
> > >> corresponding TA in secure OS. Drivers
> > >> +   are free to create needed API under optee-ta- 
> > >> directory.
> > >> diff --git a/MAINTAINERS b/MAINTAINERS
> > >> index ecc0749810b0..6717afef2de3 100644
> > >> --- a/MAINTAINERS
> > >> +++ b/MAINTAINERS
> > >> @@ -12516,6 +12516,7 @@ OP-TEE DRIVER
> > >>  M: Jens Wiklander 
> > >>  L: tee-...@lists.linaro.org
> > >>  S: Maintained
> > >> +F: Documentation/ABI/testing/sysfs-bus-optee-devices
> > >>  F: drivers/tee/optee/
> > >>
> > >>  OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER
> > >> diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
> > >> index e3a148521ec1..23d264c8146e 100644
> > >> --- a/drivers/tee/optee/device.c
> > >> +++ b/drivers/tee/optee/device.c
> > >> @@ -65,7 +65,7 @@ static int get_devices(struct tee_context *ctx, u32 
> > >> session,
> > >> return 0;
> > >>  }
> > >>
> > >> -static int optee_register_device(const uuid_t *device_uuid, u32 
> > >> device_id)
> > >> +static int optee_register_device(const uuid_t *device_uuid)
> > >>  {
> > >> struct tee_client_device *optee_device = NULL;
> > >> int rc;
> > >> @@ -75,7 +75,10 @@ static int optee_register_device(const uuid_t 
> > >> *device_uuid, u32 device_id)
> > >> return -ENOMEM;
> > >>
> > >> optee_device->dev.bus = _bus_type;
> > >> -   dev_set_name(_device->dev, "optee-clnt%u", device_id);
> > >> +   if (dev_set_name(_device->dev, "optee-ta-%pUl", 
> > >> device_uuid)) {
> > >
> > > You should be using format specifier as: "%pUb" instead of "%pUl" as
> > > UUID representation for TAs is in big endian format. See below:
> >
> > Where does device_uuid come from? If it comes directly from OP-TEE, then
> > it should be a pointer to the following struct:
> >
> > typedef struct
> > {
> > uint32_t timeLow;
> > uint16_t timeMid;
> > uint16_t timeHiAndVersion;
> > uint8_t clockSeqAndNode[8];
> > } TEE_UUID;
> >
> > (GlobalPlatform TEE Internal Core API spec v1.2.1 section 3.2.4)
> >
> > - The spec does not mandate any particular endianness and simply warns
> > about possible issues if secure and non-secure worlds differ in endianness.
> > - OP-TEE uses %pUl assuming that host order is little endian (that is
> > true for the Arm platforms that run OP-TEE currently). By the same logic
> > %pUl should be fine in the kernel.

I think Linux adheres to this RFC [1] for UUID byte order. See below
snippet from section: "Layout and Byte Order":

   The fields are encoded as 16 octets, with the sizes and order of the
   fields defined above, and with each field encoded with the Most
   Significant Byte first (known as network byte order).  Note that the
   field names, particularly for multiplexed fields, follow historical
   practice.

-Sumit

[1] https://tools.ietf.org/html/rfc4122

> > - On the other hand, the UUID in a Trusted App header is always encoded
> > big endian by the Python script that signs and optionally encrypts the
> > TA. This should not have any visible impact on UUIDs exchanged between
> > the secure and non-secure world though.
> >
> > So I am wondering why you had to use %pUb. There must be some
> > inconsistency somewhere :-/
>
> Yes there is. 

Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-17 Thread Sumit Garg
Hi Jerome,

On Wed, 17 Jun 2020 at 20:46, Jerome Forissier  wrote:
>
>
>
> On 6/17/20 3:58 PM, Sumit Garg wrote:
> > Hi Maxim,
> >
> > On Thu, 4 Jun 2020 at 23:28, Maxim Uvarov  wrote:
> >>
> >> With the evolving use-cases for TEE bus, now it's required to support
> >> multi-stage enumeration process. But using a simple index doesn't
> >> suffice this requirement and instead leads to duplicate sysfs entries.
> >> So instead switch to use more informative device UUID for sysfs entry
> >> like:
> >> /sys/bus/tee/devices/optee-ta-
> >>
> >> Signed-off-by: Maxim Uvarov 
> >> Reviewed-by: Sumit Garg 
> >> ---
> >>  Documentation/ABI/testing/sysfs-bus-optee-devices | 8 
> >>  MAINTAINERS   | 1 +
> >>  drivers/tee/optee/device.c| 9 ++---
> >>  3 files changed, 15 insertions(+), 3 deletions(-)
> >>  create mode 100644 Documentation/ABI/testing/sysfs-bus-optee-devices
> >>
> >> diff --git a/Documentation/ABI/testing/sysfs-bus-optee-devices 
> >> b/Documentation/ABI/testing/sysfs-bus-optee-devices
> >> new file mode 100644
> >> index ..0ae04ae5374a
> >> --- /dev/null
> >> +++ b/Documentation/ABI/testing/sysfs-bus-optee-devices
> >> @@ -0,0 +1,8 @@
> >> +What:  /sys/bus/tee/devices/optee-ta-/
> >> +Date:   May 2020
> >> +KernelVersion   5.7
> >> +Contact:tee-...@lists.linaro.org
> >> +Description:
> >> +   OP-TEE bus provides reference to registered drivers under 
> >> this directory. The 
> >> +   matches Trusted Application (TA) driver and corresponding 
> >> TA in secure OS. Drivers
> >> +   are free to create needed API under optee-ta- 
> >> directory.
> >> diff --git a/MAINTAINERS b/MAINTAINERS
> >> index ecc0749810b0..6717afef2de3 100644
> >> --- a/MAINTAINERS
> >> +++ b/MAINTAINERS
> >> @@ -12516,6 +12516,7 @@ OP-TEE DRIVER
> >>  M: Jens Wiklander 
> >>  L: tee-...@lists.linaro.org
> >>  S: Maintained
> >> +F: Documentation/ABI/testing/sysfs-bus-optee-devices
> >>  F: drivers/tee/optee/
> >>
> >>  OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER
> >> diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
> >> index e3a148521ec1..23d264c8146e 100644
> >> --- a/drivers/tee/optee/device.c
> >> +++ b/drivers/tee/optee/device.c
> >> @@ -65,7 +65,7 @@ static int get_devices(struct tee_context *ctx, u32 
> >> session,
> >> return 0;
> >>  }
> >>
> >> -static int optee_register_device(const uuid_t *device_uuid, u32 device_id)
> >> +static int optee_register_device(const uuid_t *device_uuid)
> >>  {
> >> struct tee_client_device *optee_device = NULL;
> >> int rc;
> >> @@ -75,7 +75,10 @@ static int optee_register_device(const uuid_t 
> >> *device_uuid, u32 device_id)
> >> return -ENOMEM;
> >>
> >> optee_device->dev.bus = _bus_type;
> >> -   dev_set_name(_device->dev, "optee-clnt%u", device_id);
> >> +   if (dev_set_name(_device->dev, "optee-ta-%pUl", 
> >> device_uuid)) {
> >
> > You should be using format specifier as: "%pUb" instead of "%pUl" as
> > UUID representation for TAs is in big endian format. See below:
>
> Where does device_uuid come from? If it comes directly from OP-TEE, then
> it should be a pointer to the following struct:
>
> typedef struct
> {
> uint32_t timeLow;
> uint16_t timeMid;
> uint16_t timeHiAndVersion;
> uint8_t clockSeqAndNode[8];
> } TEE_UUID;
>
> (GlobalPlatform TEE Internal Core API spec v1.2.1 section 3.2.4)
>
> - The spec does not mandate any particular endianness and simply warns
> about possible issues if secure and non-secure worlds differ in endianness.
> - OP-TEE uses %pUl assuming that host order is little endian (that is
> true for the Arm platforms that run OP-TEE currently). By the same logic
> %pUl should be fine in the kernel.
> - On the other hand, the UUID in a Trusted App header is always encoded
> big endian by the Python script that signs and optionally encrypts the
> TA. This should not have any visible impact on UUIDs exchanged between
> the secure and non-secure world though.
>
> So I am wondering why you had to use %pUb. There must be some
> inconsistency somewhere :-/

Yes there is. Linux stores UUID in big endian format (16 byte octets)
and OP-TEE stores UUID in little endian format (in form of struct you
referenced above).

And format conversion APIs [1] in OP-TEE OS are used while passing
UUID among Linux and OP-TEE.

So we need to use %pUb in case of Linux and %pUl in case of OP-TEE.

[1] https://github.com/OP-TEE/optee_os/blob/master/core/tee/uuid.c

-Sumit

>
> --
> Jerome
>
> >
> > # ls /sys/bus/tee/devices/
> > optee-ta-405b6ad9-e5c3-e321-8794-1002a5d5c61b
> > optee-ta-71d950bc-c9d4-c442-82cb-343fb7f37896
> > optee-ta-e70f4af0-5d1f-9b4b-abf7-619b85b4ce8c
> >
> > While UUID for fTPM TA is in big endian format:
> > bc50d971-d4c9-42c4-82cb-343fb7f37896
> >
> > Sorry that I missed it during review and 

Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-17 Thread Jerome Forissier
On 6/17/20 9:52 PM, Maxim Uvarov wrote:
> On Wed, 17 Jun 2020 at 18:16, Jerome Forissier  wrote:
>>
>> On 6/17/20 3:58 PM, Sumit Garg wrote:
>>> Hi Maxim,
>>>
>>> On Thu, 4 Jun 2020 at 23:28, Maxim Uvarov  wrote:

 With the evolving use-cases for TEE bus, now it's required to support
 multi-stage enumeration process. But using a simple index doesn't
 suffice this requirement and instead leads to duplicate sysfs entries.
 So instead switch to use more informative device UUID for sysfs entry
 like:
 /sys/bus/tee/devices/optee-ta-

 Signed-off-by: Maxim Uvarov 
 Reviewed-by: Sumit Garg 
 ---
  Documentation/ABI/testing/sysfs-bus-optee-devices | 8 
  MAINTAINERS   | 1 +
  drivers/tee/optee/device.c| 9 ++---
  3 files changed, 15 insertions(+), 3 deletions(-)
  create mode 100644 Documentation/ABI/testing/sysfs-bus-optee-devices

 diff --git a/Documentation/ABI/testing/sysfs-bus-optee-devices 
 b/Documentation/ABI/testing/sysfs-bus-optee-devices
 new file mode 100644
 index ..0ae04ae5374a
 --- /dev/null
 +++ b/Documentation/ABI/testing/sysfs-bus-optee-devices
 @@ -0,0 +1,8 @@
 +What:  /sys/bus/tee/devices/optee-ta-/
 +Date:   May 2020
 +KernelVersion   5.7
 +Contact:tee-...@lists.linaro.org
 +Description:
 +   OP-TEE bus provides reference to registered drivers under 
 this directory. The 
 +   matches Trusted Application (TA) driver and corresponding 
 TA in secure OS. Drivers
 +   are free to create needed API under optee-ta- 
 directory.
 diff --git a/MAINTAINERS b/MAINTAINERS
 index ecc0749810b0..6717afef2de3 100644
 --- a/MAINTAINERS
 +++ b/MAINTAINERS
 @@ -12516,6 +12516,7 @@ OP-TEE DRIVER
  M: Jens Wiklander 
  L: tee-...@lists.linaro.org
  S: Maintained
 +F: Documentation/ABI/testing/sysfs-bus-optee-devices
  F: drivers/tee/optee/

  OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER
 diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
 index e3a148521ec1..23d264c8146e 100644
 --- a/drivers/tee/optee/device.c
 +++ b/drivers/tee/optee/device.c
 @@ -65,7 +65,7 @@ static int get_devices(struct tee_context *ctx, u32 
 session,
 return 0;
  }

 -static int optee_register_device(const uuid_t *device_uuid, u32 device_id)
 +static int optee_register_device(const uuid_t *device_uuid)
  {
 struct tee_client_device *optee_device = NULL;
 int rc;
 @@ -75,7 +75,10 @@ static int optee_register_device(const uuid_t 
 *device_uuid, u32 device_id)
 return -ENOMEM;

 optee_device->dev.bus = _bus_type;
 -   dev_set_name(_device->dev, "optee-clnt%u", device_id);
 +   if (dev_set_name(_device->dev, "optee-ta-%pUl", 
 device_uuid)) {
>>>
>>> You should be using format specifier as: "%pUb" instead of "%pUl" as
>>> UUID representation for TAs is in big endian format. See below:
>>
>> Where does device_uuid come from? If it comes directly from OP-TEE, then
>> it should be a pointer to the following struct:
>>
>> typedef struct
>> {
>> uint32_t timeLow;
>> uint16_t timeMid;
>> uint16_t timeHiAndVersion;
>> uint8_t clockSeqAndNode[8];
>> } TEE_UUID;
>>
>> (GlobalPlatform TEE Internal Core API spec v1.2.1 section 3.2.4)
>>
>> - The spec does not mandate any particular endianness and simply warns
>> about possible issues if secure and non-secure worlds differ in endianness.
>> - OP-TEE uses %pUl assuming that host order is little endian (that is
>> true for the Arm platforms that run OP-TEE currently). By the same logic
>> %pUl should be fine in the kernel.
>> - On the other hand, the UUID in a Trusted App header is always encoded
>> big endian by the Python script that signs and optionally encrypts the
>> TA. This should not have any visible impact on UUIDs exchanged between
>> the secure and non-secure world though.
>>
>> So I am wondering why you had to use %pUb. There must be some
>> inconsistency somewhere :-/
>>
>> --
>> Jerome
> 
> From  linux side it is for example:
> 
> static const struct tee_client_device_id optee_ftpm_id_table[] = {
> {UUID_INIT(0xbc50d971, 0xd4c9, 0x42c4,
>0x82, 0xcb, 0x34, 0x3f, 0xb7, 0xf3, 0x78, 0x96)},
> {}
> };
> 
> static struct tee_client_driver ftpm_tee_driver = {
> .id_table   = optee_ftpm_id_table,
> .driver = {
> 
> So sysfs name has to be the same as the driver has. And  UUD is simple
> 16 bytes:#define UUID_SIZE 16
> typedef struct {
> __u8 b[UUID_SIZE];
> } uuid_t;
> 
> From TA it also:
> #define TA_UUID  { 0xBC50D971, 0xD4C9, 0x42C4, \
> {0x82, 0xCB, 0x34, 0x3F, 0xB7, 0xF3, 0x78, 

Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-17 Thread Maxim Uvarov
On Wed, 17 Jun 2020 at 18:16, Jerome Forissier  wrote:
>
>
>
> On 6/17/20 3:58 PM, Sumit Garg wrote:
> > Hi Maxim,
> >
> > On Thu, 4 Jun 2020 at 23:28, Maxim Uvarov  wrote:
> >>
> >> With the evolving use-cases for TEE bus, now it's required to support
> >> multi-stage enumeration process. But using a simple index doesn't
> >> suffice this requirement and instead leads to duplicate sysfs entries.
> >> So instead switch to use more informative device UUID for sysfs entry
> >> like:
> >> /sys/bus/tee/devices/optee-ta-
> >>
> >> Signed-off-by: Maxim Uvarov 
> >> Reviewed-by: Sumit Garg 
> >> ---
> >>  Documentation/ABI/testing/sysfs-bus-optee-devices | 8 
> >>  MAINTAINERS   | 1 +
> >>  drivers/tee/optee/device.c| 9 ++---
> >>  3 files changed, 15 insertions(+), 3 deletions(-)
> >>  create mode 100644 Documentation/ABI/testing/sysfs-bus-optee-devices
> >>
> >> diff --git a/Documentation/ABI/testing/sysfs-bus-optee-devices 
> >> b/Documentation/ABI/testing/sysfs-bus-optee-devices
> >> new file mode 100644
> >> index ..0ae04ae5374a
> >> --- /dev/null
> >> +++ b/Documentation/ABI/testing/sysfs-bus-optee-devices
> >> @@ -0,0 +1,8 @@
> >> +What:  /sys/bus/tee/devices/optee-ta-/
> >> +Date:   May 2020
> >> +KernelVersion   5.7
> >> +Contact:tee-...@lists.linaro.org
> >> +Description:
> >> +   OP-TEE bus provides reference to registered drivers under 
> >> this directory. The 
> >> +   matches Trusted Application (TA) driver and corresponding 
> >> TA in secure OS. Drivers
> >> +   are free to create needed API under optee-ta- 
> >> directory.
> >> diff --git a/MAINTAINERS b/MAINTAINERS
> >> index ecc0749810b0..6717afef2de3 100644
> >> --- a/MAINTAINERS
> >> +++ b/MAINTAINERS
> >> @@ -12516,6 +12516,7 @@ OP-TEE DRIVER
> >>  M: Jens Wiklander 
> >>  L: tee-...@lists.linaro.org
> >>  S: Maintained
> >> +F: Documentation/ABI/testing/sysfs-bus-optee-devices
> >>  F: drivers/tee/optee/
> >>
> >>  OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER
> >> diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
> >> index e3a148521ec1..23d264c8146e 100644
> >> --- a/drivers/tee/optee/device.c
> >> +++ b/drivers/tee/optee/device.c
> >> @@ -65,7 +65,7 @@ static int get_devices(struct tee_context *ctx, u32 
> >> session,
> >> return 0;
> >>  }
> >>
> >> -static int optee_register_device(const uuid_t *device_uuid, u32 device_id)
> >> +static int optee_register_device(const uuid_t *device_uuid)
> >>  {
> >> struct tee_client_device *optee_device = NULL;
> >> int rc;
> >> @@ -75,7 +75,10 @@ static int optee_register_device(const uuid_t 
> >> *device_uuid, u32 device_id)
> >> return -ENOMEM;
> >>
> >> optee_device->dev.bus = _bus_type;
> >> -   dev_set_name(_device->dev, "optee-clnt%u", device_id);
> >> +   if (dev_set_name(_device->dev, "optee-ta-%pUl", 
> >> device_uuid)) {
> >
> > You should be using format specifier as: "%pUb" instead of "%pUl" as
> > UUID representation for TAs is in big endian format. See below:
>
> Where does device_uuid come from? If it comes directly from OP-TEE, then
> it should be a pointer to the following struct:
>
> typedef struct
> {
> uint32_t timeLow;
> uint16_t timeMid;
> uint16_t timeHiAndVersion;
> uint8_t clockSeqAndNode[8];
> } TEE_UUID;
>
> (GlobalPlatform TEE Internal Core API spec v1.2.1 section 3.2.4)
>
> - The spec does not mandate any particular endianness and simply warns
> about possible issues if secure and non-secure worlds differ in endianness.
> - OP-TEE uses %pUl assuming that host order is little endian (that is
> true for the Arm platforms that run OP-TEE currently). By the same logic
> %pUl should be fine in the kernel.
> - On the other hand, the UUID in a Trusted App header is always encoded
> big endian by the Python script that signs and optionally encrypts the
> TA. This should not have any visible impact on UUIDs exchanged between
> the secure and non-secure world though.
>
> So I am wondering why you had to use %pUb. There must be some
> inconsistency somewhere :-/
>
> --
> Jerome

>From  linux side it is for example:

static const struct tee_client_device_id optee_ftpm_id_table[] = {
{UUID_INIT(0xbc50d971, 0xd4c9, 0x42c4,
   0x82, 0xcb, 0x34, 0x3f, 0xb7, 0xf3, 0x78, 0x96)},
{}
};

static struct tee_client_driver ftpm_tee_driver = {
.id_table   = optee_ftpm_id_table,
.driver = {

So sysfs name has to be the same as the driver has. And  UUD is simple
16 bytes:#define UUID_SIZE 16
typedef struct {
__u8 b[UUID_SIZE];
} uuid_t;

>From TA it also:
#define TA_UUID  { 0xBC50D971, 0xD4C9, 0x42C4, \
{0x82, 0xCB, 0x34, 0x3F, 0xB7, 0xF3, 0x78, 0x96}}

Compare uuid from optee and kernel driver version is simple:
static inline bool uuid_equal(const uuid_t 

Re: [Tee-dev] [PATCHv8 1/3] optee: use uuid for sysfs driver entry

2020-06-17 Thread Jerome Forissier



On 6/17/20 3:58 PM, Sumit Garg wrote:
> Hi Maxim,
> 
> On Thu, 4 Jun 2020 at 23:28, Maxim Uvarov  wrote:
>>
>> With the evolving use-cases for TEE bus, now it's required to support
>> multi-stage enumeration process. But using a simple index doesn't
>> suffice this requirement and instead leads to duplicate sysfs entries.
>> So instead switch to use more informative device UUID for sysfs entry
>> like:
>> /sys/bus/tee/devices/optee-ta-
>>
>> Signed-off-by: Maxim Uvarov 
>> Reviewed-by: Sumit Garg 
>> ---
>>  Documentation/ABI/testing/sysfs-bus-optee-devices | 8 
>>  MAINTAINERS   | 1 +
>>  drivers/tee/optee/device.c| 9 ++---
>>  3 files changed, 15 insertions(+), 3 deletions(-)
>>  create mode 100644 Documentation/ABI/testing/sysfs-bus-optee-devices
>>
>> diff --git a/Documentation/ABI/testing/sysfs-bus-optee-devices 
>> b/Documentation/ABI/testing/sysfs-bus-optee-devices
>> new file mode 100644
>> index ..0ae04ae5374a
>> --- /dev/null
>> +++ b/Documentation/ABI/testing/sysfs-bus-optee-devices
>> @@ -0,0 +1,8 @@
>> +What:  /sys/bus/tee/devices/optee-ta-/
>> +Date:   May 2020
>> +KernelVersion   5.7
>> +Contact:tee-...@lists.linaro.org
>> +Description:
>> +   OP-TEE bus provides reference to registered drivers under 
>> this directory. The 
>> +   matches Trusted Application (TA) driver and corresponding TA 
>> in secure OS. Drivers
>> +   are free to create needed API under optee-ta- 
>> directory.
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index ecc0749810b0..6717afef2de3 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -12516,6 +12516,7 @@ OP-TEE DRIVER
>>  M: Jens Wiklander 
>>  L: tee-...@lists.linaro.org
>>  S: Maintained
>> +F: Documentation/ABI/testing/sysfs-bus-optee-devices
>>  F: drivers/tee/optee/
>>
>>  OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER
>> diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c
>> index e3a148521ec1..23d264c8146e 100644
>> --- a/drivers/tee/optee/device.c
>> +++ b/drivers/tee/optee/device.c
>> @@ -65,7 +65,7 @@ static int get_devices(struct tee_context *ctx, u32 
>> session,
>> return 0;
>>  }
>>
>> -static int optee_register_device(const uuid_t *device_uuid, u32 device_id)
>> +static int optee_register_device(const uuid_t *device_uuid)
>>  {
>> struct tee_client_device *optee_device = NULL;
>> int rc;
>> @@ -75,7 +75,10 @@ static int optee_register_device(const uuid_t 
>> *device_uuid, u32 device_id)
>> return -ENOMEM;
>>
>> optee_device->dev.bus = _bus_type;
>> -   dev_set_name(_device->dev, "optee-clnt%u", device_id);
>> +   if (dev_set_name(_device->dev, "optee-ta-%pUl", device_uuid)) {
> 
> You should be using format specifier as: "%pUb" instead of "%pUl" as
> UUID representation for TAs is in big endian format. See below:

Where does device_uuid come from? If it comes directly from OP-TEE, then
it should be a pointer to the following struct:

typedef struct
{
uint32_t timeLow;
uint16_t timeMid;
uint16_t timeHiAndVersion;
uint8_t clockSeqAndNode[8];
} TEE_UUID;

(GlobalPlatform TEE Internal Core API spec v1.2.1 section 3.2.4)

- The spec does not mandate any particular endianness and simply warns
about possible issues if secure and non-secure worlds differ in endianness.
- OP-TEE uses %pUl assuming that host order is little endian (that is
true for the Arm platforms that run OP-TEE currently). By the same logic
%pUl should be fine in the kernel.
- On the other hand, the UUID in a Trusted App header is always encoded
big endian by the Python script that signs and optionally encrypts the
TA. This should not have any visible impact on UUIDs exchanged between
the secure and non-secure world though.

So I am wondering why you had to use %pUb. There must be some
inconsistency somewhere :-/

-- 
Jerome

> 
> # ls /sys/bus/tee/devices/
> optee-ta-405b6ad9-e5c3-e321-8794-1002a5d5c61b
> optee-ta-71d950bc-c9d4-c442-82cb-343fb7f37896
> optee-ta-e70f4af0-5d1f-9b4b-abf7-619b85b4ce8c
> 
> While UUID for fTPM TA is in big endian format:
> bc50d971-d4c9-42c4-82cb-343fb7f37896
> 
> Sorry that I missed it during review and noticed this while testing.
> 
> With the above fix included, I tested this series using fTPM early TA
> on Qemu for aarch64 and used basic random number generation test using
> tpm2-tools. So feel free to add:
> 
> Tested-by: Sumit Garg 
> 
> -Sumit
> 
>> +   kfree(optee_device);
>> +   return -ENOMEM;
>> +   }
>> uuid_copy(_device->id.uuid, device_uuid);
>>
>> rc = device_register(_device->dev);
>> @@ -144,7 +147,7 @@ int optee_enumerate_devices(void)
>> num_devices = shm_size / sizeof(uuid_t);
>>
>> for (idx = 0; idx < num_devices; idx++) {
>> -   rc = optee_register_device(_uuid[idx], idx);
>> +   rc =