Skip to contentSkip to conversation

Merge tpm 2018/02/21 v2

GIT PULL Applied Stefan Berger 2 participants 4 messages Feb 27, 2018 – Mar 1, 2018

lore
Share & tools
lore
#0 lore raw

This patch series adds a test case for the TPM TIS interface.

Stefan

Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180220-pull-request' into staging (2018-02-20 14:05:00 +0000)

are available in the git repository at:

git://github.com/stefanberger/qemu-tpm.git tags/pull-tpm-2018-02-21-2

for you to fetch changes up to adb0e917e6ee93631e40265ca145bc31cd3b6c9a:

tests: add test for TPM TIS device (2018-02-21 07:24:50 -0500)

----------------------------------------------------------------
Merge tpm 2018/02/21 v2

----------------------------------------------------------------
Stefan Berger (2):
tests: Move common TPM test code into tpm-emu.c
tests: add test for TPM TIS device

 MAINTAINERS            |   1 +
 hw/tpm/tpm_tis.c       | 101 -----------------
 include/hw/acpi/tpm.h  | 105 ++++++++++++++++++
 tests/Makefile.include |   4 +-
 tests/tpm-crb-test.c   | 174 +----------------------------
 tests/tpm-emu.c        | 174 +++++++++++++++++++++++++++++
 tests/tpm-emu.h        |  38 +++++++
 tests/tpm-tis-test.c   | 486 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 810 insertions(+), 273 deletions(-)
 create mode 100644 tests/tpm-emu.c
 create mode 100644 tests/tpm-emu.h
 create mode 100644 tests/tpm-tis-test.c
Signature · 1 line
2.5.5
#1 lore raw

[Qemu-devel] [PULL v2 1/2] tests: Move common TPM test code into tpm-emu.c

Move threads and other common TPM test code into tpm-emu.c.

---
 tests/Makefile.include |   2 +-
 tests/tpm-crb-test.c   | 174 +------------------------------------------------
 tests/tpm-emu.c        | 167 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/tpm-emu.h        |  38 +++++++++++
 4 files changed, 209 insertions(+), 172 deletions(-)
 create mode 100644 tests/tpm-emu.c
 create mode 100644 tests/tpm-emu.h
tests/Makefile.include +1 -1
index a1bcbff..ff44264 100644
@@ -714,7 +714,7 @@ tests/test-crypto-tlssession$(EXESUF): tests/test-crypto-tlssession.o \
 tests/test-io-task$(EXESUF): tests/test-io-task.o $(test-io-obj-y)
 tests/test-io-channel-socket$(EXESUF): tests/test-io-channel-socket.o \
         tests/io-channel-helpers.o $(test-io-obj-y)
-tests/tpm-crb-test$(EXESUF): tests/tpm-crb-test.o $(test-io-obj-y)
+tests/tpm-crb-test$(EXESUF): tests/tpm-crb-test.o tests/tpm-emu.o $(test-io-obj-y)
 tests/test-io-channel-file$(EXESUF): tests/test-io-channel-file.o \
         tests/io-channel-helpers.o $(test-io-obj-y)
 tests/test-io-channel-tls$(EXESUF): tests/test-io-channel-tls.o \
tests/tpm-crb-test.c +3 -171

188 lines not on this page · raw message

tests/tpm-emu.c new file +167 -0

167 lines not on this page · raw message

tests/tpm-emu.h new file +38 -0
new file mode 100644
index 0000000..ef4bfa8
@@ -0,0 +1,38 @@
+/*
+ * Minimal TPM emulator for TPM test cases
+ *
+ * Copyright (c) 2018 Red Hat, Inc.
+ *
+ * Authors:
+ *   Marc-André Lureau <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef TESTS_TPM_EMU_H
+#define TESTS_TPM_EMU_H
+
+#define TPM_RC_FAILURE 0x101
+#define TPM2_ST_NO_SESSIONS 0x8001
+
+struct tpm_hdr {
+    uint16_t tag;
+    uint32_t len;
+    uint32_t code; /*ordinal/error */
+    char buffer[];
+} QEMU_PACKED;
+
+typedef struct TestState {
+    CompatGMutex data_mutex;
+    CompatGCond data_cond;
+    SocketAddress *addr;
+    QIOChannel *tpm_ioc;
+    GThread *emu_tpm_thread;
+    struct tpm_hdr *tpm_msg;
+} TestState;
+
+void tpm_emu_test_wait_cond(TestState *s);
+void *tpm_emu_ctrl_thread(void *data);
+
+#endif /* TEST_TPM_EMU_H */
Signature · 1 line
2.5.5
#2 lore raw

