From: "Daniel P. Berrangé" <berrange@redhat.com>
To: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Stefan Berger <stefanb@linux.ibm.com>
Subject: Re: [PATCH v11 2/2] tpm: add backend for mssim
Date: Thu, 19 Dec 2024 17:39:46 +0000 [thread overview]
Message-ID: <Z2RaYsLkazgciofM@redhat.com> (raw)
In-Reply-To: <20241212170528.30364-3-James.Bottomley@HansenPartnership.com>
On Thu, Dec 12, 2024 at 12:05:28PM -0500, 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 based protocol on two
> 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 two sockets to be
> specified on the 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 service
> 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.
>
> To run this, simply download an emulator based on the MS specification
> (package ibmswtpm2 on openSUSE) and run it, then add these two lines
> to the qemu command and it will use the emulator.
>
> -tpmdev mssim,id=tpm0 \
> -device tpm-crb,tpmdev=tpm0 \
>
> to use a remote emulator replace the first line with
>
> -tpmdev "{'type':'mssim','id':'tpm0','command':{'type':inet,'host':'remote','port':'2321'}}"
>
> tpm-tis also works as the backend.
>
> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
> Acked-by: Markus Armbruster <armbru@redhat.com>
>
> ---
>
> v2: convert to SocketAddr json and use qio_channel_socket_connect_sync()
> v3: gate control power off by migration state keep control socket disconnected
> to test outside influence and add docs.
> v7: TPMmssim -> TPMMssim; doc and json fixes
> Make command socket open each time (makes OS debugging easier)
> v11: add startup method to make sure TPM is reset on reboot
> ---
> MAINTAINERS | 6 +
> backends/tpm/Kconfig | 5 +
> backends/tpm/meson.build | 1 +
> backends/tpm/tpm_mssim.c | 335 +++++++++++++++++++++++++++++++++++++++
> backends/tpm/tpm_mssim.h | 44 +++++
> docs/specs/tpm.rst | 39 +++++
> qapi/tpm.json | 31 +++-
> system/tpm-hmp-cmds.c | 9 ++
> 8 files changed, 466 insertions(+), 4 deletions(-)
> create mode 100644 backends/tpm/tpm_mssim.c
> create mode 100644 backends/tpm/tpm_mssim.h
>
> diff --git a/backends/tpm/tpm_mssim.c b/backends/tpm/tpm_mssim.c
> new file mode 100644
> index 0000000000..8f105fc924
> --- /dev/null
> +++ b/backends/tpm/tpm_mssim.c
> @@ -0,0 +1,335 @@
> +/*
> + * Emulator TPM driver which connects over the mssim protocol
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + * Copyright (c) 2022
Copyright by whom ? I presume yourself, but I wouldn't normally
assume the 'Author' line applies to the Copyright line.
> + * Author: James Bottomley <jejb@linux.ibm.com>
> + */
> +
> diff --git a/backends/tpm/tpm_mssim.h b/backends/tpm/tpm_mssim.h
> new file mode 100644
> index 0000000000..397474e4f6
> --- /dev/null
> +++ b/backends/tpm/tpm_mssim.h
> @@ -0,0 +1,44 @@
> +/*
> + * SPDX-License-Identifier: BSD-2-Clause
> + *
> + * The code below is copied from the Microsoft/TCG Reference implementation
> + *
> + * https://github.com/Microsoft/ms-tpm-20-ref.git
> + *
> + * In file TPMCmd/Simulator/include/TpmTcpProtocol.h
> + */
That file has a volumous copyright header that I would expect to be
preserved here.
> diff --git a/qapi/tpm.json b/qapi/tpm.json
> index e6345d424b..eed4cb9e82 100644
> --- a/qapi/tpm.json
> +++ b/qapi/tpm.json
> @@ -6,6 +6,8 @@
> # = TPM (trusted platform module) devices
> ##
>
> +{ 'include': 'sockets.json' }
> +
> ##
> # @TpmModel:
> #
> @@ -48,9 +50,11 @@
> #
> # @emulator: Software Emulator TPM type (since 2.11)
> #
> +# @mssim: Microsoft TPM Emulator (since 9.0)
Sorry, this needs a trivial bump to 10.0 now as that's
the current dev cycle
> +##
> +# @TPMMssimOptions:
> +#
> +# Information for the mssim emulator connection
> +#
> +# @command: command socket for the TPM emulator
> +#
> +# @control: control socket for the TPM emulator
> +#
> +# Since: 9.0
Likewise.
> +##
> +{ 'struct': 'TPMMssimOptions',
> + 'data': { '*command': 'SocketAddress',
> + '*control': 'SocketAddress' },
> + 'if': 'CONFIG_TPM' }
> +
> ##
> # @TpmTypeOptions:
> #
Functionally the code looks mergable with just those bureaucratic changes.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2024-12-19 17:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-12 17:05 [PATCH v11 0/2] tpm: add mssim backend James Bottomley
2024-12-12 17:05 ` [PATCH v11 1/2] tpm: convert tpmdev options processing to new visitor format James Bottomley
2025-01-07 7:41 ` Philippe Mathieu-Daudé
2025-01-07 14:12 ` Markus Armbruster
2024-12-12 17:05 ` [PATCH v11 2/2] tpm: add backend for mssim James Bottomley
2024-12-19 17:39 ` Daniel P. Berrangé [this message]
2025-01-07 2:11 ` James Bottomley
2025-01-07 8:11 ` Daniel P. Berrangé
2025-01-07 7:40 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z2RaYsLkazgciofM@redhat.com \
--to=berrange@redhat.com \
--cc=James.Bottomley@hansenpartnership.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.