Create a vTPM
Create a hardware-rooted vTPM for a VM, attach it to QEMU, check it from the guest, and manage it day to day.
A vTPM belongs to the user who will run the VM, is created and started by the host notary, and stops with its VM. This page covers its whole lifecycle. You need a host notary with the swtpm-notary fork installed; see What you need.
Create it
Create it for the user QEMU will run as, so that QEMU can run without root. The client uid and gid own the vTPM’s sockets.
sudo eqty-notaryctl vtpm create --id vm1 --client-uid "$(id -u)" --client-gid "$(id -g)"The notary seals a state key, starts swtpm, provisions the EK (TCG template L-2, persisted at
0x81010002) and the IAK (persisted at 0x81020001), writes both certificates into
platform-created, write-locked NV (0x01c0000a and 0x01c90100) and the issuer chain from
0x01c00100 onward, and leaves the vTPM running. Its sockets are:
/var/run/eqty-notary/vtpm/vm1.sock # the TPM data socket
/var/run/eqty-notary/vtpm/vm1.sock.ctrl # the swtpm control socket, for QEMUBacking modes
| Mode | Which keys are hardware-held | Use |
|---|---|---|
identity | The IAK and AKs created under the endorsement hierarchy. Low volume: quotes and certifies are rare. | Default with the fork. Attestation rooted in the host. |
all-signing | Every asymmetric signing key. | Bounded by the host TPM’s throughput, tens of signatures per second. Measure before relying on it. |
none | Nothing; a stock vTPM with sealed state. | When the fork is not installed, or for a plain vTPM. |
--backing on create picks per vTPM; EQTY_VTPM_BACKING sets the default.
Attach it to QEMU
QEMU attaches to the control socket with the TPM emulator backend:
qemu-system-x86_64 ... \
-chardev socket,id=chrtpm,path=/var/run/eqty-notary/vtpm/vm1.sock.ctrl \
-tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0On arm64, including Apple silicon under HVF, the device is tpm-tis-device, and QEMU 11.1 and
later need ppi=off on it or they abort with HV_BAD_ARGUMENT:
qemu-system-aarch64 -machine virt,accel=hvf ... \
-chardev socket,id=chrtpm,path=/var/run/eqty-notary/vtpm/vm1.sock.ctrl \
-tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis-device,tpmdev=tpm0,ppi=offThe guest sees /dev/tpm0 and /dev/tpmrm0. QEMU resets the TPM at every VM start, so each boot
begins with clean PCRs, and the guest’s firmware and kernel IMA measure into the vTPM from the
first instruction.
The full QEMU walkthrough, with a cloud image and a guest notary, is Run a Guest Notary.
Check it from the guest
With tpm2-tools in the guest, read the IAK certificate and take a quote the host hardware signs:
tpm2_nvread 0x01c90100 -o iak.der
openssl x509 -inform der -in iak.der -noout -subject -issuer
# subject=O=EQTY, CN=vTPM vm1 IAK
# issuer=O=EQTY, CN=EQTY Notary AK <id> (SK <id> on a Mac)
tpm2_readpublic -c 0x81020001 -f pem -o iak.pem
tpm2_quote -c 0x81020001 -l sha256:0,7 -q c0ffee -m q.msg -s q.sig -o q.pcr -g sha256
tpm2_checkquote -u iak.pem -m q.msg -s q.sig -f q.pcr -q c0ffee -g sha256 && echo verifiedThe root certificate in NV 0x01c00100 carries the host notary’s did:key in its subject
alternative name, the same DID as the host notary’s identity credential. That is where the TPM
evidence and the EQTY credentials meet.
Owner operations
A vTPM’s owner, the client uid it was created with, may list, show, start and stop that
vTPM over the Unix socket without root, so a user can bring their VM’s TPM up without sudo.
EQTY_VTPM_OWNER_OPS narrows the set; empty means root only. Create and delete are always root
only, and another user’s vTPM answers 404.
Delete
sudo eqty-notaryctl vtpm delete vm1Stops the vTPM and destroys its sealed state key and backing keys, in the TPM or the System keychain. The state cannot be recovered on this machine or any other.
Protection on the host
On Linux the daemon runs each swtpm with a clean environment, no core dumps, its own session, an
exec from the descriptor that was hashed, and the state keys over pipes. The BPF LSM key guard
adds rules for vTPMs: only the notary or a registered swtpm inside its own state directory may
open files under EQTY_VTPM_DIR; nobody but the notary may ptrace the notary or a swtpm; only
the notary loads tracing BPF programs; only registered swtpm processes connect to the notary
socket; and, opt-in with EQTY_GUARD_TPM_DEVICE=1, only the notary opens the host TPM device.
EQTY_VTPM_ALLOWED_HASHES pins the emulator binary.
On macOS there is no such guard. File modes and the System keychain’s code-signing ACL are the protection, and PCR binding is not available.
What is still open: the EK stays a software key (its seed is hardware-derived, but ECDH is not
forwarded yet); host PCRs are not in the backing-key policy; and there is no VCompVTpmV1
credential type yet, so a vTPM is told apart from hardware only by its chain’s issuer being an
EQTY notary rather than a TPM vendor. The design document, docs/VTPM.md in the repository,
tracks these.