diff options
Diffstat (limited to 'meta/recipes-devtools/qemu/qemu/0003-Introduce-condition-in-TPM-backend-for-notification.patch')
-rw-r--r-- | meta/recipes-devtools/qemu/qemu/0003-Introduce-condition-in-TPM-backend-for-notification.patch | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/meta/recipes-devtools/qemu/qemu/0003-Introduce-condition-in-TPM-backend-for-notification.patch b/meta/recipes-devtools/qemu/qemu/0003-Introduce-condition-in-TPM-backend-for-notification.patch new file mode 100644 index 0000000000..e58f019062 --- /dev/null +++ b/meta/recipes-devtools/qemu/qemu/0003-Introduce-condition-in-TPM-backend-for-notification.patch | |||
@@ -0,0 +1,79 @@ | |||
1 | From 732a8e046948fd62b32cd1dd76a6798eb1caf4d6 Mon Sep 17 00:00:00 2001 | ||
2 | From: Stefan Berger <stefanb@linux.vnet.ibm.com> | ||
3 | Date: Sat, 31 Dec 2016 11:23:32 -0500 | ||
4 | Subject: [PATCH 3/4] Introduce condition in TPM backend for notification | ||
5 | |||
6 | TPM backends will suspend independently of the frontends. Also | ||
7 | here we need to be able to wait for the TPM command to have been | ||
8 | completely processed. | ||
9 | |||
10 | Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> | ||
11 | |||
12 | Upstream-Status: Pending [https://lists.nongnu.org/archive/html/qemu-devel/2016-06/msg00252.html] | ||
13 | Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> | ||
14 | --- | ||
15 | hw/tpm/tpm_passthrough.c | 20 ++++++++++++++++++++ | ||
16 | 1 file changed, 20 insertions(+) | ||
17 | |||
18 | diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c | ||
19 | index 050f2ba850..44739ebad2 100644 | ||
20 | --- a/hw/tpm/tpm_passthrough.c | ||
21 | +++ b/hw/tpm/tpm_passthrough.c | ||
22 | @@ -75,6 +75,10 @@ struct TPMPassthruState { | ||
23 | TPMVersion tpm_version; | ||
24 | ptm_cap cuse_cap; /* capabilities of the CUSE TPM */ | ||
25 | uint8_t cur_locty_number; /* last set locality */ | ||
26 | + | ||
27 | + QemuMutex state_lock; | ||
28 | + QemuCond cmd_complete; /* singnaled once tpm_busy is false */ | ||
29 | + bool tpm_busy; | ||
30 | }; | ||
31 | |||
32 | typedef struct TPMPassthruState TPMPassthruState; | ||
33 | @@ -274,6 +278,11 @@ static void tpm_passthrough_worker_thread(gpointer data, | ||
34 | thr_parms->recv_data_callback(thr_parms->tpm_state, | ||
35 | thr_parms->tpm_state->locty_number, | ||
36 | selftest_done); | ||
37 | + /* result delivered */ | ||
38 | + qemu_mutex_lock(&tpm_pt->state_lock); | ||
39 | + tpm_pt->tpm_busy = false; | ||
40 | + qemu_cond_signal(&tpm_pt->cmd_complete); | ||
41 | + qemu_mutex_unlock(&tpm_pt->state_lock); | ||
42 | break; | ||
43 | case TPM_BACKEND_CMD_INIT: | ||
44 | case TPM_BACKEND_CMD_END: | ||
45 | @@ -401,6 +410,7 @@ static void tpm_passthrough_reset(TPMBackend *tb) | ||
46 | tpm_backend_thread_end(&tpm_pt->tbt); | ||
47 | |||
48 | tpm_pt->had_startup_error = false; | ||
49 | + tpm_pt->tpm_busy = false; | ||
50 | } | ||
51 | |||
52 | static int tpm_passthrough_init(TPMBackend *tb, TPMState *s, | ||
53 | @@ -478,6 +488,11 @@ static void tpm_passthrough_deliver_request(TPMBackend *tb) | ||
54 | { | ||
55 | TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); | ||
56 | |||
57 | + /* TPM considered busy once TPM Request scheduled for processing */ | ||
58 | + qemu_mutex_lock(&tpm_pt->state_lock); | ||
59 | + tpm_pt->tpm_busy = true; | ||
60 | + qemu_mutex_unlock(&tpm_pt->state_lock); | ||
61 | + | ||
62 | tpm_backend_thread_deliver_request(&tpm_pt->tbt); | ||
63 | } | ||
64 | |||
65 | @@ -746,6 +761,11 @@ static const TPMDriverOps tpm_passthrough_driver = { | ||
66 | |||
67 | static void tpm_passthrough_inst_init(Object *obj) | ||
68 | { | ||
69 | + TPMBackend *tb = TPM_BACKEND(obj); | ||
70 | + TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); | ||
71 | + | ||
72 | + qemu_mutex_init(&tpm_pt->state_lock); | ||
73 | + qemu_cond_init(&tpm_pt->cmd_complete); | ||
74 | } | ||
75 | |||
76 | static void tpm_passthrough_inst_finalize(Object *obj) | ||
77 | -- | ||
78 | 2.11.0 | ||
79 | |||