From f4ede81eed29e6140374177d1f2808248c5b5650 Mon Sep 17 00:00:00 2001 From: Amarnath Valluri Date: Fri, 29 Sep 2017 14:10:20 +0300 Subject: tpm: Added support for TPM emulator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change introduces a new TPM backend driver that can communicate with swtpm(software TPM emulator) using unix domain socket interface. QEMU talks to the TPM emulator using QEMU's socket-based chardev backend device. Swtpm uses two Unix sockets for communications, one for plain TPM commands and responses, and one for out-of-band control messages. QEMU passes the data socket to be used over the control channel. The swtpm and associated tools can be found here: https://github.com/stefanberger/swtpm The swtpm's control channel protocol specification can be found here: https://github.com/stefanberger/swtpm/wiki/Control-Channel-Specification Usage: # setup TPM state directory mkdir /tmp/mytpm chown -R tss:root /tmp/mytpm /usr/bin/swtpm_setup --tpm-state /tmp/mytpm --createek # Ask qemu to use TPM emulator with given tpm state directory qemu-system-x86_64 \ [...] \ -chardev socket,id=chrtpm,path=/tmp/swtpm-sock \ -tpmdev emulator,id=tpm0,chardev=chrtpm \ -device tpm-tis,tpmdev=tpm0 \ [...] Signed-off-by: Amarnath Valluri Reviewed-by: Marc-André Lureau Tested-by: Stefan Berger Signed-off-by: Stefan Berger --- hmp.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'hmp.c') diff --git a/hmp.c b/hmp.c index 739d330f4e..ec61329ebb 100644 --- a/hmp.c +++ b/hmp.c @@ -1000,6 +1000,7 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) Error *err = NULL; unsigned int c = 0; TPMPassthroughOptions *tpo; + TPMEmulatorOptions *teo; info_list = qmp_query_tpm(&err); if (err) { @@ -1029,6 +1030,10 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) tpo->has_cancel_path ? ",cancel-path=" : "", tpo->has_cancel_path ? tpo->cancel_path : ""); break; + case TPM_TYPE_OPTIONS_KIND_EMULATOR: + teo = ti->options->u.emulator.data; + monitor_printf(mon, ",chardev=%s", teo->chardev); + break; case TPM_TYPE_OPTIONS_KIND__MAX: break; } -- cgit v1.2.1