[Qemu-devel] [PULL v2 2/2] tests: add test for TPM TIS device

In reply to Stefan Berger

Move the TPM TIS related register and flag #defines into include/hw/acpi/tpm.h for access by the test case.

Write a test case that covers the TIS functionality.

Add the tests cases to the MAINTAINERS file.

---
 MAINTAINERS            |   1 +
 hw/tpm/tpm_tis.c       | 101 ----------
 include/hw/acpi/tpm.h  | 105 +++++++++++
 tests/Makefile.include |   2 +
 tests/tpm-emu.c        |   7 +
 tests/tpm-tis-test.c   | 486 +++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 601 insertions(+), 101 deletions(-)
 create mode 100644 tests/tpm-tis-test.c
MAINTAINERS +1 -0
index 6e7adad..8c1ae1d 100644
@@ -1633,6 +1633,7 @@ F: include/hw/acpi/tpm.h
 F: include/sysemu/tpm*
 F: qapi/tpm.json
 F: backends/tpm.c
+F: tests/*tpm*
 T: git git://github.com/stefanberger/qemu-tpm.git tpm-next
 
 Checkpatch
hw/tpm/tpm_tis.c +0 -101

107 lines not on this page · raw message

include/hw/acpi/tpm.h +105 -0

111 lines not on this page · raw message

tests/Makefile.include +2 -0
index ff44264..b89f20b 100644
@@ -287,6 +287,7 @@ ifeq ($(CONFIG_VHOST_USER_NET_TEST_i386),)
 check-qtest-x86_64-$(CONFIG_VHOST_USER_NET_TEST_x86_64) += tests/vhost-user-test$(EXESUF)
 endif
 check-qtest-i386-$(CONFIG_TPM) += tests/tpm-crb-test$(EXESUF)
+check-qtest-i386-$(CONFIG_TPM) += tests/tpm-tis-test$(EXESUF)
 check-qtest-i386-$(CONFIG_SLIRP) += tests/test-netfilter$(EXESUF)
 check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-mirror$(EXESUF)
 check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
@@ -715,6 +716,7 @@ tests/test-io-task$(EXESUF): tests/test-io-task.o $(test-io-obj-y)
 tests/test-io-channel-socket$(EXESUF): tests/test-io-channel-socket.o \
         tests/io-channel-helpers.o $(test-io-obj-y)
 tests/tpm-crb-test$(EXESUF): tests/tpm-crb-test.o tests/tpm-emu.o $(test-io-obj-y)
+tests/tpm-tis-test$(EXESUF): tests/tpm-tis-test.o tests/tpm-emu.o $(test-io-obj-y)
 tests/test-io-channel-file$(EXESUF): tests/test-io-channel-file.o \
         tests/io-channel-helpers.o $(test-io-obj-y)
 tests/test-io-channel-tls$(EXESUF): tests/test-io-channel-tls.o \
tests/tpm-emu.c +7 -0
index cbb92af..4dada76 100644
@@ -155,6 +155,13 @@ void *tpm_emu_ctrl_thread(void *data)
             qio_channel_write(ioc, (char *)&loc, sizeof(loc), &error_abort);
             break;
         }
+        case CMD_GET_TPMESTABLISHED: {
+            ptm_est est = {
+                .u.resp.bit = 0,
+            };
+            qio_channel_write(ioc, (char *)&est, sizeof(est), &error_abort);
+            break;
+        }
         default:
             g_debug("unimplemented %u", cmd);
             g_assert_not_reached();
tests/tpm-tis-test.c new file +486 -0

486 lines not on this page · raw message

Signature · 1 line
2.5.5
#3 lore raw
In reply to Stefan Berger
Quoted 14 lines · Stefan Berger

This patch series adds a test case for the TPM TIS interface.

Stefan

Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180220-pull-request' into staging (2018-02-20 14:05:00 +0000)

are available in the git repository at:

git://github.com/stefanberger/qemu-tpm.git tags/pull-tpm-2018-02-21-2

for you to fetch changes up to adb0e917e6ee93631e40265ca145bc31cd3b6c9a:

tests: add test for TPM TIS device (2018-02-21 07:24:50 -0500)

Quoted 7 lines

----------------------------------------------------------------
Merge tpm 2018/02/21 v2

----------------------------------------------------------------
Stefan Berger (2):
tests: Move common TPM test code into tpm-emu.c
tests: add test for TPM TIS device

Applied, thanks.

-- PMM