Skip to contentSkip to conversation

ioctl API for vTPM driver

DISCUSSION Jarkko Sakkinen 3 participants 13 messages Mar 6, 2016 – Mar 8, 2016 14 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Hi

Some follow-up question that have popped up while I've started to write a test program for this feature mainly about ioctl API. It's better to be extremly cautious here because we will be stuck with this ioctl forever.

1. Why the ioctl name is VTPM_NEW_DEV but the struct name is vtpm_new_pair? It would be better if they both were either VTPM_NEW_DEV and vtpm_new_dev or alternatively VTPM_NEW_PAIR and vtpm_new_pair.
2. Is 'pair' or 'tuple' a better term?
3. Where is the documentation for the ioctl? I don't think I can merge this to my next branch before it exists.
4. I have forgotten why the major and minor numbers were returned. My guess is that they were returned so that a container could replicate the device? This is one reason why documentation is mandatory.

/Jarkko

------------------------------------------------------------------------------

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 7 lines · Jarkko Sakkinen

Hi

Some follow-up question that have popped up while I've started to write a test program for this feature mainly about ioctl API. It's better to be extremly cautious here because we will be stuck with this ioctl forever.

Quoted 11 lines

1. Why the ioctl name is VTPM_NEW_DEV but the struct name is vtpm_new_pair? It would be better if they both were either VTPM_NEW_DEV and vtpm_new_dev or alternatively VTPM_NEW_PAIR and vtpm_new_pair.
2. Is 'pair' or 'tuple' a better term?
3. Where is the documentation for the ioctl? I don't think I can merge this to my next branch before it exists.
4. I have forgotten why the major and minor numbers were returned. My guess is that they were returned so that a container could replicate the device? This is one reason why documentation is mandatory.

5. Is there any particular reason why 'tpm_dev_num' couldn't simply be 'dev_num'?

/Jarkko

------------------------------------------------------------------------------

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 20 lines · Jarkko Sakkinen
Quoted 7 lines · Jarkko Sakkinen

Hi

Some follow-up question that have popped up while I've started to write a test program for this feature mainly about ioctl API. It's better to be extremly cautious here because we will be stuck with this ioctl forever.

Quoted 11 lines

1. Why the ioctl name is VTPM_NEW_DEV but the struct name is vtpm_new_pair? It would be better if they both were either VTPM_NEW_DEV and vtpm_new_dev or alternatively VTPM_NEW_PAIR and vtpm_new_pair.
2. Is 'pair' or 'tuple' a better term?
3. Where is the documentation for the ioctl? I don't think I can merge this to my next branch before it exists.
4. I have forgotten why the major and minor numbers were returned. My guess is that they were returned so that a container could replicate the device? This is one reason why documentation is mandatory.

Quoted 2 lines

5. Is there any particular reason why 'tpm_dev_num' couldn't simply be 'dev_num'?

I think you should still send a patch set after documentation has been completed and we have addressed these items to the following mailing lists:

* linux-kernel
* linux-api
* linux-doc
* tpmdd

Now these patches have circled only in the tpmdd mailing list which is not sufficient. I just realized this recently that the relevant mailing lists were completely missing (while starting to write a test program).

For patches up to TPM_CHIP_FLAG_VIRTUAL you could downloaded patches from my repository before posting the patch set since they include also my reviewed/tested-by's.

Thanks.

/Jarkko

------------------------------------------------------------------------------

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/[email protected]> wrote on 03/06/2016 07:28:16 AM:

Quoted 6 lines

From: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/[email protected]>
To: Stefan Berger <[email protected]>
Cc: [email protected]
Date: 03/06/2016 07:29 AM
Subject: Re: [tpmdd-devel] ioctl API for vTPM driver

Quoted 7 lines
Quoted 6 lines · Jarkko Sakkinen
Quoted 5 lines · Jarkko Sakkinen

Hi

Some follow-up question that have popped up while I've started to write a test program for this feature mainly about ioctl API. It's better to be extremly cautious here because we will be stuck with

this

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

ioctl forever.

1. Why the ioctl name is VTPM_NEW_DEV but the struct name is vtpm_new_pair? It would be better if they both were either VTPM_NEW_DEV and vtpm_new_dev or alternatively VTPM_NEW_PAIR and vtpm_new_pair.

Renamed it to vtpm_new_dev.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

2. Is 'pair' or 'tuple' a better term?
3. Where is the documentation for the ioctl? I don't think I can merge this to my next branch before it exists.

I'll add some later today or tomorrow.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

