On Mon, 2022-12-12 at 08:43 -0500, Stefan Berger wrote: > > > On 12/10/22 12:10, James Bottomley wrote: > > The Microsoft Simulator (mssim) is the reference emulation platform > > for the TCG TPM 2.0 specification. > > > > https://github.com/Microsoft/ms-tpm-20-ref.git > > > > It exports a fairly simple network socket baset protocol on two > > baset -> based. > > > sockets, one for command (default 2321) and one for control > > (default 2322). This patch adds a simple backend that can speak > > the mssim protocol over the network. It also allows the host, and > > two ports to be specified on the qemu command line. The benefits > > are twofold: firstly it gives us a backend that actually speaks a > > standard TPM emulation protocol instead of the linux specific TPM > > driver format of the current emulated TPM backend and secondly, > > using the microsoft protocol, the end point of the emulator can be > > anywhere on the network, facilitating the cloud use case where a > > central TPM ervice can be used over a control network. > > > > The implementation does basic control commands like power off/on, > > but doesn't implement cancellation or startup. The former because > > cancellation is pretty much useless on a fast operating TPM > > emulator and the latter because this emulator is designed to be > > used with OVMF which itself does TPM startup and I wanted to > > validate that. > > How did you implement VM suspend/resume and snapshotting support?
TPM2 doesn't need to. The mssim follows the reference model which obeys the TPM2_Shutdown protocol, so the software does a power off with TPM2_Shutdown(TPM_SU_STATE) This allows poweroff to preserve the PCR state, provided the startup does TPM2_Startup(TPM_SU_STATE). the edk2 SecurityPackage does this in OVMF on S3 Resume, so using this backend allows us to check the OVMF startup for correctness. Now getting QEMU to go through S3 suspend is another issue, but when it does, the TPM should just work. James