1 | From: James Bottomley <James.Bottomley@HansenPartnership.com> | ||
---|---|---|---|
2 | |||
3 | The requested feedback was to convert the tpmdev handler to being json | 1 | The requested feedback was to convert the tpmdev handler to being json |
4 | based, which requires rethreading all the backends. The good news is | 2 | based, which requires rethreading all the backends. The good news is |
5 | this reduced quite a bit of code (especially as I converted it to | 3 | this reduced quite a bit of code (especially as I converted it to |
6 | error_fatal handling as well, which removes the return status | 4 | error_fatal handling as well, which removes the return status |
7 | threading). The bad news is I can't test any of the conversions. | 5 | threading). |
8 | swtpm still isn't building on opensuse and, apparently, passthrough | ||
9 | doesn't like my native TPM because it doesn't allow cancellation. | ||
10 | 6 | ||
11 | v3 pulls out more unneeded code in the visitor conversion, makes | 7 | v3 pulls out more unneeded code in the visitor conversion, makes |
12 | migration work on external state preservation of the simulator and | 8 | migration work on external state preservation of the simulator and |
13 | adds documentation | 9 | adds documentation |
14 | 10 | ||
... | ... | ||
17 | 13 | ||
18 | v5 rebases to the latest master branch and adjusts for removed use_FOO ptrs | 14 | v5 rebases to the latest master branch and adjusts for removed use_FOO ptrs |
19 | 15 | ||
20 | v5 updates help to exit zero; does some checkpatch tidying | 16 | v5 updates help to exit zero; does some checkpatch tidying |
21 | 17 | ||
18 | v7 merge review feedback and add acks. | ||
19 | |||
20 | v8 adds better error handling, more code tidies and adds command | ||
21 | socket disconnection/reconnection (instead of trying to keep the | ||
22 | socket open the whole time). This adds overhead, but makes | ||
23 | debugging guest kernel TPM issues much easier. | ||
24 | |||
25 | v9 Fix merge conflict with optarg->optstr conversion | ||
26 | |||
27 | v10 Fix more merge conflicts and update API versions | ||
28 | |||
29 | v11 Fix another merge conflict and correct a warm reboot problem where | ||
30 | the TPM isn't getting reset (meaning the PCR values are wrong). | ||
31 | |||
22 | James | 32 | James |
23 | 33 | ||
24 | --- | 34 | --- |
25 | 35 | ||
26 | James Bottomley (2): | 36 | James Bottomley (2): |
27 | tpm: convert tpmdev options processing to new visitor format | 37 | tpm: convert tpmdev options processing to new visitor format |
28 | tpm: add backend for mssim | 38 | tpm: add backend for mssim |
29 | 39 | ||
30 | MAINTAINERS | 6 + | 40 | MAINTAINERS | 6 + |
31 | backends/tpm/Kconfig | 5 + | 41 | backends/tpm/Kconfig | 5 + |
32 | backends/tpm/meson.build | 1 + | 42 | backends/tpm/meson.build | 1 + |
33 | backends/tpm/tpm_emulator.c | 24 +-- | 43 | backends/tpm/tpm_emulator.c | 25 +-- |
34 | backends/tpm/tpm_mssim.c | 290 +++++++++++++++++++++++++++++++++ | 44 | backends/tpm/tpm_mssim.c | 335 +++++++++++++++++++++++++++++++++ |
35 | backends/tpm/tpm_mssim.h | 44 +++++ | 45 | backends/tpm/tpm_mssim.h | 44 +++++ |
36 | backends/tpm/tpm_passthrough.c | 22 +-- | 46 | backends/tpm/tpm_passthrough.c | 23 +-- |
37 | docs/specs/tpm.rst | 35 ++++ | 47 | docs/specs/tpm.rst | 39 ++++ |
38 | include/sysemu/tpm.h | 4 +- | 48 | include/sysemu/tpm.h | 5 +- |
39 | include/sysemu/tpm_backend.h | 2 +- | 49 | include/sysemu/tpm_backend.h | 2 +- |
40 | monitor/hmp-cmds.c | 9 + | 50 | qapi/tpm.json | 50 ++++- |
41 | qapi/tpm.json | 45 ++++- | 51 | system/tpm-hmp-cmds.c | 9 + |
42 | softmmu/tpm.c | 90 ++++------ | 52 | system/tpm.c | 91 ++++----- |
43 | softmmu/vl.c | 19 +-- | 53 | system/vl.c | 19 +- |
44 | 14 files changed, 488 insertions(+), 108 deletions(-) | 54 | 14 files changed, 546 insertions(+), 108 deletions(-) |
45 | create mode 100644 backends/tpm/tpm_mssim.c | 55 | create mode 100644 backends/tpm/tpm_mssim.c |
46 | create mode 100644 backends/tpm/tpm_mssim.h | 56 | create mode 100644 backends/tpm/tpm_mssim.h |
47 | 57 | ||
48 | -- | 58 | -- |
49 | 2.35.3 | 59 | 2.35.3 | diff view generated by jsdifflib |
1 | From: James Bottomley <James.Bottomley@HansenPartnership.com> | ||
---|---|---|---|
2 | |||
3 | Instead of processing the tpmdev options using the old qemu options, | 1 | Instead of processing the tpmdev options using the old qemu options, |
4 | convert to the new visitor format which also allows the passing of | 2 | convert to the new visitor format which also allows the passing of |
5 | json on the command line. | 3 | json on the command line. |
6 | 4 | ||
7 | Signed-off-by: James Bottomley <jejb@linux.ibm.com> | 5 | Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> |
6 | Tested-by: Stefan Berger <stefanb@linux.ibm.com> | ||
7 | Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> | ||
8 | 8 | ||
9 | --- | 9 | --- |
10 | v4: add TpmConfiOptions | 10 | v4: add TpmConfiOptions |
11 | v5: exit(0) for help | 11 | v5: exit(0) for help |
12 | v7: adjust line lengths, free options | ||
13 | v8: minor updates; add tested/reviewed-by | ||
14 | v9: optarg->optstr | ||
12 | --- | 15 | --- |
13 | backends/tpm/tpm_emulator.c | 24 ++++----- | 16 | backends/tpm/tpm_emulator.c | 25 ++++------ |
14 | backends/tpm/tpm_passthrough.c | 22 +++------ | 17 | backends/tpm/tpm_passthrough.c | 23 +++------ |
15 | include/sysemu/tpm.h | 4 +- | 18 | include/sysemu/tpm.h | 5 +- |
16 | include/sysemu/tpm_backend.h | 2 +- | 19 | include/sysemu/tpm_backend.h | 2 +- |
17 | qapi/tpm.json | 19 +++++++ | 20 | qapi/tpm.json | 21 ++++++++ |
18 | softmmu/tpm.c | 90 ++++++++++++++-------------------- | 21 | system/tpm.c | 91 ++++++++++++++-------------------- |
19 | softmmu/vl.c | 19 +------ | 22 | system/vl.c | 19 +------ |
20 | 7 files changed, 75 insertions(+), 105 deletions(-) | 23 | 7 files changed, 81 insertions(+), 105 deletions(-) |
21 | 24 | ||
22 | diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c | 25 | diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c |
23 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/backends/tpm/tpm_emulator.c | 27 | --- a/backends/tpm/tpm_emulator.c |
25 | +++ b/backends/tpm/tpm_emulator.c | 28 | +++ b/backends/tpm/tpm_emulator.c |
26 | @@ -XXX,XX +XXX,XX @@ err_exit: | 29 | @@ -XXX,XX +XXX,XX @@ err_exit: |
27 | return -1; | 30 | return -1; |
28 | } | 31 | } |
29 | 32 | ||
30 | -static int tpm_emulator_handle_device_opts(TPMEmulator *tpm_emu, QemuOpts *opts) | 33 | -static int tpm_emulator_handle_device_opts(TPMEmulator *tpm_emu, QemuOpts *opts) |
31 | +static int tpm_emulator_handle_device_opts(TPMEmulator *tpm_emu, TpmCreateOptions *opts) | 34 | +static int tpm_emulator_handle_device_opts(TPMEmulator *tpm_emu, |
35 | + TpmCreateOptions *opts) | ||
32 | { | 36 | { |
33 | - const char *value; | 37 | - const char *value; |
34 | Error *err = NULL; | 38 | Error *err = NULL; |
35 | Chardev *dev; | 39 | Chardev *dev; |
36 | 40 | ||
... | ... | ||
45 | - dev = qemu_chr_find(value); | 49 | - dev = qemu_chr_find(value); |
46 | + dev = qemu_chr_find(opts->u.emulator.chardev); | 50 | + dev = qemu_chr_find(opts->u.emulator.chardev); |
47 | if (!dev) { | 51 | if (!dev) { |
48 | - error_report("tpm-emulator: tpm chardev '%s' not found", value); | 52 | - error_report("tpm-emulator: tpm chardev '%s' not found", value); |
49 | + error_report("tpm-emulator: tpm chardev '%s' not found", | 53 | + error_report("tpm-emulator: tpm chardev '%s' not found", |
50 | + opts->u.emulator.chardev); | 54 | + opts->u.emulator.chardev); |
51 | goto err; | 55 | goto err; |
52 | } | 56 | } |
53 | 57 | ||
54 | if (!qemu_chr_fe_init(&tpm_emu->ctrl_chr, dev, &err)) { | 58 | if (!qemu_chr_fe_init(&tpm_emu->ctrl_chr, dev, &err)) { |
55 | error_prepend(&err, "tpm-emulator: No valid chardev found at '%s':", | 59 | error_prepend(&err, "tpm-emulator: No valid chardev found at '%s':", |
... | ... | ||
97 | @@ -XXX,XX +XXX,XX @@ static int tpm_passthrough_open_sysfs_cancel(TPMPassthruState *tpm_pt) | 101 | @@ -XXX,XX +XXX,XX @@ static int tpm_passthrough_open_sysfs_cancel(TPMPassthruState *tpm_pt) |
98 | } | 102 | } |
99 | 103 | ||
100 | static int | 104 | static int |
101 | -tpm_passthrough_handle_device_opts(TPMPassthruState *tpm_pt, QemuOpts *opts) | 105 | -tpm_passthrough_handle_device_opts(TPMPassthruState *tpm_pt, QemuOpts *opts) |
102 | +tpm_passthrough_handle_device_opts(TPMPassthruState *tpm_pt, TpmCreateOptions *opts) | 106 | +tpm_passthrough_handle_device_opts(TPMPassthruState *tpm_pt, |
107 | + TpmCreateOptions *opts) | ||
103 | { | 108 | { |
104 | - const char *value; | 109 | - const char *value; |
105 | + tpm_pt->options = QAPI_CLONE(TPMPassthroughOptions, &opts->u.passthrough); | 110 | + tpm_pt->options = QAPI_CLONE(TPMPassthroughOptions, &opts->u.passthrough); |
106 | 111 | ||
107 | - value = qemu_opt_get(opts, "cancel-path"); | 112 | - value = qemu_opt_get(opts, "cancel-path"); |
... | ... | ||
148 | +++ b/include/sysemu/tpm.h | 153 | +++ b/include/sysemu/tpm.h |
149 | @@ -XXX,XX +XXX,XX @@ | 154 | @@ -XXX,XX +XXX,XX @@ |
150 | 155 | ||
151 | #ifdef CONFIG_TPM | 156 | #ifdef CONFIG_TPM |
152 | 157 | ||
153 | -int tpm_config_parse(QemuOptsList *opts_list, const char *optarg); | 158 | -int tpm_config_parse(QemuOptsList *opts_list, const char *optstr); |
154 | -int tpm_init(void); | 159 | -int tpm_init(void); |
155 | +void tpm_config_parse(const char *optarg); | 160 | +void tpm_config_parse(const char *optstr); |
156 | +void tpm_init(void); | 161 | +void tpm_init(void); |
162 | + | ||
157 | void tpm_cleanup(void); | 163 | void tpm_cleanup(void); |
158 | 164 | ||
159 | typedef enum TPMVersion { | 165 | typedef enum TPMVersion { |
160 | diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h | 166 | diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h |
161 | index XXXXXXX..XXXXXXX 100644 | 167 | index XXXXXXX..XXXXXXX 100644 |
... | ... | ||
185 | +# without the wrapper to be usable by visitors. | 191 | +# without the wrapper to be usable by visitors. |
186 | +# | 192 | +# |
187 | +# @type: - 'passthrough' The configuration options for the TPM passthrough type | 193 | +# @type: - 'passthrough' The configuration options for the TPM passthrough type |
188 | +# - 'emulator' The configuration options for TPM emulator backend type | 194 | +# - 'emulator' The configuration options for TPM emulator backend type |
189 | +# | 195 | +# |
190 | +# Since: 7.2 | 196 | +# @id: The Id of the TPM |
197 | +# | ||
198 | +# Since: 9.0 | ||
191 | +## | 199 | +## |
192 | +{ 'union': 'TpmCreateOptions', | 200 | +{ 'union': 'TpmCreateOptions', |
193 | + 'base': { 'type': 'TpmType', | 201 | + 'base': { 'type': 'TpmType', |
194 | + 'id' : 'str' }, | 202 | + 'id' : 'str' }, |
195 | + 'discriminator': 'type', | 203 | + 'discriminator': 'type', |
... | ... | ||
198 | + 'if': 'CONFIG_TPM' } | 206 | + 'if': 'CONFIG_TPM' } |
199 | + | 207 | + |
200 | ## | 208 | ## |
201 | # @TPMInfo: | 209 | # @TPMInfo: |
202 | # | 210 | # |
203 | diff --git a/softmmu/tpm.c b/softmmu/tpm.c | 211 | diff --git a/system/tpm.c b/system/tpm.c |
204 | index XXXXXXX..XXXXXXX 100644 | 212 | index XXXXXXX..XXXXXXX 100644 |
205 | --- a/softmmu/tpm.c | 213 | --- a/system/tpm.c |
206 | +++ b/softmmu/tpm.c | 214 | +++ b/system/tpm.c |
207 | @@ -XXX,XX +XXX,XX @@ | 215 | @@ -XXX,XX +XXX,XX @@ |
208 | #include "qapi/error.h" | 216 | #include "qapi/error.h" |
209 | #include "qapi/qapi-commands-tpm.h" | 217 | #include "qapi/qapi-commands-tpm.h" |
210 | #include "qapi/qmp/qerror.h" | 218 | #include "qapi/qmp/qerror.h" |
211 | +#include "qapi/qobject-input-visitor.h" | 219 | +#include "qapi/qobject-input-visitor.h" |
... | ... | ||
317 | + TpmCreateOptionsQueueEntry *tcoqe = QSIMPLEQ_FIRST(&tco_queue); | 325 | + TpmCreateOptionsQueueEntry *tcoqe = QSIMPLEQ_FIRST(&tco_queue); |
318 | 326 | ||
319 | - return 0; | 327 | - return 0; |
320 | + QSIMPLEQ_REMOVE_HEAD(&tco_queue, entry); | 328 | + QSIMPLEQ_REMOVE_HEAD(&tco_queue, entry); |
321 | + tpm_init_tpmdev(tcoqe->tco); | 329 | + tpm_init_tpmdev(tcoqe->tco); |
330 | + qapi_free_TpmCreateOptions(tcoqe->tco); | ||
322 | + g_free(tcoqe); | 331 | + g_free(tcoqe); |
323 | + } | 332 | + } |
324 | } | 333 | } |
325 | 334 | ||
326 | /* | 335 | /* |
327 | * Parse the TPM configuration options. | 336 | * Parse the TPM configuration options. |
328 | * To display all available TPM backends the user may use '-tpmdev help' | 337 | * To display all available TPM backends the user may use '-tpmdev help' |
329 | */ | 338 | */ |
330 | -int tpm_config_parse(QemuOptsList *opts_list, const char *optarg) | 339 | -int tpm_config_parse(QemuOptsList *opts_list, const char *optstr) |
331 | +void tpm_config_parse(const char *optarg) | 340 | +void tpm_config_parse(const char *optstr) |
332 | { | 341 | { |
333 | - QemuOpts *opts; | 342 | - QemuOpts *opts; |
334 | + Visitor *v; | 343 | + Visitor *v; |
335 | + TpmCreateOptionsQueueEntry *tcqe; | 344 | + TpmCreateOptionsQueueEntry *tcqe; |
336 | 345 | ||
337 | - if (!strcmp(optarg, "help")) { | 346 | - if (!strcmp(optstr, "help")) { |
338 | + if (is_help_option(optarg)) { | 347 | + if (is_help_option(optstr)) { |
339 | tpm_display_backend_drivers(); | 348 | tpm_display_backend_drivers(); |
340 | - return -1; | 349 | - return -1; |
341 | - } | 350 | - } |
342 | - opts = qemu_opts_parse_noisily(opts_list, optarg, true); | 351 | - opts = qemu_opts_parse_noisily(opts_list, optstr, true); |
343 | - if (!opts) { | 352 | - if (!opts) { |
344 | - return -1; | 353 | - return -1; |
345 | + exit(0); | 354 | + exit(0); |
346 | } | 355 | } |
347 | - return 0; | 356 | - return 0; |
348 | + v = qobject_input_visitor_new_str(optarg, "type", &error_fatal); | 357 | + v = qobject_input_visitor_new_str(optstr, "type", &error_fatal); |
349 | + tcqe = g_new(TpmCreateOptionsQueueEntry, 1); | 358 | + tcqe = g_new(TpmCreateOptionsQueueEntry, 1); |
350 | + visit_type_TpmCreateOptions(v, NULL, &tcqe->tco, &error_fatal); | 359 | + visit_type_TpmCreateOptions(v, NULL, &tcqe->tco, &error_fatal); |
351 | + visit_free(v); | 360 | + visit_free(v); |
352 | + QSIMPLEQ_INSERT_TAIL(&tco_queue, tcqe, entry); | 361 | + QSIMPLEQ_INSERT_TAIL(&tco_queue, tcqe, entry); |
353 | } | 362 | } |
354 | 363 | ||
355 | /* | 364 | /* |
356 | diff --git a/softmmu/vl.c b/softmmu/vl.c | 365 | diff --git a/system/vl.c b/system/vl.c |
357 | index XXXXXXX..XXXXXXX 100644 | 366 | index XXXXXXX..XXXXXXX 100644 |
358 | --- a/softmmu/vl.c | 367 | --- a/system/vl.c |
359 | +++ b/softmmu/vl.c | 368 | +++ b/system/vl.c |
360 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList qemu_object_opts = { | 369 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList qemu_object_opts = { |
361 | }, | 370 | }, |
362 | }; | 371 | }; |
363 | 372 | ||
364 | -static QemuOptsList qemu_tpmdev_opts = { | 373 | -static QemuOptsList qemu_tpmdev_opts = { |
... | ... | ||
373 | - | 382 | - |
374 | static QemuOptsList qemu_overcommit_opts = { | 383 | static QemuOptsList qemu_overcommit_opts = { |
375 | .name = "overcommit", | 384 | .name = "overcommit", |
376 | .head = QTAILQ_HEAD_INITIALIZER(qemu_overcommit_opts.head), | 385 | .head = QTAILQ_HEAD_INITIALIZER(qemu_overcommit_opts.head), |
377 | @@ -XXX,XX +XXX,XX @@ static void qemu_create_late_backends(void) | 386 | @@ -XXX,XX +XXX,XX @@ static void qemu_create_late_backends(void) |
378 | 387 | exit(1); | |
379 | object_option_foreach_add(object_create_late); | 388 | } |
380 | 389 | ||
381 | - if (tpm_init() < 0) { | 390 | - if (tpm_init() < 0) { |
382 | - exit(1); | 391 | - exit(1); |
383 | - } | 392 | - } |
384 | + tpm_init(); | 393 | + tpm_init(); |
... | ... | diff view generated by jsdifflib |
1 | From: James Bottomley <James.Bottomley@HansenPartnership.com> | ||
---|---|---|---|
2 | |||
3 | The Microsoft Simulator (mssim) is the reference emulation platform | 1 | The Microsoft Simulator (mssim) is the reference emulation platform |
4 | for the TCG TPM 2.0 specification. | 2 | for the TCG TPM 2.0 specification. |
5 | 3 | ||
6 | https://github.com/Microsoft/ms-tpm-20-ref.git | 4 | https://github.com/Microsoft/ms-tpm-20-ref.git |
7 | 5 | ||
... | ... | ||
34 | 32 | ||
35 | -tpmdev "{'type':'mssim','id':'tpm0','command':{'type':inet,'host':'remote','port':'2321'}}" | 33 | -tpmdev "{'type':'mssim','id':'tpm0','command':{'type':inet,'host':'remote','port':'2321'}}" |
36 | 34 | ||
37 | tpm-tis also works as the backend. | 35 | tpm-tis also works as the backend. |
38 | 36 | ||
39 | Signed-off-by: James Bottomley <jejb@linux.ibm.com> | 37 | Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> |
38 | Acked-by: Markus Armbruster <armbru@redhat.com> | ||
40 | 39 | ||
41 | --- | 40 | --- |
42 | 41 | ||
43 | v2: convert to SocketAddr json and use qio_channel_socket_connect_sync() | 42 | v2: convert to SocketAddr json and use qio_channel_socket_connect_sync() |
44 | v3: gate control power off by migration state keep control socket disconnected | 43 | v3: gate control power off by migration state keep control socket disconnected |
45 | to test outside influence and add docs. | 44 | to test outside influence and add docs. |
45 | v7: TPMmssim -> TPMMssim; doc and json fixes | ||
46 | Make command socket open each time (makes OS debugging easier) | ||
47 | v11: add startup method to make sure TPM is reset on reboot | ||
46 | --- | 48 | --- |
47 | MAINTAINERS | 6 + | 49 | MAINTAINERS | 6 + |
48 | backends/tpm/Kconfig | 5 + | 50 | backends/tpm/Kconfig | 5 + |
49 | backends/tpm/meson.build | 1 + | 51 | backends/tpm/meson.build | 1 + |
50 | backends/tpm/tpm_mssim.c | 290 +++++++++++++++++++++++++++++++++++++++ | 52 | backends/tpm/tpm_mssim.c | 335 +++++++++++++++++++++++++++++++++++++++ |
51 | backends/tpm/tpm_mssim.h | 44 ++++++ | 53 | backends/tpm/tpm_mssim.h | 44 +++++ |
52 | docs/specs/tpm.rst | 35 +++++ | 54 | docs/specs/tpm.rst | 39 +++++ |
53 | monitor/hmp-cmds.c | 9 ++ | 55 | qapi/tpm.json | 31 +++- |
54 | qapi/tpm.json | 28 +++- | 56 | system/tpm-hmp-cmds.c | 9 ++ |
55 | 8 files changed, 414 insertions(+), 4 deletions(-) | 57 | 8 files changed, 466 insertions(+), 4 deletions(-) |
56 | create mode 100644 backends/tpm/tpm_mssim.c | 58 | create mode 100644 backends/tpm/tpm_mssim.c |
57 | create mode 100644 backends/tpm/tpm_mssim.h | 59 | create mode 100644 backends/tpm/tpm_mssim.h |
58 | 60 | ||
59 | diff --git a/MAINTAINERS b/MAINTAINERS | 61 | diff --git a/MAINTAINERS b/MAINTAINERS |
60 | index XXXXXXX..XXXXXXX 100644 | 62 | index XXXXXXX..XXXXXXX 100644 |
... | ... | ||
72 | +MSSIM TPM Backend | 74 | +MSSIM TPM Backend |
73 | +M: James Bottomley <jejb@linux.ibm.com> | 75 | +M: James Bottomley <jejb@linux.ibm.com> |
74 | +S: Maintained | 76 | +S: Maintained |
75 | +F: backends/tpm/tpm_mssim.* | 77 | +F: backends/tpm/tpm_mssim.* |
76 | + | 78 | + |
77 | Checkpatch | 79 | SPDM |
78 | S: Odd Fixes | 80 | M: Alistair Francis <alistair.francis@wdc.com> |
79 | F: scripts/checkpatch.pl | 81 | S: Maintained |
80 | diff --git a/backends/tpm/Kconfig b/backends/tpm/Kconfig | 82 | diff --git a/backends/tpm/Kconfig b/backends/tpm/Kconfig |
81 | index XXXXXXX..XXXXXXX 100644 | 83 | index XXXXXXX..XXXXXXX 100644 |
82 | --- a/backends/tpm/Kconfig | 84 | --- a/backends/tpm/Kconfig |
83 | +++ b/backends/tpm/Kconfig | 85 | +++ b/backends/tpm/Kconfig |
84 | @@ -XXX,XX +XXX,XX @@ config TPM_EMULATOR | 86 | @@ -XXX,XX +XXX,XX @@ config TPM_EMULATOR |
... | ... | ||
93 | diff --git a/backends/tpm/meson.build b/backends/tpm/meson.build | 95 | diff --git a/backends/tpm/meson.build b/backends/tpm/meson.build |
94 | index XXXXXXX..XXXXXXX 100644 | 96 | index XXXXXXX..XXXXXXX 100644 |
95 | --- a/backends/tpm/meson.build | 97 | --- a/backends/tpm/meson.build |
96 | +++ b/backends/tpm/meson.build | 98 | +++ b/backends/tpm/meson.build |
97 | @@ -XXX,XX +XXX,XX @@ if have_tpm | 99 | @@ -XXX,XX +XXX,XX @@ if have_tpm |
98 | softmmu_ss.add(files('tpm_util.c')) | 100 | system_ss.add(files('tpm_util.c')) |
99 | softmmu_ss.add(when: 'CONFIG_TPM_PASSTHROUGH', if_true: files('tpm_passthrough.c')) | 101 | system_ss.add(when: 'CONFIG_TPM_PASSTHROUGH', if_true: files('tpm_passthrough.c')) |
100 | softmmu_ss.add(when: 'CONFIG_TPM_EMULATOR', if_true: files('tpm_emulator.c')) | 102 | system_ss.add(when: 'CONFIG_TPM_EMULATOR', if_true: files('tpm_emulator.c')) |
101 | + softmmu_ss.add(when: 'CONFIG_TPM_MSSIM', if_true: files('tpm_mssim.c')) | 103 | + system_ss.add(when: 'CONFIG_TPM_MSSIM', if_true: files('tpm_mssim.c')) |
102 | endif | 104 | endif |
103 | diff --git a/backends/tpm/tpm_mssim.c b/backends/tpm/tpm_mssim.c | 105 | diff --git a/backends/tpm/tpm_mssim.c b/backends/tpm/tpm_mssim.c |
104 | new file mode 100644 | 106 | new file mode 100644 |
105 | index XXXXXXX..XXXXXXX | 107 | index XXXXXXX..XXXXXXX |
106 | --- /dev/null | 108 | --- /dev/null |
... | ... | ||
133 | +#include "tpm_mssim.h" | 135 | +#include "tpm_mssim.h" |
134 | + | 136 | + |
135 | +#define ERROR_PREFIX "TPM mssim Emulator: " | 137 | +#define ERROR_PREFIX "TPM mssim Emulator: " |
136 | + | 138 | + |
137 | +#define TYPE_TPM_MSSIM "tpm-mssim" | 139 | +#define TYPE_TPM_MSSIM "tpm-mssim" |
138 | +OBJECT_DECLARE_SIMPLE_TYPE(TPMmssim, TPM_MSSIM) | 140 | +OBJECT_DECLARE_SIMPLE_TYPE(TPMMssim, TPM_MSSIM) |
139 | + | 141 | + |
140 | +struct TPMmssim { | 142 | +struct TPMMssim { |
141 | + TPMBackend parent; | 143 | + TPMBackend parent; |
142 | + | 144 | + |
143 | + TPMmssimOptions opts; | 145 | + TPMMssimOptions opts; |
144 | + | 146 | + |
145 | + QIOChannelSocket *cmd_qc, *ctrl_qc; | 147 | + QIOChannelSocket *cmd_qc, *ctrl_qc; |
146 | +}; | 148 | +}; |
147 | + | 149 | + |
148 | +static int tpm_send_ctrl(TPMmssim *t, uint32_t cmd, Error **errp) | 150 | +static int tpm_send_ctrl(TPMMssim *t, uint32_t cmd, Error **errp) |
149 | +{ | 151 | +{ |
150 | + int ret; | 152 | + int ret, retc; |
151 | + | 153 | + Error *local_err = NULL; |
152 | + qio_channel_socket_connect_sync(t->ctrl_qc, t->opts.control, errp); | 154 | + |
155 | + ret = qio_channel_socket_connect_sync(t->ctrl_qc, t->opts.control, errp); | ||
156 | + if (ret != 0) { | ||
157 | + return ret; | ||
158 | + } | ||
153 | + cmd = htonl(cmd); | 159 | + cmd = htonl(cmd); |
154 | + ret = qio_channel_write_all(QIO_CHANNEL(t->ctrl_qc), | 160 | + ret = qio_channel_write_all(QIO_CHANNEL(t->ctrl_qc), |
155 | + (char *)&cmd, sizeof(cmd), errp); | 161 | + (char *)&cmd, sizeof(cmd), errp); |
156 | + if (ret != 0) { | 162 | + if (ret != 0) { |
157 | + goto out; | 163 | + goto out; |
... | ... | ||
166 | + error_setg(errp, ERROR_PREFIX | 172 | + error_setg(errp, ERROR_PREFIX |
167 | + "Incorrect ACK recieved on control channel 0x%x", cmd); | 173 | + "Incorrect ACK recieved on control channel 0x%x", cmd); |
168 | + ret = -1; | 174 | + ret = -1; |
169 | + } | 175 | + } |
170 | + out: | 176 | + out: |
171 | + qio_channel_close(QIO_CHANNEL(t->ctrl_qc), errp); | 177 | + /* |
172 | + return ret; | 178 | + * need to close the channel here, but if that fails report it |
179 | + * while not letting a prior failure get overwritten | ||
180 | + */ | ||
181 | + retc = qio_channel_close(QIO_CHANNEL(t->ctrl_qc), &local_err); | ||
182 | + error_propagate(errp, local_err); | ||
183 | + return retc ? retc : ret; | ||
173 | +} | 184 | +} |
174 | + | 185 | + |
175 | +static void tpm_mssim_instance_init(Object *obj) | 186 | +static void tpm_mssim_instance_init(Object *obj) |
176 | +{ | 187 | +{ |
177 | +} | 188 | +} |
178 | + | 189 | + |
179 | +static void tpm_mssim_instance_finalize(Object *obj) | 190 | +static void tpm_mssim_instance_finalize(Object *obj) |
180 | +{ | 191 | +{ |
181 | + TPMmssim *t = TPM_MSSIM(obj); | 192 | + TPMMssim *t = TPM_MSSIM(obj); |
182 | + | 193 | + |
183 | + if (t->cmd_qc && !runstate_check(RUN_STATE_POSTMIGRATE)) { | 194 | + if (t->cmd_qc && !runstate_check(RUN_STATE_POSTMIGRATE)) { |
184 | + tpm_send_ctrl(t, TPM_SIGNAL_POWER_OFF, NULL); | 195 | + Error *errp = NULL; |
196 | + int ret; | ||
197 | + | ||
198 | + ret = tpm_send_ctrl(t, TPM_SIGNAL_POWER_OFF, &errp); | ||
199 | + if (ret != 0) { | ||
200 | + error_report_err(errp); | ||
201 | + } | ||
185 | + } | 202 | + } |
186 | + | 203 | + |
187 | + object_unref(OBJECT(t->ctrl_qc)); | 204 | + object_unref(OBJECT(t->ctrl_qc)); |
188 | + object_unref(OBJECT(t->cmd_qc)); | 205 | + object_unref(OBJECT(t->cmd_qc)); |
189 | +} | 206 | +} |
... | ... | ||
204 | + return 4096; | 221 | + return 4096; |
205 | +} | 222 | +} |
206 | + | 223 | + |
207 | +static TpmTypeOptions *tpm_mssim_get_opts(TPMBackend *tb) | 224 | +static TpmTypeOptions *tpm_mssim_get_opts(TPMBackend *tb) |
208 | +{ | 225 | +{ |
209 | + TPMmssim *t = TPM_MSSIM(tb); | 226 | + TPMMssim *t = TPM_MSSIM(tb); |
210 | + TpmTypeOptions *opts = g_new0(TpmTypeOptions, 1); | 227 | + TpmTypeOptions *opts = g_new0(TpmTypeOptions, 1); |
211 | + | 228 | + |
212 | + opts->type = TPM_TYPE_MSSIM; | 229 | + opts->type = TPM_TYPE_MSSIM; |
213 | + opts->u.mssim = t->opts; | 230 | + QAPI_CLONE_MEMBERS(TPMMssimOptions, &opts->u.mssim, &t->opts); |
214 | + | 231 | + |
215 | + return opts; | 232 | + return opts; |
216 | +} | 233 | +} |
217 | + | 234 | + |
218 | +static void tpm_mssim_handle_request(TPMBackend *tb, TPMBackendCmd *cmd, | 235 | +static void tpm_mssim_handle_request(TPMBackend *tb, TPMBackendCmd *cmd, |
219 | + Error **errp) | 236 | + Error **errp) |
220 | +{ | 237 | +{ |
221 | + TPMmssim *t = TPM_MSSIM(tb); | 238 | + TPMMssim *t = TPM_MSSIM(tb); |
222 | + uint32_t header, len; | 239 | + uint32_t header, len; |
223 | + uint8_t locality = cmd->locty; | 240 | + uint8_t locality = cmd->locty; |
224 | + struct iovec iov[4]; | 241 | + struct iovec iov[4]; |
225 | + int ret; | 242 | + int ret; |
243 | + | ||
244 | + ret = qio_channel_socket_connect_sync(t->cmd_qc, t->opts.command, errp); | ||
245 | + if (ret != 0) { | ||
246 | + goto fail_msg; | ||
247 | + } | ||
226 | + | 248 | + |
227 | + header = htonl(TPM_SEND_COMMAND); | 249 | + header = htonl(TPM_SEND_COMMAND); |
228 | + len = htonl(cmd->in_len); | 250 | + len = htonl(cmd->in_len); |
229 | + | 251 | + |
230 | + iov[0].iov_base = &header; | 252 | + iov[0].iov_base = &header; |
... | ... | ||
267 | + if (header != 0) { | 289 | + if (header != 0) { |
268 | + error_setg(errp, "incorrect ACK received on command channel 0x%x", len); | 290 | + error_setg(errp, "incorrect ACK received on command channel 0x%x", len); |
269 | + goto fail; | 291 | + goto fail; |
270 | + } | 292 | + } |
271 | + | 293 | + |
294 | + ret = qio_channel_close(QIO_CHANNEL(t->cmd_qc), errp); | ||
295 | + if (ret != 0) { | ||
296 | + goto fail_msg; | ||
297 | + } | ||
298 | + | ||
272 | + return; | 299 | + return; |
273 | + | 300 | + |
274 | + fail: | 301 | + fail: |
302 | + /* we're already failing, so don't worry if this fails too */ | ||
303 | + qio_channel_close(QIO_CHANNEL(t->cmd_qc), NULL); | ||
304 | + fail_msg: | ||
275 | + error_prepend(errp, ERROR_PREFIX); | 305 | + error_prepend(errp, ERROR_PREFIX); |
276 | + tpm_util_write_fatal_error_response(cmd->out, cmd->out_len); | 306 | + tpm_util_write_fatal_error_response(cmd->out, cmd->out_len); |
277 | +} | 307 | +} |
278 | + | 308 | + |
309 | +static int tpm_mssim_startup(TPMBackend *tb, size_t buffersize) | ||
310 | +{ | ||
311 | + TPMMssim *t = TPM_MSSIM(tb); | ||
312 | + Error *errp = NULL; | ||
313 | + int ret; | ||
314 | + | ||
315 | + if (runstate_check(RUN_STATE_INMIGRATE)) { | ||
316 | + return 0; | ||
317 | + } | ||
318 | + | ||
319 | + /* | ||
320 | + * reset the TPM using a power cycle sequence, in case someone has | ||
321 | + * previously powered it up | ||
322 | + */ | ||
323 | + ret = tpm_send_ctrl(t, TPM_SIGNAL_POWER_OFF, &errp); | ||
324 | + if (ret != 0) { | ||
325 | + goto fail; | ||
326 | + } | ||
327 | + | ||
328 | + ret = tpm_send_ctrl(t, TPM_SIGNAL_POWER_ON, &errp); | ||
329 | + if (ret != 0) { | ||
330 | + goto fail; | ||
331 | + } | ||
332 | + | ||
333 | + ret = tpm_send_ctrl(t, TPM_SIGNAL_NV_ON, &errp); | ||
334 | + if (ret != 0) { | ||
335 | + goto fail; | ||
336 | + } | ||
337 | + | ||
338 | + return 0; | ||
339 | + | ||
340 | + fail: | ||
341 | + error_report_err(errp); | ||
342 | + return -1; | ||
343 | +} | ||
344 | + | ||
279 | +static TPMBackend *tpm_mssim_create(TpmCreateOptions *opts) | 345 | +static TPMBackend *tpm_mssim_create(TpmCreateOptions *opts) |
280 | +{ | 346 | +{ |
281 | + TPMBackend *be = TPM_BACKEND(object_new(TYPE_TPM_MSSIM)); | 347 | + TPMBackend *be = TPM_BACKEND(object_new(TYPE_TPM_MSSIM)); |
282 | + TPMmssim *t = TPM_MSSIM(be); | 348 | + TPMMssim *t = TPM_MSSIM(be); |
283 | + int sock; | ||
284 | + Error *errp = NULL; | 349 | + Error *errp = NULL; |
285 | + TPMmssimOptions *mo = &opts->u.mssim; | 350 | + TPMMssimOptions *mo = &opts->u.mssim; |
286 | + | 351 | + |
287 | + if (!mo->command) { | 352 | + if (!mo->command) { |
288 | + mo->command = g_new0(SocketAddress, 1); | 353 | + mo->command = g_new0(SocketAddress, 1); |
289 | + mo->command->type = SOCKET_ADDRESS_TYPE_INET; | 354 | + mo->command->type = SOCKET_ADDRESS_TYPE_INET; |
290 | + mo->command->u.inet.host = g_strdup("localhost"); | 355 | + mo->command->u.inet.host = g_strdup("localhost"); |
... | ... | ||
302 | + */ | 367 | + */ |
303 | + port = atoi(mo->command->u.inet.port) + 1; | 368 | + port = atoi(mo->command->u.inet.port) + 1; |
304 | + mo->control->u.inet.port = g_strdup_printf("%d", port); | 369 | + mo->control->u.inet.port = g_strdup_printf("%d", port); |
305 | + } | 370 | + } |
306 | + | 371 | + |
307 | + t->opts = opts->u.mssim; | 372 | + QAPI_CLONE_MEMBERS(TPMMssimOptions, &t->opts, &opts->u.mssim); |
308 | + t->cmd_qc = qio_channel_socket_new(); | 373 | + t->cmd_qc = qio_channel_socket_new(); |
309 | + t->ctrl_qc = qio_channel_socket_new(); | 374 | + t->ctrl_qc = qio_channel_socket_new(); |
310 | + | 375 | + |
311 | + if (qio_channel_socket_connect_sync(t->cmd_qc, mo->command, &errp) < 0) { | 376 | + if (qio_channel_socket_connect_sync(t->cmd_qc, mo->command, &errp) < 0) { |
312 | + goto fail; | 377 | + goto fail; |
313 | + } | 378 | + } |
314 | + | 379 | + |
315 | + if (qio_channel_socket_connect_sync(t->ctrl_qc, mo->control, &errp) < 0) { | 380 | + if (qio_channel_socket_connect_sync(t->ctrl_qc, mo->control, &errp) < 0) { |
316 | + goto fail; | 381 | + goto fail; |
317 | + } | 382 | + } |
318 | + qio_channel_close(QIO_CHANNEL(t->ctrl_qc), &errp); | 383 | + qio_channel_close(QIO_CHANNEL(t->ctrl_qc), NULL); |
319 | + | 384 | + qio_channel_close(QIO_CHANNEL(t->cmd_qc), NULL); |
320 | + if (!runstate_check(RUN_STATE_INMIGRATE)) { | 385 | + |
321 | + /* | ||
322 | + * reset the TPM using a power cycle sequence, in case someone | ||
323 | + * has previously powered it up | ||
324 | + */ | ||
325 | + sock = tpm_send_ctrl(t, TPM_SIGNAL_POWER_OFF, &errp); | ||
326 | + if (sock != 0) { | ||
327 | + goto fail; | ||
328 | + } | ||
329 | + | ||
330 | + sock = tpm_send_ctrl(t, TPM_SIGNAL_POWER_ON, &errp); | ||
331 | + if (sock != 0) { | ||
332 | + goto fail; | ||
333 | + } | ||
334 | + | ||
335 | + sock = tpm_send_ctrl(t, TPM_SIGNAL_NV_ON, &errp); | ||
336 | + if (sock != 0) { | ||
337 | + goto fail; | ||
338 | + } | ||
339 | + } | ||
340 | + | 386 | + |
341 | + return be; | 387 | + return be; |
342 | + | 388 | + |
343 | + fail: | 389 | + fail: |
344 | + object_unref(OBJECT(t->ctrl_qc)); | 390 | + object_unref(OBJECT(t->ctrl_qc)); |
... | ... | ||
373 | + cl->type = TPM_TYPE_MSSIM; | 419 | + cl->type = TPM_TYPE_MSSIM; |
374 | + cl->opts = tpm_mssim_cmdline_opts; | 420 | + cl->opts = tpm_mssim_cmdline_opts; |
375 | + cl->desc = "TPM mssim emulator backend driver"; | 421 | + cl->desc = "TPM mssim emulator backend driver"; |
376 | + cl->create = tpm_mssim_create; | 422 | + cl->create = tpm_mssim_create; |
377 | + cl->cancel_cmd = tpm_mssim_cancel_cmd; | 423 | + cl->cancel_cmd = tpm_mssim_cancel_cmd; |
424 | + cl->startup_tpm = tpm_mssim_startup; | ||
378 | + cl->get_tpm_version = tpm_mssim_get_version; | 425 | + cl->get_tpm_version = tpm_mssim_get_version; |
379 | + cl->get_buffer_size = tpm_mssim_get_buffer_size; | 426 | + cl->get_buffer_size = tpm_mssim_get_buffer_size; |
380 | + cl->get_tpm_options = tpm_mssim_get_opts; | 427 | + cl->get_tpm_options = tpm_mssim_get_opts; |
381 | + cl->handle_request = tpm_mssim_handle_request; | 428 | + cl->handle_request = tpm_mssim_handle_request; |
382 | +} | 429 | +} |
383 | + | 430 | + |
384 | +static const TypeInfo tpm_mssim_info = { | 431 | +static const TypeInfo tpm_mssim_info = { |
385 | + .name = TYPE_TPM_MSSIM, | 432 | + .name = TYPE_TPM_MSSIM, |
386 | + .parent = TYPE_TPM_BACKEND, | 433 | + .parent = TYPE_TPM_BACKEND, |
387 | + .instance_size = sizeof(TPMmssim), | 434 | + .instance_size = sizeof(TPMMssim), |
388 | + .class_init = tpm_mssim_class_init, | 435 | + .class_init = tpm_mssim_class_init, |
389 | + .instance_init = tpm_mssim_instance_init, | 436 | + .instance_init = tpm_mssim_instance_init, |
390 | + .instance_finalize = tpm_mssim_instance_finalize, | 437 | + .instance_finalize = tpm_mssim_instance_finalize, |
391 | +}; | 438 | +}; |
392 | + | 439 | + |
... | ... | ||
455 | ... | 502 | ... |
456 | 503 | ||
457 | +The QEMU TPM Microsoft Simulator Device | 504 | +The QEMU TPM Microsoft Simulator Device |
458 | +--------------------------------------- | 505 | +--------------------------------------- |
459 | + | 506 | + |
460 | +The TCG provides a reference implementation for TPM 2.0 written by | 507 | +The Microsoft Simulator (mssim) is the reference emulation platform |
461 | +Microsoft (See `ms-tpm-20-ref`_ on github). The reference implementation | 508 | +for the TCG TPM 2.0 specification. It provides a reference |
462 | +starts a network server and listens for TPM commands on port 2321 and | 509 | +implementation for the TPM 2.0 written by Microsoft (See |
463 | +TPM Platform control commands on port 2322, although these can be | 510 | +`ms-tpm-20-ref`_ on github). The reference implementation starts a |
464 | +altered. The QEMU mssim TPM backend talks to this implementation. By | 511 | +network server and listens for TPM commands on port 2321 and TPM |
465 | +default it connects to the default ports on localhost: | 512 | +Platform control commands on port 2322, although these can be altered. |
513 | +The QEMU mssim TPM backend talks to this implementation. By default | ||
514 | +it connects to the default ports on localhost: | ||
466 | + | 515 | + |
467 | +.. code-block:: console | 516 | +.. code-block:: console |
468 | + | 517 | + |
469 | + qemu-system-x86_64 <qemu-options> \ | 518 | + qemu-system-x86_64 <qemu-options> \ |
470 | + -tpmdev mssim,id=tpm0 \ | 519 | + -tpmdev mssim,id=tpm0 \ |
471 | + -device tpm-crb,tpmdev=tpm0 | 520 | + -device tpm-crb,tpmdev=tpm0 |
472 | + | 521 | + |
473 | + | 522 | + |
474 | +Although it can also communicate with a remote host, which must be | 523 | +Although it can also communicate with a remote host, which must be |
475 | +specified as a SocketAddress via json on the command line for each of | 524 | +specified as a SocketAddress via json or dotted keys on the command |
476 | +the command and control ports: | 525 | +line for each of the command and control ports: |
477 | + | 526 | + |
478 | +.. code-block:: console | 527 | +.. code-block:: console |
479 | + | 528 | + |
480 | + qemu-system-x86_64 <qemu-options> \ | 529 | + qemu-system-x86_64 <qemu-options> \ |
481 | + -tpmdev "{'type':'mssim','id':'tpm0','command':{'type':'inet','host':'remote','port':'2321'},'control':{'type':'inet','host':'remote','port':'2322'}}" \ | 530 | + -tpmdev "{'type':'mssim','id':'tpm0','command':{'type':'inet','host':'remote','port':'2321'},'control':{'type':'inet','host':'remote','port':'2322'}}" \ |
482 | + -device tpm-crb,tpmdev=tpm0 | 531 | + -device tpm-crb,tpmdev=tpm0 |
483 | + | 532 | + |
484 | + | 533 | + |
485 | +The mssim backend supports snapshotting and migration, but the state | 534 | +The mssim backend supports snapshotting and migration by not resetting |
486 | +of the Microsoft Simulator server must be preserved (or the server | 535 | +the TPM on start up and not powering it down on halt if the VM is in |
487 | +kept running) outside of QEMU for restore to be successful. | 536 | +migration, but the state of the Microsoft Simulator server must be |
537 | +preserved (or the server kept running) outside of QEMU for restore to | ||
538 | +be successful. | ||
488 | + | 539 | + |
489 | The QEMU TPM emulator device | 540 | The QEMU TPM emulator device |
490 | ---------------------------- | 541 | ---------------------------- |
491 | 542 | ||
492 | @@ -XXX,XX +XXX,XX @@ the following: | 543 | @@ -XXX,XX +XXX,XX @@ the following: |
493 | 544 | ||
494 | .. _SWTPM protocol: | 545 | .. _SWTPM protocol: |
495 | https://github.com/stefanberger/swtpm/blob/master/man/man3/swtpm_ioctls.pod | 546 | https://github.com/stefanberger/swtpm/blob/master/man/man3/swtpm_ioctls.pod |
496 | + | 547 | + |
497 | +.. _ms-tpm-20-ref: | 548 | +.. _ms-tpm-20-ref: |
498 | + https://github.com/microsoft/ms-tpm-20-ref | 549 | + https://github.com/microsoft/ms-tpm-20-ref |
499 | diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c | 550 | diff --git a/qapi/tpm.json b/qapi/tpm.json |
500 | index XXXXXXX..XXXXXXX 100644 | 551 | index XXXXXXX..XXXXXXX 100644 |
501 | --- a/monitor/hmp-cmds.c | 552 | --- a/qapi/tpm.json |
502 | +++ b/monitor/hmp-cmds.c | 553 | +++ b/qapi/tpm.json |
554 | @@ -XXX,XX +XXX,XX @@ | ||
555 | # = TPM (trusted platform module) devices | ||
556 | ## | ||
557 | |||
558 | +{ 'include': 'sockets.json' } | ||
559 | + | ||
560 | ## | ||
561 | # @TpmModel: | ||
562 | # | ||
563 | @@ -XXX,XX +XXX,XX @@ | ||
564 | # | ||
565 | # @emulator: Software Emulator TPM type (since 2.11) | ||
566 | # | ||
567 | +# @mssim: Microsoft TPM Emulator (since 9.0) | ||
568 | +# | ||
569 | # Since: 1.5 | ||
570 | ## | ||
571 | -{ 'enum': 'TpmType', 'data': [ 'passthrough', 'emulator' ], | ||
572 | +{ 'enum': 'TpmType', 'data': [ 'passthrough', 'emulator', 'mssim' ], | ||
573 | 'if': 'CONFIG_TPM' } | ||
574 | |||
575 | ## | ||
576 | @@ -XXX,XX +XXX,XX @@ | ||
577 | # .. qmp-example:: | ||
578 | # | ||
579 | # -> { "execute": "query-tpm-types" } | ||
580 | -# <- { "return": [ "passthrough", "emulator" ] } | ||
581 | +# <- { "return": [ "passthrough", "emulator", "mssim" ] } | ||
582 | ## | ||
583 | { 'command': 'query-tpm-types', 'returns': ['TpmType'], | ||
584 | 'if': 'CONFIG_TPM' } | ||
585 | @@ -XXX,XX +XXX,XX @@ | ||
586 | 'data': { 'data': 'TPMEmulatorOptions' }, | ||
587 | 'if': 'CONFIG_TPM' } | ||
588 | |||
589 | +## | ||
590 | +# @TPMMssimOptions: | ||
591 | +# | ||
592 | +# Information for the mssim emulator connection | ||
593 | +# | ||
594 | +# @command: command socket for the TPM emulator | ||
595 | +# | ||
596 | +# @control: control socket for the TPM emulator | ||
597 | +# | ||
598 | +# Since: 9.0 | ||
599 | +## | ||
600 | +{ 'struct': 'TPMMssimOptions', | ||
601 | + 'data': { '*command': 'SocketAddress', | ||
602 | + '*control': 'SocketAddress' }, | ||
603 | + 'if': 'CONFIG_TPM' } | ||
604 | + | ||
605 | ## | ||
606 | # @TpmTypeOptions: | ||
607 | # | ||
608 | @@ -XXX,XX +XXX,XX @@ | ||
609 | # passthrough type | ||
610 | # - 'emulator' The configuration options for TPM emulator backend | ||
611 | # type | ||
612 | +# - 'mssim' The configuration options for TPM emulator mssim type | ||
613 | # | ||
614 | # Since: 1.5 | ||
615 | ## | ||
616 | @@ -XXX,XX +XXX,XX @@ | ||
617 | 'base': { 'type': 'TpmType' }, | ||
618 | 'discriminator': 'type', | ||
619 | 'data': { 'passthrough' : 'TPMPassthroughOptionsWrapper', | ||
620 | - 'emulator': 'TPMEmulatorOptionsWrapper' }, | ||
621 | + 'emulator': 'TPMEmulatorOptionsWrapper', | ||
622 | + 'mssim' : 'TPMMssimOptions' }, | ||
623 | 'if': 'CONFIG_TPM' } | ||
624 | |||
625 | ## | ||
626 | @@ -XXX,XX +XXX,XX @@ | ||
627 | 'id' : 'str' }, | ||
628 | 'discriminator': 'type', | ||
629 | 'data': { 'passthrough' : 'TPMPassthroughOptions', | ||
630 | - 'emulator': 'TPMEmulatorOptions' }, | ||
631 | + 'emulator': 'TPMEmulatorOptions', | ||
632 | + 'mssim': 'TPMMssimOptions' }, | ||
633 | 'if': 'CONFIG_TPM' } | ||
634 | |||
635 | ## | ||
636 | diff --git a/system/tpm-hmp-cmds.c b/system/tpm-hmp-cmds.c | ||
637 | index XXXXXXX..XXXXXXX 100644 | ||
638 | --- a/system/tpm-hmp-cmds.c | ||
639 | +++ b/system/tpm-hmp-cmds.c | ||
503 | @@ -XXX,XX +XXX,XX @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) | 640 | @@ -XXX,XX +XXX,XX @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) |
504 | unsigned int c = 0; | 641 | unsigned int c = 0; |
505 | TPMPassthroughOptions *tpo; | 642 | TPMPassthroughOptions *tpo; |
506 | TPMEmulatorOptions *teo; | 643 | TPMEmulatorOptions *teo; |
507 | + TPMmssimOptions *tmo; | 644 | + TPMMssimOptions *tmo; |
508 | 645 | ||
509 | info_list = qmp_query_tpm(&err); | 646 | info_list = qmp_query_tpm(&err); |
510 | if (err) { | 647 | if (err) { |
511 | @@ -XXX,XX +XXX,XX @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) | 648 | @@ -XXX,XX +XXX,XX @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) |
512 | teo = ti->options->u.emulator.data; | 649 | teo = ti->options->u.emulator.data; |
... | ... | ||
521 | + tmo->control->u.inet.port); | 658 | + tmo->control->u.inet.port); |
522 | + break; | 659 | + break; |
523 | case TPM_TYPE__MAX: | 660 | case TPM_TYPE__MAX: |
524 | break; | 661 | break; |
525 | } | 662 | } |
526 | diff --git a/qapi/tpm.json b/qapi/tpm.json | ||
527 | index XXXXXXX..XXXXXXX 100644 | ||
528 | --- a/qapi/tpm.json | ||
529 | +++ b/qapi/tpm.json | ||
530 | @@ -XXX,XX +XXX,XX @@ | ||
531 | ## | ||
532 | # = TPM (trusted platform module) devices | ||
533 | ## | ||
534 | +{ 'include': 'sockets.json' } | ||
535 | |||
536 | ## | ||
537 | # @TpmModel: | ||
538 | @@ -XXX,XX +XXX,XX @@ | ||
539 | # | ||
540 | # Since: 1.5 | ||
541 | ## | ||
542 | -{ 'enum': 'TpmType', 'data': [ 'passthrough', 'emulator' ], | ||
543 | +{ 'enum': 'TpmType', 'data': [ 'passthrough', 'emulator', 'mssim' ], | ||
544 | 'if': 'CONFIG_TPM' } | ||
545 | |||
546 | ## | ||
547 | @@ -XXX,XX +XXX,XX @@ | ||
548 | # Example: | ||
549 | # | ||
550 | # -> { "execute": "query-tpm-types" } | ||
551 | -# <- { "return": [ "passthrough", "emulator" ] } | ||
552 | +# <- { "return": [ "passthrough", "emulator", "mssim" ] } | ||
553 | # | ||
554 | ## | ||
555 | { 'command': 'query-tpm-types', 'returns': ['TpmType'], | ||
556 | @@ -XXX,XX +XXX,XX @@ | ||
557 | 'data': { 'data': 'TPMEmulatorOptions' }, | ||
558 | 'if': 'CONFIG_TPM' } | ||
559 | |||
560 | +## | ||
561 | +# @TPMmssimOptions: | ||
562 | +# | ||
563 | +# Information for the mssim emulator connection | ||
564 | +# | ||
565 | +# @command: command socket for the TPM emulator | ||
566 | +# @control: control socket for the TPM emulator | ||
567 | +# | ||
568 | +# Since: 7.2.0 | ||
569 | +## | ||
570 | +{ 'struct': 'TPMmssimOptions', | ||
571 | + 'data': { | ||
572 | + '*command': 'SocketAddress', | ||
573 | + '*control': 'SocketAddress' }, | ||
574 | + 'if': 'CONFIG_TPM' } | ||
575 | + | ||
576 | ## | ||
577 | # @TpmTypeOptions: | ||
578 | # | ||
579 | @@ -XXX,XX +XXX,XX @@ | ||
580 | # | ||
581 | # @type: - 'passthrough' The configuration options for the TPM passthrough type | ||
582 | # - 'emulator' The configuration options for TPM emulator backend type | ||
583 | +# - 'mssim' The configuration options for TPM emulator mssim type | ||
584 | # | ||
585 | # Since: 1.5 | ||
586 | ## | ||
587 | @@ -XXX,XX +XXX,XX @@ | ||
588 | 'base': { 'type': 'TpmType' }, | ||
589 | 'discriminator': 'type', | ||
590 | 'data': { 'passthrough' : 'TPMPassthroughOptionsWrapper', | ||
591 | - 'emulator': 'TPMEmulatorOptionsWrapper' }, | ||
592 | + 'emulator': 'TPMEmulatorOptionsWrapper', | ||
593 | + 'mssim' : 'TPMmssimOptions' }, | ||
594 | 'if': 'CONFIG_TPM' } | ||
595 | |||
596 | ## | ||
597 | @@ -XXX,XX +XXX,XX @@ | ||
598 | 'id' : 'str' }, | ||
599 | 'discriminator': 'type', | ||
600 | 'data': { 'passthrough' : 'TPMPassthroughOptions', | ||
601 | - 'emulator': 'TPMEmulatorOptions' }, | ||
602 | + 'emulator': 'TPMEmulatorOptions', | ||
603 | + 'mssim': 'TPMmssimOptions' }, | ||
604 | 'if': 'CONFIG_TPM' } | ||
605 | |||
606 | ## | ||
607 | -- | 663 | -- |
608 | 2.35.3 | 664 | 2.35.3 | diff view generated by jsdifflib |