[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/7] tpm: Introduce condition to notify waiters o
From: |
Stefan Berger |
Subject: |
[Qemu-devel] [PATCH v2 1/7] tpm: Introduce condition to notify waiters of completed command |
Date: |
Fri, 27 Oct 2017 19:02:35 -0400 |
Introduce a lock and a condition to notify anyone waiting for the completion
of the execution of a TPM command by the backend (thread). The backend
uses the condition to signal anyone waiting for command completion.
We need to place the condition in two locations: one is invoked by the
backend thread, the other by the bottom half thread.
We will use the signaling to wait for command completion before VM
suspend.
Signed-off-by: Stefan Berger <address@hidden>
---
hw/tpm/tpm_tis.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 9a94051..90dca4e 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -90,6 +90,9 @@ typedef struct TPMState {
char *backend;
TPMBackend *be_driver;
TPMVersion be_tpm_version;
+
+ QemuMutex state_lock;
+ QemuCond cmd_complete;
} TPMState;
#define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS)
@@ -421,6 +424,8 @@ static void tpm_tis_request_completed(TPMIf *ti)
}
}
+ qemu_mutex_lock(&s->state_lock);
+
tpm_tis_sts_set(&s->loc[locty],
TPM_TIS_STS_VALID | TPM_TIS_STS_DATA_AVAILABLE);
s->loc[locty].state = TPM_TIS_STATE_COMPLETION;
@@ -435,6 +440,10 @@ static void tpm_tis_request_completed(TPMIf *ti)
tpm_tis_raise_irq(s, locty,
TPM_TIS_INT_DATA_AVAILABLE | TPM_TIS_INT_STS_VALID);
+
+ /* notify of completed command */
+ qemu_cond_signal(&s->cmd_complete);
+ qemu_mutex_unlock(&s->state_lock);
}
/*
@@ -1088,6 +1097,9 @@ static void tpm_tis_initfn(Object *obj)
memory_region_init_io(&s->mmio, OBJECT(s), &tpm_tis_memory_ops,
s, "tpm-tis-mmio",
TPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT);
+
+ qemu_mutex_init(&s->state_lock);
+ qemu_cond_init(&s->cmd_complete);
}
static void tpm_tis_class_init(ObjectClass *klass, void *data)
--
2.5.5
- [Qemu-devel] [PATCH v2 0/7] tpm: Extend TPM with state migration support, Stefan Berger, 2017/10/27
- [Qemu-devel] [PATCH v2 1/7] tpm: Introduce condition to notify waiters of completed command,
Stefan Berger <=
- [Qemu-devel] [PATCH v2 4/7] tpm: Implement tpm_sized_buffer_reset, Stefan Berger, 2017/10/27
- [Qemu-devel] [PATCH v2 2/7] tpm: Introduce condition in TPM backend for notification, Stefan Berger, 2017/10/27
- [Qemu-devel] [PATCH v2 7/7] tpm: extend TPM CRB with state migration support, Stefan Berger, 2017/10/27
- [Qemu-devel] [PATCH v2 3/7] tpm: implement tpm_backend_wait_cmd_completed, Stefan Berger, 2017/10/27
- [Qemu-devel] [PATCH v2 5/7] tpm: extend TPM emulator with state migration support, Stefan Berger, 2017/10/27
- [Qemu-devel] [PATCH v2 6/7] tpm: extend TPM TIS with state migration support, Stefan Berger, 2017/10/27