Skip to contentSkip to conversation

specs: Describe the TPM support in QEMU

PATCH Superseded Stefan Berger 3 participants 4 messages Jun 29, 2017 – Jul 4, 2017

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 specs: Describe the TPM support in QEMU

This patch adds a description of the current TPM support in QEMU to the specs.

Several public specs are referenced via their landing page on the trustedcomputinggroup.org website.

---
 docs/specs/tpm.txt | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 docs/specs/tpm.txt
docs/specs/tpm.txt new file +98 -0
new file mode 100644
index 0000000..6472989
@@ -0,0 +1,98 @@
+
+QEMU TPM Device
+===============
+
+= Guest-side Hardware Interface =
+
+The QEMU TPM emulation implements a TPM TIS hardware interface following
+the Trusted Computing Group's specification "TCG PC Client Specific TPM
+Interface Specification (TIS)", Specifcation Version 1.3, 21 March 2013.
+This specification, or a later version of it, can be accessed from the
+following URL:
+
+https://trustedcomputinggroup.org/pc-client-work-group-pc-client-specific-tpm-interface-specification-tis/
+
+The TIS interface makes a memory mapped IO region in the area 0xfed40000 -
+0xfed44fff available to the guest operating system.
+
+
+QEMU files related to TPM TIS interfaceL
+ - hw/tpm/tpm_tis.c
+ - hw/tpm/tpm_tis.h
+
+
+= ACPI Interface =
+
+The TPM device is defined with ACPI ID "PNP0C31". QEMU builds a SSDT and passes
+it into the guest through the fw_cfg device. The device description contains
+the base address of the TIS interface 0xfed40000 and the size of the MMIO area
+(0x5000). In case a TPM2 is used by QEMU, a TPM2 ACPI table is also provided.
+The device is described to be used in polling mode rather than interrupt mode
+primarily because no unused IRQ could be found.
+
+To support measurement logs to be written by the firmware, e.g. SeaBIOS, a TCPA
+table is implemented. This table provides a 64kb buffer where the firmware can
+write its log into. For TPM 2 only a more recent version of the TPM2 table
+provides support for measurements logs and a TCPA table does not need to be
+created.
+
+The TCPA and TPM2 ACPI tables follow the Trusted Computing Group specification
+"TCG ACPI Specification" Family "1.2" and "2.0", Level 00 Revision 00.37. This
+specification, or a later version of it, can be accessed from the following
+URL:
+
+https://trustedcomputinggroup.org/tcg-acpi-specification/
+
+
+QEMU files related to TPM ACPI tables:
+ - hw/i386/acpi-build.c
+ - include/hw/acpi/tpm.h
+
+
+= TPM backend devices =
+
+The TPM implementation is split into two parts, frontend and backend. 
+The frontend part is the hardware interface, such as the TPM TIS interface
+described earlier, and the other part is the TPM backend interface. The
+backend interfaces implement the interaction with a TPM device,
+which may be a physical or an emulated device. The split between the front-
+and backend devices allows a frontend to be connected with any available
+backend. This enables the TIS interface to be used with the passthrough
+backend or the swtpm backend.
+
+
+QEMU file related to TPM backends:
+ - backends/tpm.c
+ - include/sysemu/tpm_backend.h
+ - include/sysemu/tpm_backend_int.h
+
+
+== The QEMU TPM passthrough device ==
+
+In case QEMU is run on Linux as the host operating system it is possible to
+make the hardware TPM device available to a single QEMU guest. In this case the
+user must make sure that no other program is using the device, e.g., /dev/tpm0,
+before trying to start QEMU with it.
+
+The passthrough driver uses the host's TPM device for sending TPM commands
+and receiving responses from. Besides that it accesses the TPM device's sysfs
+entry for support of command cancellation. Since none of the state of a hardware
+TPM can be migrated between hosts, virtual machine migration is disabled when
+the TPM passthrough driver is used.
+
+Since the host's TPM device will already be initialize by the host's firmware,
+certain commands, e.g. TPM_Startup(), sent by the virtual firmware for device
+initialization, will fail. In this case the firmware should simply not use the
+TPM.
+
+Sharing the device with the host is generally not a recommended usage scenario
+for a TPM device. The primary reason for this is that two operating systems can
+then access the device's single set of resources, such as platform configuration
+registers (PCRs). Applications or kernel security subsystems, such as the
+Linux Integrity Measurement Architecture (IMA), are not expecting to share PCRs.
+
+
+QEMU files related to TPM passthrough device:
+ - hw/tpm/tpm_passthrough.c
+ - hw/tpm/tpm_util.c
+ - hw/tpm/tpm_util.h
Signature · 1 line
2.5.5
#1 lore raw
Quoted 12 lines · Stefan Berger

