aboutsummaryrefslogtreecommitdiff
path: root/hw/tpm
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-10-10 00:56:02 +0200
committerStefan Berger <stefanb@linux.vnet.ibm.com>2017-10-19 11:42:33 -0400
commit05a699985c001927a50f8f276251f2af1e0c5b58 (patch)
tree6ceaf9311f014cf2be96a4194d98f593bc399184 /hw/tpm
parent698f5daa4a81984490612a6143b46f5da7392510 (diff)
downloadqemu-05a699985c001927a50f8f276251f2af1e0c5b58.zip
qemu-05a699985c001927a50f8f276251f2af1e0c5b58.tar.gz
qemu-05a699985c001927a50f8f276251f2af1e0c5b58.tar.bz2
tpm: move recv_data_callback to TPM interface
Simplify the TPM backend setup, move callback to TPM interface. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Diffstat (limited to 'hw/tpm')
-rw-r--r--hw/tpm/tpm_emulator.c3
-rw-r--r--hw/tpm/tpm_int.h3
-rw-r--r--hw/tpm/tpm_passthrough.c3
-rw-r--r--hw/tpm/tpm_tis.c11
4 files changed, 13 insertions, 7 deletions
diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
index 6500b86..9aaec8e 100644
--- a/hw/tpm/tpm_emulator.c
+++ b/hw/tpm/tpm_emulator.c
@@ -176,6 +176,7 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_emu, uint8_t locty_number,
static void tpm_emulator_handle_request(TPMBackend *tb, TPMBackendCmd *cmd)
{
TPMEmulator *tpm_emu = TPM_EMULATOR(tb);
+ TPMIfClass *tic = TPM_IF_GET_CLASS(tb->tpm_state);
Error *err = NULL;
DPRINTF("processing TPM command");
@@ -190,7 +191,7 @@ static void tpm_emulator_handle_request(TPMBackend *tb, TPMBackendCmd *cmd)
goto error;
}
- tb->recv_data_callback(tb->tpm_state);
+ tic->request_completed(TPM_IF(tb->tpm_state));
return;
error:
diff --git a/hw/tpm/tpm_int.h b/hw/tpm/tpm_int.h
index eb02e77..9c045b6 100644
--- a/hw/tpm/tpm_int.h
+++ b/hw/tpm/tpm_int.h
@@ -29,6 +29,9 @@ typedef struct TPMIf {
typedef struct TPMIfClass {
InterfaceClass parent_class;
+
+ /* run in thread pool by backend */
+ void (*request_completed)(TPMIf *obj);
} TPMIfClass;
#define TPM_STANDARD_CMDLINE_OPTS \
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)
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index dbb5004..8c5cac5 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -430,11 +430,10 @@ static void tpm_tis_receive_bh(void *opaque)
TPM_TIS_INT_DATA_AVAILABLE | TPM_TIS_INT_STS_VALID);
}
-/*
- * Callback from the TPM to indicate that the response was received.
- */
-static void tpm_tis_receive_cb(TPMState *s)
+static void tpm_tis_request_completed(TPMIf *ti)
{
+ TPMState *s = TPM(ti);
+
bool is_selftest_done = s->cmd.selftest_done;
uint8_t locty = s->cmd.locty;
uint8_t l;
@@ -1078,7 +1077,7 @@ static void tpm_tis_realizefn(DeviceState *dev, Error **errp)
s->be_driver->fe_model = TPM_MODEL_TPM_TIS;
- if (tpm_backend_init(s->be_driver, s, tpm_tis_receive_cb)) {
+ if (tpm_backend_init(s->be_driver, s)) {
error_setg(errp, "tpm_tis: backend driver with id %s could not be "
"initialized", s->backend);
return;
@@ -1110,11 +1109,13 @@ static void tpm_tis_initfn(Object *obj)
static void tpm_tis_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+ TPMIfClass *tc = TPM_IF_CLASS(klass);
dc->realize = tpm_tis_realizefn;
dc->props = tpm_tis_properties;
dc->reset = tpm_tis_reset;
dc->vmsd = &vmstate_tpm_tis;
+ tc->request_completed = tpm_tis_request_completed;
}
static const TypeInfo tpm_tis_info = {