build: don't fail if given a git submodule which does not exist
[qemu/ar7.git] / docs / specs / tpm.txt
blob914daaceeafa4ad4010f8837364d283c6a67d20b
1 QEMU TPM Device
2 ===============
4 = Guest-side Hardware Interface =
6 The QEMU TPM emulation implements a TPM TIS hardware interface following the
7 Trusted Computing Group's specification "TCG PC Client Specific TPM Interface
8 Specification (TIS)", Specification Version 1.3, 21 March 2013. This
9 specification, or a later version of it, can be accessed from the following
10 URL:
12 https://trustedcomputinggroup.org/pc-client-work-group-pc-client-specific-tpm-interface-specification-tis/
14 The TIS interface makes a memory mapped IO region in the area 0xfed40000 -
15 0xfed44fff available to the guest operating system.
18 QEMU files related to TPM TIS interface:
19  - hw/tpm/tpm_tis.c
20  - hw/tpm/tpm_tis.h
23 = ACPI Interface =
25 The TPM device is defined with ACPI ID "PNP0C31". QEMU builds a SSDT and passes
26 it into the guest through the fw_cfg device. The device description contains
27 the base address of the TIS interface 0xfed40000 and the size of the MMIO area
28 (0x5000). In case a TPM2 is used by QEMU, a TPM2 ACPI table is also provided.
29 The device is described to be used in polling mode rather than interrupt mode
30 primarily because no unused IRQ could be found.
32 To support measurement logs to be written by the firmware, e.g. SeaBIOS, a TCPA
33 table is implemented. This table provides a 64kb buffer where the firmware can
34 write its log into. For TPM 2 only a more recent version of the TPM2 table
35 provides support for measurements logs and a TCPA table does not need to be
36 created.
38 The TCPA and TPM2 ACPI tables follow the Trusted Computing Group specification
39 "TCG ACPI Specification" Family "1.2" and "2.0", Level 00 Revision 00.37. This
40 specification, or a later version of it, can be accessed from the following
41 URL:
43 https://trustedcomputinggroup.org/tcg-acpi-specification/
46 QEMU files related to TPM ACPI tables:
47  - hw/i386/acpi-build.c
48  - include/hw/acpi/tpm.h
51 = TPM backend devices =
53 The TPM implementation is split into two parts, frontend and backend. The
54 frontend part is the hardware interface, such as the TPM TIS interface
55 described earlier, and the other part is the TPM backend interface. The backend
56 interfaces implement the interaction with a TPM device, which may be a physical
57 or an emulated device. The split between the front- and backend devices allows
58 a frontend to be connected with any available backend. This enables the TIS
59 interface to be used with the passthrough backend or the (future) swtpm backend.
62 QEMU files related to TPM backends:
63  - backends/tpm.c
64  - include/sysemu/tpm_backend.h
65  - include/sysemu/tpm_backend_int.h
68 == The QEMU TPM passthrough device ==
70 In case QEMU is run on Linux as the host operating system it is possible to
71 make the hardware TPM device available to a single QEMU guest. In this case the
72 user must make sure that no other program is using the device, e.g., /dev/tpm0,
73 before trying to start QEMU with it.
75 The passthrough driver uses the host's TPM device for sending TPM commands
76 and receiving responses from. Besides that it accesses the TPM device's sysfs
77 entry for support of command cancellation. Since none of the state of a
78 hardware TPM can be migrated between hosts, virtual machine migration is
79 disabled when the TPM passthrough driver is used.
81 Since the host's TPM device will already be initialized by the host's firmware,
82 certain commands, e.g. TPM_Startup(), sent by the virtual firmware for device
83 initialization, will fail. In this case the firmware should not use the TPM.
85 Sharing the device with the host is generally not a recommended usage scenario
86 for a TPM device. The primary reason for this is that two operating systems can
87 then access the device's single set of resources, such as platform configuration
88 registers (PCRs). Applications or kernel security subsystems, such as the
89 Linux Integrity Measurement Architecture (IMA), are not expecting to share PCRs.
92 QEMU files related to the TPM passthrough device:
93  - hw/tpm/tpm_passthrough.c
94  - hw/tpm/tpm_util.c
95  - hw/tpm/tpm_util.h
98 Command line to start QEMU with the TPM passthrough device using the host's
99 hardware TPM /dev/tpm0:
101 qemu-system-x86_64 -display sdl -enable-kvm \
102   -m 1024 -boot d -bios bios-256k.bin -boot menu=on \
103   -tpmdev passthrough,id=tpm0,path=/dev/tpm0 \
104   -device tpm-tis,tpmdev=tpm0 test.img
106 The following commands should result in similar output inside the VM with a
107 Linux kernel that either has the TPM TIS driver built-in or available as a
108 module:
110 #> dmesg | grep -i tpm
111 [    0.711310] tpm_tis 00:06: 1.2 TPM (device=id 0x1, rev-id 1)
113 #> dmesg | grep TCPA
114 [    0.000000] ACPI: TCPA 0x0000000003FFD191C 000032 (v02 BOCHS  \
115     BXPCTCPA 0000001 BXPC 00000001)
117 #> ls -l /dev/tpm*
118 crw-------. 1 root root 10, 224 Jul 11 10:11 /dev/tpm0
120 #> find /sys/devices/ | grep pcrs$ | xargs cat
121 PCR-00: 35 4E 3B CE 23 9F 38 59 ...
123 PCR-23: 00 00 00 00 00 00 00 00 ...