swtpm_ioctl - Man Page

Utility for sending control commands to swtpm


swtpm_ioctl [COMMAND] <device>


swtpm_ioctl implements a client tool for controlling the swtpm_cuse TPM software emulator, such as for example its initialization and shutdown. Once the swtpm_cuse has been initialized, TPM commands can be sent to it.

The full path to the swtpm_cuse's character device must be provided such  as for example /dev/vtpm-200.

The environment variable SWTPM_IOCTL_BUFFERSIZE can be set to the size for the buffer for state blob transfer to use. If it is not set, the ioctl() interface is used for transferring the state. This environment variable is primarily used for testing purposes.

The following commands are supported:

--tpm-device <device>

Use the given device.

This option can be used instead of providing the device as the last parameter.

--tcp <server>:<port>

Connect to the given server and port; if no server is given, is used; if port is not given, the default port 6545 is used.

--unixio <path>

Connect to the given UnixIO path.


Get the swtpm_cuse's capability flags indicating which commands are supported.


Send a hardware initialization signal to the swtpm_cuse. Volatile state previously written by the TPM will be read and the file automatically delete.


Gracefully shut the swtpm_cuse down.


Stop the swtpm_cuse. This does not shut it down. The -i command can again be sent to it. After a stop it is also possible to load TPM stateblobs into the TPM using the --load command.


Get the tpmEstablished bit.

-r locality

Reset the tpmEstablished bit using the given locality. Only localities 3 and 4 work. This operation will not permanently change the localty that was previously set using the -l option.

-l locality

Set the locality for the subsequent TPM commands.


Have the TPM write the volatile state to a file. Upon a TPM_Init (-i) the TPM state will be read and the TPM can then resume operation without further intialization.


Cancel an ongoing TPM command.

-h data

Reset and extend PCR 17 with the hash of the given data. If data is the single character '-', then all data are read from stdin.

--save <TPM state blob name> <filename>

Save the TPM state blob into the given file. Valid TPM state blob names are permanent, volatile, and savestate.

Note that this command can be executed at any time. However, to retrieve the latest volatile state, the -v command should have been run immediately before running this command. The savestate blob will only be returned if a TPM_SaveState command was executed in the TPM.

--load <TPM state blob name> <filename>

Load the given TPM state blob from the given file. Valid TPM state blob names are permanent, volatile, and savestate.

Note that this command can only be executed on a TPM that is shut down. To then start the TPM with the uploaded state, the -i command must be issued.


Get configuration flags that for example indicate which keys (file encryption or migration key) are in use by the TPM.

--info <flag>

Get information about the TPM implementation in JSON format. The flag <TPMLIB_INFO_TPMSPECIFICATION>, which has the value 1, returns information about the specification the TPM implementation followed.

See Also


Referenced By


2017-11-13 swtpm