From ed836d9d6bf0c89bf2e43e300fd2254237a39ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:47 +0200 Subject: tpm: remove tpm_register_driver() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No more users of be_drivers[], drop that too. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hw/tpm/tpm_passthrough.c') diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index e6ace28..f04eab3 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -418,7 +418,6 @@ static const TypeInfo tpm_passthrough_info = { static void tpm_passthrough_register(void) { type_register_static(&tpm_passthrough_info); - tpm_register_driver(&tpm_passthrough_driver); } type_init(tpm_passthrough_register) -- cgit v1.1 From d31076ba75d4239928282143efd30d08730c8845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:49 +0200 Subject: tpm: remove TPMDriverOps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use TPMBackendClass to hold class methods/fields. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'hw/tpm/tpm_passthrough.c') diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index f04eab3..d9da99b 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -365,19 +365,6 @@ static const QemuOptDesc tpm_passthrough_cmdline_opts[] = { { /* end of list */ }, }; -static const TPMDriverOps tpm_passthrough_driver = { - .type = TPM_TYPE_PASSTHROUGH, - .opts = tpm_passthrough_cmdline_opts, - .desc = "Passthrough TPM backend driver", - .create = tpm_passthrough_create, - .reset = tpm_passthrough_reset, - .cancel_cmd = tpm_passthrough_cancel_cmd, - .get_tpm_established_flag = tpm_passthrough_get_tpm_established_flag, - .reset_tpm_established_flag = tpm_passthrough_reset_tpm_established_flag, - .get_tpm_version = tpm_passthrough_get_tpm_version, - .get_tpm_options = tpm_passthrough_get_tpm_options, -}; - static void tpm_passthrough_inst_init(Object *obj) { TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(obj); @@ -402,7 +389,17 @@ static void tpm_passthrough_class_init(ObjectClass *klass, void *data) { TPMBackendClass *tbc = TPM_BACKEND_CLASS(klass); - tbc->ops = &tpm_passthrough_driver; + tbc->type = TPM_TYPE_PASSTHROUGH; + tbc->opts = tpm_passthrough_cmdline_opts; + tbc->desc = "Passthrough TPM backend driver"; + tbc->create = tpm_passthrough_create; + tbc->reset = tpm_passthrough_reset; + tbc->cancel_cmd = tpm_passthrough_cancel_cmd; + tbc->get_tpm_established_flag = tpm_passthrough_get_tpm_established_flag; + tbc->reset_tpm_established_flag = + tpm_passthrough_reset_tpm_established_flag; + tbc->get_tpm_version = tpm_passthrough_get_tpm_version; + tbc->get_tpm_options = tpm_passthrough_get_tpm_options; tbc->handle_request = tpm_passthrough_handle_request; } -- cgit v1.1 From 905e78ba25c613a9daa7adb4e8fb3aec0fa4a2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:52 +0200 Subject: tpm: remove unused TPMBackendCmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is only handling of request so far in both backends. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'hw/tpm/tpm_passthrough.c') diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index d9da99b..5cd988e 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -149,29 +149,20 @@ static int tpm_passthrough_unix_transfer(TPMPassthruState *tpm_pt, selftest_done); } -static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd cmd) +static void tpm_passthrough_handle_request(TPMBackend *tb) { TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); bool selftest_done = false; - DPRINTF("tpm_passthrough: processing command type %d\n", cmd); - - switch (cmd) { - case TPM_BACKEND_CMD_PROCESS_CMD: - tpm_passthrough_unix_transfer(tpm_pt, - tb->tpm_state->locty_data, - &selftest_done); - - tb->recv_data_callback(tb->tpm_state, - tb->tpm_state->locty_number, - selftest_done); - break; - case TPM_BACKEND_CMD_INIT: - case TPM_BACKEND_CMD_END: - case TPM_BACKEND_CMD_TPM_RESET: - /* nothing to do */ - break; - } + DPRINTF("tpm_passthrough: processing command\n"); + + tpm_passthrough_unix_transfer(tpm_pt, + tb->tpm_state->locty_data, + &selftest_done); + + tb->recv_data_callback(tb->tpm_state, + tb->tpm_state->locty_number, + selftest_done); } static void tpm_passthrough_reset(TPMBackend *tb) -- cgit v1.1 From 54aa36d5c8ac70db25923c7a8aa11c8f7aadd225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:53 +0200 Subject: tpm: remove needless cast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'hw/tpm/tpm_passthrough.c') diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 5cd988e..fed3d69 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -96,7 +96,7 @@ static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt, is_selftest = tpm_util_is_selftest(in, in_len); - ret = qemu_write_full(tpm_pt->tpm_fd, (const void *)in, (size_t)in_len); + ret = qemu_write_full(tpm_pt->tpm_fd, in, in_len); if (ret != in_len) { if (!tpm_pt->tpm_op_canceled || errno != ECANCELED) { error_report("tpm_passthrough: error while transmitting data " -- cgit v1.1 From d1fd6b563d44a1132f8a5758f8f7bafba548502c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:54 +0200 Subject: tpm: remove locty argument from receive_cb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tpm_state is passed as argument, the assert() is pointless since we give it the value of tpm_state->locty_number already. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'hw/tpm/tpm_passthrough.c') diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index fed3d69..0ae4596 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -160,9 +160,7 @@ static void tpm_passthrough_handle_request(TPMBackend *tb) tb->tpm_state->locty_data, &selftest_done); - tb->recv_data_callback(tb->tpm_state, - tb->tpm_state->locty_number, - selftest_done); + tb->recv_data_callback(tb->tpm_state, selftest_done); } static void tpm_passthrough_reset(TPMBackend *tb) -- cgit v1.1 From 0e43b7e61ce677e154584523943c1651779baccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:55 +0200 Subject: tpm: add TPMBackendCmd to hold the request state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This simplifies a bit locality handling, and argument passing, and could pave the way to queuing requests (if that makes sense). Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'hw/tpm/tpm_passthrough.c') diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 0ae4596..93d72b8 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -137,30 +137,16 @@ err_exit: return ret; } -static int tpm_passthrough_unix_transfer(TPMPassthruState *tpm_pt, - const TPMLocality *locty_data, - bool *selftest_done) -{ - return tpm_passthrough_unix_tx_bufs(tpm_pt, - locty_data->w_buffer.buffer, - locty_data->w_offset, - locty_data->r_buffer.buffer, - locty_data->r_buffer.size, - selftest_done); -} - -static void tpm_passthrough_handle_request(TPMBackend *tb) +static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd *cmd) { TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); - bool selftest_done = false; - DPRINTF("tpm_passthrough: processing command\n"); + DPRINTF("tpm_passthrough: processing command %p\n", cmd); - tpm_passthrough_unix_transfer(tpm_pt, - tb->tpm_state->locty_data, - &selftest_done); + tpm_passthrough_unix_tx_bufs(tpm_pt, cmd->in, cmd->in_len, + cmd->out, cmd->out_len, &cmd->selftest_done); - tb->recv_data_callback(tb->tpm_state, selftest_done); + tb->recv_data_callback(tb->tpm_state); } static void tpm_passthrough_reset(TPMBackend *tb) -- cgit v1.1 From 732cd5877ef07595d1d42745ef81135a27cdf3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:55:59 +0200 Subject: tpm-tis: remove tpm_tis.h header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The definitions are now private to TIS implementation. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 1 - 1 file changed, 1 deletion(-) (limited to 'hw/tpm/tpm_passthrough.c') diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 93d72b8..4274164 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -31,7 +31,6 @@ #include "hw/hw.h" #include "hw/i386/pc.h" #include "qapi/clone-visitor.h" -#include "tpm_tis.h" #include "tpm_util.h" #define DEBUG_TPM 0 -- cgit v1.1 From 05a699985c001927a50f8f276251f2af1e0c5b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 10 Oct 2017 00:56:02 +0200 Subject: tpm: move recv_data_callback to TPM interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplify the TPM backend setup, move callback to TPM interface. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- hw/tpm/tpm_passthrough.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'hw/tpm/tpm_passthrough.c') diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 4274164..c440aff 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -139,13 +139,14 @@ err_exit: static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd *cmd) { TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); + TPMIfClass *tic = TPM_IF_GET_CLASS(tb->tpm_state); DPRINTF("tpm_passthrough: processing command %p\n", cmd); tpm_passthrough_unix_tx_bufs(tpm_pt, cmd->in, cmd->in_len, cmd->out, cmd->out_len, &cmd->selftest_done); - tb->recv_data_callback(tb->tpm_state); + tic->request_completed(TPM_IF(tb->tpm_state)); } static void tpm_passthrough_reset(TPMBackend *tb) -- cgit v1.1