Skip to content

Commit 7e1dc00

Browse files
stefanbergerJarkko Sakkinen
authored andcommitted
tpm: Add documentation for the tpm_vtpm_proxy device driver
Add documentation for the tpm_vtpm device driver that implements support for providing TPM functionality to Linux containers. Parts of this documentation were recycled from the Xen vTPM device driver documentation. Update the documentation for the ioctl numbers. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> CC: linux-kernel@vger.kernel.org CC: linux-doc@vger.kernel.org CC: linux-api@vger.kernel.org Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
1 parent 6f99612 commit 7e1dc00

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

Documentation/ioctl/ioctl-number.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ Code Seq#(hex) Include File Comments
303303
<mailto:buk@buks.ipn.de>
304304
0xA0 all linux/sdp/sdp.h Industrial Device Project
305305
<mailto:kenji@bitgate.com>
306+
0xA1 0 linux/vtpm_proxy.h TPM Emulator Proxy Driver
306307
0xA2 00-0F arch/tile/include/asm/hardwall.h
307308
0xA3 80-8F Port ACL in development:
308309
<mailto:tlewis@mindspring.com>

Documentation/tpm/tpm_vtpm_proxy.txt

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Virtual TPM Proxy Driver for Linux Containers
2+
3+
Authors: Stefan Berger (IBM)
4+
5+
This document describes the virtual Trusted Platform Module (vTPM)
6+
proxy device driver for Linux containers.
7+
8+
INTRODUCTION
9+
------------
10+
11+
The goal of this work is to provide TPM functionality to each Linux
12+
container. This allows programs to interact with a TPM in a container
13+
the same way they interact with a TPM on the physical system. Each
14+
container gets its own unique, emulated, software TPM.
15+
16+
17+
DESIGN
18+
------
19+
20+
To make an emulated software TPM available to each container, the container
21+
management stack needs to create a device pair consisting of a client TPM
22+
character device /dev/tpmX (with X=0,1,2...) and a 'server side' file
23+
descriptor. The former is moved into the container by creating a character
24+
device with the appropriate major and minor numbers while the file descriptor
25+
is passed to the TPM emulator. Software inside the container can then send
26+
TPM commands using the character device and the emulator will receive the
27+
commands via the file descriptor and use it for sending back responses.
28+
29+
To support this, the virtual TPM proxy driver provides a device /dev/vtpmx
30+
that is used to create device pairs using an ioctl. The ioctl takes as
31+
an input flags for configuring the device. The flags for example indicate
32+
whether TPM 1.2 or TPM 2 functionality is supported by the TPM emulator.
33+
The result of the ioctl are the file descriptor for the 'server side'
34+
as well as the major and minor numbers of the character device that was created.
35+
Besides that the number of the TPM character device is return. If for
36+
example /dev/tpm10 was created, the number (dev_num) 10 is returned.
37+
38+
The following is the data structure of the TPM_PROXY_IOC_NEW_DEV ioctl:
39+
40+
struct vtpm_proxy_new_dev {
41+
__u32 flags; /* input */
42+
__u32 tpm_num; /* output */
43+
__u32 fd; /* output */
44+
__u32 major; /* output */
45+
__u32 minor; /* output */
46+
};
47+
48+
Note that if unsupported flags are passed to the device driver, the ioctl will
49+
fail and errno will be set to EOPNOTSUPP. Similarly, if an unsupported ioctl is
50+
called on the device driver, the ioctl will fail and errno will be set to
51+
ENOTTY.
52+
53+
See /usr/include/linux/vtpm_proxy.h for definitions related to the public interface
54+
of this vTPM device driver.
55+
56+
Once the device has been created, the driver will immediately try to talk
57+
to the TPM. All commands from the driver can be read from the file descriptor
58+
returned by the ioctl. The commands should be responded to immediately.
59+
60+
Depending on the version of TPM the following commands will be sent by the
61+
driver:
62+
63+
- TPM 1.2:
64+
- the driver will send a TPM_Startup command to the TPM emulator
65+
- the driver will send commands to read the command durations and
66+
interface timeouts from the TPM emulator
67+
- TPM 2:
68+
- the driver will send a TPM2_Startup command to the TPM emulator
69+
70+
The TPM device /dev/tpmX will only appear if all of the relevant commands
71+
were responded to properly.

0 commit comments

Comments
 (0)