This patch adds a description of the current TPM support in QEMU to the specs.

Several public specs are referenced via their landing page on the trustedcomputinggroup.org website.

---
 docs/specs/tpm.txt | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 docs/specs/tpm.txt

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+QEMU files related to TPM TIS interfaceL

s/interfaceL/interface:/

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+Since the host's TPM device will already be initialize by the host's firmware,

s/initialize/initialized/

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 17 lines · Eric Blake

Review

Quoted 13 lines · Stefan Berger

This patch adds a description of the current TPM support in QEMU to the specs.

Several public specs are referenced via their landing page on the trustedcomputinggroup.org website.

---
  docs/specs/tpm.txt | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 98 insertions(+)

create mode 100644 docs/specs/tpm.txt

(quoted diff) +2 -0
+
+QEMU files related to TPM TIS interfaceL

s/interfaceL/interface:/

Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+Since the host's TPM device will already be initialize by the host's firmware,

s/initialize/initialized/

applied :-)

#3 lore raw
In reply to Stefan Berger
Quoted 27 lines · Stefan Berger

This patch adds a description of the current TPM support in QEMU to the specs.

Several public specs are referenced via their landing page on the trustedcomputinggroup.org website.

---
 docs/specs/tpm.txt | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 docs/specs/tpm.txt
docs/specs/tpm.txt new file +9 -0
new file mode 100644
index 0000000..6472989
@@ -0,0 +1,98 @@
+
+QEMU TPM Device
+===============
+
+= Guest-side Hardware Interface =
+
+The QEMU TPM emulation implements a TPM TIS hardware interface following
+the Trusted Computing Group's specification "TCG PC Client Specific TPM
+Interface Specification (TIS)", Specifcation Version 1.3, 21 March 2013.

docs/specs/tpm.txt line 19

Quoted 10 lines
docs/specs/tpm.txt new file +10 -0
+This specification, or a later version of it, can be accessed from the
+following URL:
+
+https://trustedcomputinggroup.org/pc-client-work-group-pc-client-specific-tpm-interface-specification-tis/
+
+The TIS interface makes a memory mapped IO region in the area 0xfed40000 -
+0xfed44fff available to the guest operating system.
+
+
+QEMU files related to TPM TIS interfaceL

... OK, Eric mentioned the typo already

Quoted 25 lines
docs/specs/tpm.txt new file +25 -0
+ - hw/tpm/tpm_tis.c
+ - hw/tpm/tpm_tis.h
+
+
+= ACPI Interface =
+
+The TPM device is defined with ACPI ID "PNP0C31". QEMU builds a SSDT and passes
+it into the guest through the fw_cfg device. The device description contains
+the base address of the TIS interface 0xfed40000 and the size of the MMIO area
+(0x5000). In case a TPM2 is used by QEMU, a TPM2 ACPI table is also provided.
+The device is described to be used in polling mode rather than interrupt mode
+primarily because no unused IRQ could be found.
+
+To support measurement logs to be written by the firmware, e.g. SeaBIOS, a TCPA
+table is implemented. This table provides a 64kb buffer where the firmware can
+write its log into. For TPM 2 only a more recent version of the TPM2 table
+provides support for measurements logs and a TCPA table does not need to be
+created.
+
+The TCPA and TPM2 ACPI tables follow the Trusted Computing Group specification
+"TCG ACPI Specification" Family "1.2" and "2.0", Level 00 Revision 00.37. This
+specification, or a later version of it, can be accessed from the following
+URL:
+
+https://trustedcomputinggroup.org/tcg-acpi-specification/

