[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 3/4] Introduce condition in TPM backend for notif
From: |
Stefan Berger |
Subject: |
[Qemu-devel] [PATCH v4 3/4] Introduce condition in TPM backend for notification |
Date: |
Mon, 8 Jun 2015 07:17:36 -0400 |
TPM backends will suspend independently of the frontends. Also
here we need to be able to wait for the TPM command to have been
completely processed.
Signed-off-by: Stefan Berger <address@hidden>
---
hw/tpm/tpm_passthrough.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index 68cb5e7..89c77c8 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -76,6 +76,10 @@ struct TPMPassthruState {
TPMVersion tpm_version;
ptm_cap cuse_cap; /* capabilities of the CUSE TPM */
uint8_t cur_locty_number; /* last set locality */
+
+ QemuMutex state_lock;
+ QemuCond cmd_complete; /* singnaled once tpm_busy is false */
+ bool tpm_busy;
};
typedef struct TPMPassthruState TPMPassthruState;
@@ -250,6 +254,11 @@ static void tpm_passthrough_worker_thread(gpointer data,
thr_parms->recv_data_callback(thr_parms->tpm_state,
thr_parms->tpm_state->locty_number,
selftest_done);
+ /* result delivered */
+ qemu_mutex_lock(&tpm_pt->state_lock);
+ tpm_pt->tpm_busy = false;
+ qemu_cond_signal(&tpm_pt->cmd_complete);
+ qemu_mutex_unlock(&tpm_pt->state_lock);
break;
case TPM_BACKEND_CMD_INIT:
case TPM_BACKEND_CMD_END:
@@ -377,6 +386,7 @@ static void tpm_passthrough_reset(TPMBackend *tb)
tpm_backend_thread_end(&tpm_pt->tbt);
tpm_pt->had_startup_error = false;
+ tpm_pt->tpm_busy = false;
}
static int tpm_passthrough_init(TPMBackend *tb, TPMState *s,
@@ -454,6 +464,11 @@ static void tpm_passthrough_deliver_request(TPMBackend *tb)
{
TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
+ /* TPM considered busy once TPM Request scheduled for processing */
+ qemu_mutex_lock(&tpm_pt->state_lock);
+ tpm_pt->tpm_busy = true;
+ qemu_mutex_unlock(&tpm_pt->state_lock);
+
tpm_backend_thread_deliver_request(&tpm_pt->tbt);
}
@@ -722,6 +737,11 @@ static const TPMDriverOps tpm_passthrough_driver = {
static void tpm_passthrough_inst_init(Object *obj)
{
+ TPMBackend *tb = TPM_BACKEND(obj);
+ TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
+
+ qemu_mutex_init(&tpm_pt->state_lock);
+ qemu_cond_init(&tpm_pt->cmd_complete);
}
static void tpm_passthrough_inst_finalize(Object *obj)
--
1.9.3
- [Qemu-devel] [PATCH v4 0/4] Extend TPM support with a QEMU-external TPM, Stefan Berger, 2015/06/08
- [Qemu-devel] [PATCH v4 2/4] Introduce condition to notify waiters of completed command, Stefan Berger, 2015/06/08
- [Qemu-devel] [PATCH v4 3/4] Introduce condition in TPM backend for notification,
Stefan Berger <=
- [Qemu-devel] [PATCH v4 4/4] Add support for VM suspend/resume for TPM TIS, Stefan Berger, 2015/06/08
- [Qemu-devel] [PATCH v4 1/4] Provide support for the CUSE TPM, Stefan Berger, 2015/06/08
- Re: [Qemu-devel] [PATCH v4 0/4] Extend TPM support with a QEMU-external TPM, Michael S. Tsirkin, 2015/06/23
- Re: [Qemu-devel] [PATCH v4 0/4] Extend TPM support with a QEMU-external TPM, Michael S. Tsirkin, 2015/06/23