4. I have forgotten why the major and minor numbers were returned. My guess is that they were returned so that a container could replicate the device? This is one reason why documentation is mandatory.

Yes, it's there so that inside a container a device with that major and minor number can be created and device cgroups be setup.

Quoted 3 lines
Quoted 3 lines

5. Is there any particular reason why 'tpm_dev_num' couldn't simply be 'dev_num'?

Renamed to 'tpm_num' Updated my git repo.

Quoted 9 lines

I think you should still send a patch set after documentation has been completed and we have addressed these items to the following mailing lists:

* linux-kernel
* linux-api
* linux-doc
* tpmdd

The whole patchset as 'v5' ?

Quoted 9 lines

Now these patches have circled only in the tpmdd mailing list which is not sufficient. I just realized this recently that the relevant mailing lists were completely missing (while starting to write a test program).

For patches up to TPM_CHIP_FLAG_VIRTUAL you could downloaded patches from my repository before posting the patch set since they include also my reviewed/tested-by's.

Ok, will sync.

Stefan

Quoted 6 lines

Thanks.

/Jarkko

------------------------------------------------------------------------------

Quoted 5 lines

_______________________________________________
tpmdd-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

------------------------------------------------------------------------------

_______________________________________________
tpmdd-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

#7 lore raw
In reply to a message not in the archive

Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/[email protected]> wrote on 03/06/2016 07:28:16 AM:

Quoted 8 lines · Jarkko Sakkinen
Quoted 6 lines · Jarkko Sakkinen
Quoted 5 lines

Hi

Some follow-up question that have popped up while I've started to write a test program for this feature mainly about ioctl API. It's better to be extremly cautious here because we will be stuck with

this

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines

ioctl forever.

1. Why the ioctl name is VTPM_NEW_DEV but the struct name is vtpm_new_pair? It would be better if they both were either VTPM_NEW_DEV and vtpm_new_dev or alternatively VTPM_NEW_PAIR and vtpm_new_pair.
2. Is 'pair' or 'tuple' a better term?
3. Where is the documentation for the ioctl? I don't think I can merge this to my next branch before it exists.
4. I have forgotten why the major and minor numbers were returned. My guess is that they were returned so that a container could replicate the device? This is one reason why documentation is mandatory.

Quoted 6 lines
Quoted 2 lines

5. Is there any particular reason why 'tpm_dev_num' couldn't simply be 'dev_num'?

I think you should still send a patch set after documentation has been completed and we have addressed these items to the following mailing lists:

Here's the documentation patch:

https://github.com/stefanberger/linux/commit/bf1d11a67be64e580636c90cb8acbace80e16ab7

If you have suggestions or comments, let me know.

I adjusted the code to reflect the ENOSYS (previously EINVAL) in case of unsupported flags or unsupported ioctls.

Regards,
Stefan

------------------------------------------------------------------------------
Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more.
http://makebettercode.com/inteldaal-eval

_______________________________________________
tpmdd-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

A message that is not in the archive (sent off-list or not yet received): 201603070040.u270eq7U019952-CUdSWdNILC7ImUpY6SP3GEEOCMrvLtNR@public.gmane.org

#9 lore raw
Quoted 3 lines · Stefan Berger

If you have suggestions or comments, let me know.
I adjusted the code to reflect the ENOSYS (previously EINVAL) in case of unsupported flags or unsupported ioctls.

Please don't use ENOSYS, the desire is that is only used by systemcalls.

Jason

------------------------------------------------------------------------------
Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more.
http://makebettercode.com/inteldaal-eval

A message that is not in the archive (sent off-list or not yet received): 20160307203206.GA4303-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

#11 lore raw

Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote on 03/07/2016 03:32:06 PM:

Quoted 5 lines · Stefan Berger
Quoted 3 lines

If you have suggestions or comments, let me know.
I adjusted the code to reflect the ENOSYS (previously EINVAL) in

case

Quoted 4 lines
Quoted 1 line

of unsupported flags or unsupported ioctls.

Please don't use ENOSYS, the desire is that is only used by systemcalls.

Ok, found alternatives: ENOTSUPP for the flag and ENOIOCTLCMD for the unsupported ioctl ?

Stefan

------------------------------------------------------------------------------
Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more.
http://makebettercode.com/inteldaal-eval

_______________________________________________
tpmdd-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 201603072115.u27LFcMK001519-4ZtxiNBBw+3ImUpY6SP3GEEOCMrvLtNR@public.gmane.org

#14 lore raw
Quoted 7 lines · Stefan Berger

Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote on 03/07/2016 03:32:06 PM:

Quoted 5 lines · Stefan Berger
Quoted 3 lines

If you have suggestions or comments, let me know.
I adjusted the code to reflect the ENOSYS (previously EINVAL) in

Quoted 8 lines

case

Quoted 4 lines
Quoted 1 line

of unsupported flags or unsupported ioctls.

Please don't use ENOSYS, the desire is that is only used by systemcalls.

Ok, found alternatives: ENOTSUPP for the flag ENOIOCTLCMD for the unsupported ioctl ?

ENOIOCTLCMD might be OK, just make sure it gets converted to ENOTTY:

390  * Is it an unrecognized ioctl? The correct returns are either
391  * ENOTTY (final) or ENOIOCTLCMD ("I don't know this one, try a
392  * fallback"). ENOIOCTLCMD gets turned into ENOTTY by the ioctl
393  * code before returning.

ENOTSUPP is for NFS internal use only, can't be exported to user space.

Try EOPNOTSUPP

Jason

------------------------------------------------------------------------------
Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more.
http://makebettercode.com/inteldaal-eval

A message that is not in the archive (sent off-list or not yet received): 20160307213453.GA4630-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

#16 lore raw

Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote on 03/07/2016 04:34:53 PM:

Quoted 4 lines

Subject: Re: [tpmdd-devel] ioctl API for vTPM driver

Quoted 1 line · Stefan Berger

Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote on

03/07/2016

Quoted 6 lines
Quoted 6 lines
   03:32:06 PM:
   >
   > On Sun, Mar 06, 2016 at 07:40:40PM -0500, Stefan Berger wrote:
   >
   > >    If you have suggestions or comments, let me know.
   > >    I adjusted the code to reflect the ENOSYS (previously 

EINVAL) in

Quoted 11 lines
Quoted 8 lines

case

Quoted 4 lines
Quoted 1 line

of unsupported flags or unsupported ioctls.

Please don't use ENOSYS, the desire is that is only used by systemcalls.

Ok, found alternatives: ENOTSUPP for the flag ENOIOCTLCMD for the unsupported ioctl ?

ENOIOCTLCMD might be OK, just make sure it gets converted to ENOTTY:

Quoted 7 lines
390  * Is it an unrecognized ioctl? The correct returns are either
391  * ENOTTY (final) or ENOIOCTLCMD ("I don't know this one, try a
392  * fallback"). ENOIOCTLCMD gets turned into ENOTTY by the ioctl
393  * code before returning.

ENOTSUPP is for NFS internal use only, can't be exported to user space.

It's found in more then 300 files using that errno...

http://lxr.free-electrons.com/ident?i=ENOTSUPP

Quoted 2 lines

Try EOPNOTSUPP

Ok, I will use that one.

Stefan

Quoted 3 lines

Jason

------------------------------------------------------------------------------
Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more.
http://makebettercode.com/inteldaal-eval

_______________________________________________
tpmdd-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 201603072224.u27MOBJO007812-prK0F/[email protected]

#19 lore raw
Quoted 2 lines · Stefan Berger

It's found in more then 300 files using that errno... [1]http://lxr.free-electrons.com/ident?i=ENOTSUPP

No idea if those leak to user space or not, but ENOTSUPP is not exposed to user space:

grep -r 524 /usr/include/bits*

So there is nothing a user space app can do with it.

Jason

------------------------------------------------------------------------------
Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more.
http://makebettercode.com/inteldaal-eval

#20 lore raw
In reply to a message not in the archive

Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/[email protected]> wrote on 03/06/2016 07:28:16 AM:

Quoted 8 lines · Jarkko Sakkinen
Quoted 6 lines · Jarkko Sakkinen
Quoted 5 lines

Hi

Some follow-up question that have popped up while I've started to write a test program for this feature mainly about ioctl API. It's better to be extremly cautious here because we will be stuck with

this

Quoted 26 lines
Quoted 14 lines
Quoted 13 lines

ioctl forever.

1. Why the ioctl name is VTPM_NEW_DEV but the struct name is vtpm_new_pair? It would be better if they both were either VTPM_NEW_DEV and vtpm_new_dev or alternatively VTPM_NEW_PAIR and vtpm_new_pair.
2. Is 'pair' or 'tuple' a better term?
3. Where is the documentation for the ioctl? I don't think I can merge this to my next branch before it exists.
4. I have forgotten why the major and minor numbers were returned. My guess is that they were returned so that a container could replicate the device? This is one reason why documentation is mandatory.

Quoted 2 lines

5. Is there any particular reason why 'tpm_dev_num' couldn't simply be 'dev_num'?

I think you should still send a patch set after documentation has been completed and we have addressed these items to the following mailing lists:

* linux-kernel
* linux-api
* linux-doc
* tpmdd

Quoted 8 lines

Now these patches have circled only in the tpmdd mailing list which is not sufficient. I just realized this recently that the relevant mailing lists were completely missing (while starting to write a test program).

For patches up to TPM_CHIP_FLAG_VIRTUAL you could downloaded patches from my repository before posting the patch set since they include also my reviewed/tested-by's.

I will post a v6 tomorrow again with the 3 vtpm related patches cc'ed to the above mailing lists. V6 addresses the errno's Jason has been suggesting.

Stefan

------------------------------------------------------------------------------
Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more.
http://makebettercode.com/inteldaal-eval

_______________________________________________
tpmdd-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 201603061621.u26GLsne030524-4ZtxiNBBw+3ImUpY6SP3GEEOCMrvLtNR@public.gmane.org

#23 lore raw
Quoted 10 lines · Stefan Berger
Quoted 8 lines

Now these patches have circled only in the tpmdd mailing list which is not sufficient. I just realized this recently that the relevant mailing lists were completely missing (while starting to write a test program).

For patches up to TPM_CHIP_FLAG_VIRTUAL you could downloaded patches from my repository before posting the patch set since they include also my reviewed/tested-by's.

Ok, will sync.

In the mean time I'll continue porting Peters (Hüwe) Python script to run on top of vtpm so that I can run my smoke tests [1] by using TPM 2.0 simulator.

Quoted 1 line

Stefan

[1] git://git.infradead.org/users/jjs/tpm2-scripts.git

/Jarkko

------------------------------------------------------------------------------
Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more.
http://makebettercode.com/inteldaal-eval

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): 201603081724.u28HOrRB005375-CUdSWdNILC7ImUpY6SP3GEEOCMrvLtNR@public.gmane.org

#26 lore raw
Quoted 43 lines · Stefan Berger

Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/[email protected]> wrote on 03/06/2016 07:28:16 AM:

Quoted 8 lines · Jarkko Sakkinen
Quoted 6 lines · Jarkko Sakkinen
Quoted 5 lines

Hi

Some follow-up question that have popped up while I've started to write a test program for this feature mainly about ioctl API. It's better to be extremly cautious here because we will be stuck with

this

Quoted 31 lines
Quoted 14 lines
Quoted 13 lines

ioctl forever.

1. Why the ioctl name is VTPM_NEW_DEV but the struct name is vtpm_new_pair? It would be better if they both were either VTPM_NEW_DEV and vtpm_new_dev or alternatively VTPM_NEW_PAIR and vtpm_new_pair.
2. Is 'pair' or 'tuple' a better term?
3. Where is the documentation for the ioctl? I don't think I can merge this to my next branch before it exists.
4. I have forgotten why the major and minor numbers were returned. My guess is that they were returned so that a container could replicate the device? This is one reason why documentation is mandatory.

Quoted 2 lines

5. Is there any particular reason why 'tpm_dev_num' couldn't simply be 'dev_num'?

I think you should still send a patch set after documentation has been completed and we have addressed these items to the following mailing lists:

* linux-kernel
* linux-api
* linux-doc
* tpmdd

Now these patches have circled only in the tpmdd mailing list which is not sufficient. I just realized this recently that the relevant mailing lists were completely missing (while starting to write a test program).

Quoted 7 lines
Quoted 3 lines

For patches up to TPM_CHIP_FLAG_VIRTUAL you could downloaded patches from my repository before posting the patch set since they include also my reviewed/tested-by's.

I will post a v6 tomorrow again with the 3 vtpm related patches cc'ed to the above mailing lists. V6 addresses the errno's Jason has been suggesting.

I've used today improving this:

git://git.infradead.org/users/jjs/buildroot-tpmdd.git

By doing

make tpmdd_defconfig
make

You get a file called 'tpmdd.img' that you can flash to a USB stick. The image is both legacy and UEFI bootable. The kernel is my latest master and perf is included for tracing.

The compiled kernel has vtpm enabled.

There's a scripts called board/tpmdd/image.sh that does the image generation magic. I've only tested it in Ubuntu environment.

As the next step I'll finish my test script for vtpm and use it and TPM 2.0 simulator to test your functionality.

Quoted 1 line

Stefan

/Jarkko

------------------------------------------------------------------------------
Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more.
http://makebettercode.com/inteldaal-eval