docs/specs/tpm.txt line 54

Quoted 10 lines
docs/specs/tpm.txt new file +10 -0
+
+
+QEMU files related to TPM ACPI tables:
+ - hw/i386/acpi-build.c
+ - include/hw/acpi/tpm.h
+
+
+= TPM backend devices =
+
+The TPM implementation is split into two parts, frontend and backend. 

git-am complains that this line adds a whitespace error (trailing space, namely).

docs/specs/tpm.txt line 61

Quoted 7 lines
docs/specs/tpm.txt new file +7 -0
+The frontend part is the hardware interface, such as the TPM TIS interface
+described earlier, and the other part is the TPM backend interface. The
+backend interfaces implement the interaction with a TPM device,
+which may be a physical or an emulated device. The split between the front-
+and backend devices allows a frontend to be connected with any available
+backend. This enables the TIS interface to be used with the passthrough
+backend or the swtpm backend.

In the previous (RFC-like) version, you wrote "(future) swtpm" -- I think that would be more precise. When QEMU gets swtpm support, we can update this language (because we should update the filename list(s) as well). What do you think?

docs/specs/tpm.txt line 64

Quoted 3 lines
docs/specs/tpm.txt new file +3 -0
+
+
+QEMU file related to TPM backends:

s/file/files/

docs/specs/tpm.txt line 67

Quoted 3 lines
docs/specs/tpm.txt new file +3 -0
+ - backends/tpm.c
+ - include/sysemu/tpm_backend.h
+ - include/sysemu/tpm_backend_int.h

Is this generic backend code? Because for the passthrough backend, you provide a separate file list below (which is great, but then we should qualify *this* list as "generic" or some such).

Quoted 6 lines
docs/specs/tpm.txt new file +6 -0
+
+
+== The QEMU TPM passthrough device ==
+
+In case QEMU is run on Linux as the host operating system it is possible to
+make the hardware TPM device available to a single QEMU guest. In this case the

docs/specs/tpm.txt line 83

Quoted 10 lines
docs/specs/tpm.txt new file +10 -0
+user must make sure that no other program is using the device, e.g., /dev/tpm0,
+before trying to start QEMU with it.
+
+The passthrough driver uses the host's TPM device for sending TPM commands
+and receiving responses from. Besides that it accesses the TPM device's sysfs
+entry for support of command cancellation. Since none of the state of a hardware
+TPM can be migrated between hosts, virtual machine migration is disabled when
+the TPM passthrough driver is used.
+
+Since the host's TPM device will already be initialize by the host's firmware,

s/initialize/initialized/

... ah, also pointed out by Eric.

Quoted 6 lines
docs/specs/tpm.txt new file +5 -0
+certain commands, e.g. TPM_Startup(), sent by the virtual firmware for device
+initialization, will fail. In this case the firmware should simply not use the
+TPM.
+
+Sharing the device with the host is generally not a recommended usage scenario

docs/specs/tpm.txt line 98

Quoted 10 lines
docs/specs/tpm.txt new file +10 -0
+for a TPM device. The primary reason for this is that two operating systems can
+then access the device's single set of resources, such as platform configuration
+registers (PCRs). Applications or kernel security subsystems, such as the
+Linux Integrity Measurement Architecture (IMA), are not expecting to share PCRs.
+
+
+QEMU files related to TPM passthrough device:
+ - hw/tpm/tpm_passthrough.c
+ - hw/tpm/tpm_util.c
+ - hw/tpm/tpm_util.h

This looks very helpful, thank you, and mostly done (as far as I'm concerned).

Again, if you were willing to add command line options as examples, that would be great, but if not, I'm fine (and thankful) that way as well.

Thanks!
Laszlo