summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/qemu/qemu/0006-tpm-backend-Made-few-interface-methods-optional.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/qemu/qemu/0006-tpm-backend-Made-few-interface-methods-optional.patch')
-rw-r--r--meta/recipes-devtools/qemu/qemu/0006-tpm-backend-Made-few-interface-methods-optional.patch284
1 files changed, 0 insertions, 284 deletions
diff --git a/meta/recipes-devtools/qemu/qemu/0006-tpm-backend-Made-few-interface-methods-optional.patch b/meta/recipes-devtools/qemu/qemu/0006-tpm-backend-Made-few-interface-methods-optional.patch
deleted file mode 100644
index eb456f01c7..0000000000
--- a/meta/recipes-devtools/qemu/qemu/0006-tpm-backend-Made-few-interface-methods-optional.patch
+++ /dev/null
@@ -1,284 +0,0 @@
1From 47e6ef6586401e82e652f3c013a349bba3a0479b Mon Sep 17 00:00:00 2001
2From: Amarnath Valluri <amarnath.valluri@intel.com>
3Date: Thu, 30 Mar 2017 18:04:16 +0300
4Subject: [PATCH 06/12] tpm-backend: Made few interface methods optional
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9This allows backend implementations left optional interface methods.
10For mandatory methods assertion checks added.
11
12Took the opportunity to remove unused methods:
13 - tpm_backend_get_desc()
14 - TPMDriverOps->handle_startup_error
15
16Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
17Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
18Reviewed-by: Stefan Berger<stefanb@linux.vnet.ibm.com>
19
20Upstream-Status: Backport [93330cf542b920b6ea5fea8120a08b76bb353113]
21---
22 backends/tpm.c | 39 ++++++++++++++++++++++++---------------
23 hw/tpm/tpm_passthrough.c | 36 +-----------------------------------
24 include/sysemu/tpm_backend.h | 13 ++-----------
25 tpm.c | 2 +-
26 4 files changed, 28 insertions(+), 62 deletions(-)
27
28diff --git a/backends/tpm.c b/backends/tpm.c
29index cf5abf1582..8911597fab 100644
30--- a/backends/tpm.c
31+++ b/backends/tpm.c
32@@ -44,13 +44,6 @@ enum TpmType tpm_backend_get_type(TPMBackend *s)
33 return k->ops->type;
34 }
35
36-const char *tpm_backend_get_desc(TPMBackend *s)
37-{
38- TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
39-
40- return k->ops->desc();
41-}
42-
43 int tpm_backend_init(TPMBackend *s, TPMState *state,
44 TPMRecvDataCB *datacb)
45 {
46@@ -58,12 +51,14 @@ int tpm_backend_init(TPMBackend *s, TPMState *state,
47
48 s->tpm_state = state;
49 s->recv_data_callback = datacb;
50+ s->had_startup_error = false;
51
52- return k->ops->init(s);
53+ return k->ops->init ? k->ops->init(s) : 0;
54 }
55
56 int tpm_backend_startup_tpm(TPMBackend *s)
57 {
58+ int res = 0;
59 TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
60
61 /* terminate a running TPM */
62@@ -73,20 +68,24 @@ int tpm_backend_startup_tpm(TPMBackend *s)
63 NULL);
64 g_thread_pool_push(s->thread_pool, (gpointer)TPM_BACKEND_CMD_INIT, NULL);
65
66- return k->ops->startup_tpm(s);
67+ res = k->ops->startup_tpm ? k->ops->startup_tpm(s) : 0;
68+
69+ s->had_startup_error = (res != 0);
70+
71+ return res;
72 }
73
74 bool tpm_backend_had_startup_error(TPMBackend *s)
75 {
76- TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
77-
78- return k->ops->had_startup_error(s);
79+ return s->had_startup_error;
80 }
81
82 size_t tpm_backend_realloc_buffer(TPMBackend *s, TPMSizedBuffer *sb)
83 {
84 TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
85
86+ assert(k->ops->realloc_buffer);
87+
88 return k->ops->realloc_buffer(sb);
89 }
90
91@@ -100,15 +99,21 @@ void tpm_backend_reset(TPMBackend *s)
92 {
93 TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
94
95- k->ops->reset(s);
96+ if (k->ops->reset) {
97+ k->ops->reset(s);
98+ }
99
100 tpm_backend_thread_end(s);
101+
102+ s->had_startup_error = false;
103 }
104
105 void tpm_backend_cancel_cmd(TPMBackend *s)
106 {
107 TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
108
109+ assert(k->ops->cancel_cmd);
110+
111 k->ops->cancel_cmd(s);
112 }
113
114@@ -116,20 +121,24 @@ bool tpm_backend_get_tpm_established_flag(TPMBackend *s)
115 {
116 TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
117
118- return k->ops->get_tpm_established_flag(s);
119+ return k->ops->get_tpm_established_flag ?
120+ k->ops->get_tpm_established_flag(s) : false;
121 }
122
123 int tpm_backend_reset_tpm_established_flag(TPMBackend *s, uint8_t locty)
124 {
125 TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
126
127- return k->ops->reset_tpm_established_flag(s, locty);
128+ return k->ops->reset_tpm_established_flag ?
129+ k->ops->reset_tpm_established_flag(s, locty) : 0;
130 }
131
132 TPMVersion tpm_backend_get_tpm_version(TPMBackend *s)
133 {
134 TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
135
136+ assert(k->ops->get_tpm_version);
137+
138 return k->ops->get_tpm_version(s);
139 }
140
141diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
142index 815a72ef9a..4c21e52b7c 100644
143--- a/hw/tpm/tpm_passthrough.c
144+++ b/hw/tpm/tpm_passthrough.c
145@@ -54,7 +54,6 @@ struct TPMPassthruState {
146 bool tpm_executing;
147 bool tpm_op_canceled;
148 int cancel_fd;
149- bool had_startup_error;
150
151 TPMVersion tpm_version;
152 };
153@@ -227,29 +226,11 @@ static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd cmd)
154 }
155 }
156
157-/*
158- * Start the TPM (thread). If it had been started before, then terminate
159- * and start it again.
160- */
161-static int tpm_passthrough_startup_tpm(TPMBackend *tb)
162-{
163- return 0;
164-}
165-
166 static void tpm_passthrough_reset(TPMBackend *tb)
167 {
168- TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
169-
170 DPRINTF("tpm_passthrough: CALL TO TPM_RESET!\n");
171
172 tpm_passthrough_cancel_cmd(tb);
173-
174- tpm_pt->had_startup_error = false;
175-}
176-
177-static int tpm_passthrough_init(TPMBackend *tb)
178-{
179- return 0;
180 }
181
182 static bool tpm_passthrough_get_tpm_established_flag(TPMBackend *tb)
183@@ -264,13 +245,6 @@ static int tpm_passthrough_reset_tpm_established_flag(TPMBackend *tb,
184 return 0;
185 }
186
187-static bool tpm_passthrough_get_startup_error(TPMBackend *tb)
188-{
189- TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
190-
191- return tpm_pt->had_startup_error;
192-}
193-
194 static size_t tpm_passthrough_realloc_buffer(TPMSizedBuffer *sb)
195 {
196 size_t wanted_size = 4096; /* Linux tpm.c buffer size */
197@@ -309,11 +283,6 @@ static void tpm_passthrough_cancel_cmd(TPMBackend *tb)
198 }
199 }
200
201-static const char *tpm_passthrough_create_desc(void)
202-{
203- return "Passthrough TPM backend driver";
204-}
205-
206 static TPMVersion tpm_passthrough_get_tpm_version(TPMBackend *tb)
207 {
208 TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
209@@ -453,13 +422,10 @@ static const QemuOptDesc tpm_passthrough_cmdline_opts[] = {
210 static const TPMDriverOps tpm_passthrough_driver = {
211 .type = TPM_TYPE_PASSTHROUGH,
212 .opts = tpm_passthrough_cmdline_opts,
213- .desc = tpm_passthrough_create_desc,
214+ .desc = "Passthrough TPM backend driver",
215 .create = tpm_passthrough_create,
216- .init = tpm_passthrough_init,
217- .startup_tpm = tpm_passthrough_startup_tpm,
218 .realloc_buffer = tpm_passthrough_realloc_buffer,
219 .reset = tpm_passthrough_reset,
220- .had_startup_error = tpm_passthrough_get_startup_error,
221 .cancel_cmd = tpm_passthrough_cancel_cmd,
222 .get_tpm_established_flag = tpm_passthrough_get_tpm_established_flag,
223 .reset_tpm_established_flag = tpm_passthrough_reset_tpm_established_flag,
224diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h
225index 202ec8d5a2..9ea707253a 100644
226--- a/include/sysemu/tpm_backend.h
227+++ b/include/sysemu/tpm_backend.h
228@@ -47,6 +47,7 @@ struct TPMBackend {
229 TPMState *tpm_state;
230 GThreadPool *thread_pool;
231 TPMRecvDataCB *recv_data_callback;
232+ bool had_startup_error;
233
234 char *id;
235 enum TpmModel fe_model;
236@@ -75,7 +76,7 @@ struct TPMDriverOps {
237 enum TpmType type;
238 const QemuOptDesc *opts;
239 /* get a descriptive text of the backend to display to the user */
240- const char *(*desc)(void);
241+ const char *desc;
242
243 TPMBackend *(*create)(QemuOpts *opts, const char *id);
244
245@@ -83,8 +84,6 @@ struct TPMDriverOps {
246 int (*init)(TPMBackend *t);
247 /* start up the TPM on the backend */
248 int (*startup_tpm)(TPMBackend *t);
249- /* returns true if nothing will ever answer TPM requests */
250- bool (*had_startup_error)(TPMBackend *t);
251
252 size_t (*realloc_buffer)(TPMSizedBuffer *sb);
253
254@@ -109,14 +108,6 @@ struct TPMDriverOps {
255 enum TpmType tpm_backend_get_type(TPMBackend *s);
256
257 /**
258- * tpm_backend_get_desc:
259- * @s: the backend
260- *
261- * Returns a human readable description of the backend.
262- */
263-const char *tpm_backend_get_desc(TPMBackend *s);
264-
265-/**
266 * tpm_backend_init:
267 * @s: the backend to initialized
268 * @state: TPMState
269diff --git a/tpm.c b/tpm.c
270index 7feb3b43c9..9f4f37da50 100644
271--- a/tpm.c
272+++ b/tpm.c
273@@ -63,7 +63,7 @@ static void tpm_display_backend_drivers(void)
274 continue;
275 }
276 fprintf(stderr, "%12s %s\n",
277- TpmType_lookup[i], be_drivers[i]->desc());
278+ TpmType_lookup[i], be_drivers[i]->desc);
279 }
280 fprintf(stderr, "\n");
281 }
282--
2832.11.0
284