summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/qemu/qemu/0002-tpm-Clean-up-model-registration-lookup.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/qemu/qemu/0002-tpm-Clean-up-model-registration-lookup.patch')
-rw-r--r--meta/recipes-devtools/qemu/qemu/0002-tpm-Clean-up-model-registration-lookup.patch121
1 files changed, 0 insertions, 121 deletions
diff --git a/meta/recipes-devtools/qemu/qemu/0002-tpm-Clean-up-model-registration-lookup.patch b/meta/recipes-devtools/qemu/qemu/0002-tpm-Clean-up-model-registration-lookup.patch
deleted file mode 100644
index c223ba83b6..0000000000
--- a/meta/recipes-devtools/qemu/qemu/0002-tpm-Clean-up-model-registration-lookup.patch
+++ /dev/null
@@ -1,121 +0,0 @@
1From 89430c64784484214b3c99562520cdffe79cd801 Mon Sep 17 00:00:00 2001
2From: Markus Armbruster <armbru@redhat.com>
3Date: Thu, 24 Aug 2017 10:45:59 +0200
4Subject: [PATCH 02/12] tpm: Clean up model registration & lookup
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9We have a strict separation between enum TpmModel and tpm_models[]:
10
11* TpmModel may have any number of members. It just happens to have one.
12
13* tpm_register_model() uses the first empty slot in tpm_models[].
14
15 If you register more than tpm_models[] has space,
16 tpn_register_model() fails. Its caller silently ignores the
17 failure.
18
19 Register the same TpmModel more than once has no effect other than
20 wasting tpm_models[] slots: tpm_model_is_registered() is happy with
21 the first one it finds.
22
23Since we only ever register one model, and tpm_models[] has space for
24just that one, this contraption even works.
25
26Turn tpm_models[] into a straight map from enum TpmType to bool. Much
27simpler.
28
29Cc: Stefan Berger <stefanb@us.ibm.com>
30Signed-off-by: Markus Armbruster <armbru@redhat.com>
31Message-Id: <1503564371-26090-5-git-send-email-armbru@redhat.com>
32Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
33[Commit message typo fixed]
34
35Upstream-Status: Backport
36---
37 include/sysemu/tpm_backend.h | 2 +-
38 tpm.c | 37 +++++--------------------------------
39 2 files changed, 6 insertions(+), 33 deletions(-)
40
41diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h
42index 1d21c6b19b..b0a9731aee 100644
43--- a/include/sysemu/tpm_backend.h
44+++ b/include/sysemu/tpm_backend.h
45@@ -226,7 +226,7 @@ TPMVersion tpm_backend_get_tpm_version(TPMBackend *s);
46 TPMBackend *qemu_find_tpm(const char *id);
47
48 const TPMDriverOps *tpm_get_backend_driver(const char *type);
49-int tpm_register_model(enum TpmModel model);
50+void tpm_register_model(enum TpmModel model);
51 void tpm_register_driver(const TPMDriverOps *tdo);
52
53 #endif
54diff --git a/tpm.c b/tpm.c
55index bb45d0c08e..2dbea70645 100644
56--- a/tpm.c
57+++ b/tpm.c
58@@ -24,39 +24,12 @@
59 static QLIST_HEAD(, TPMBackend) tpm_backends =
60 QLIST_HEAD_INITIALIZER(tpm_backends);
61
62-
63-#define TPM_MAX_MODELS 1
64-
65 static TPMDriverOps const *be_drivers[TPM_TYPE__MAX];
66+static bool tpm_models[TPM_MODEL__MAX];
67
68-static enum TpmModel tpm_models[TPM_MAX_MODELS] = {
69- TPM_MODEL__MAX,
70-};
71-
72-int tpm_register_model(enum TpmModel model)
73-{
74- int i;
75-
76- for (i = 0; i < TPM_MAX_MODELS; i++) {
77- if (tpm_models[i] == TPM_MODEL__MAX) {
78- tpm_models[i] = model;
79- return 0;
80- }
81- }
82- error_report("Could not register TPM model");
83- return 1;
84-}
85-
86-static bool tpm_model_is_registered(enum TpmModel model)
87+void tpm_register_model(enum TpmModel model)
88 {
89- int i;
90-
91- for (i = 0; i < TPM_MAX_MODELS; i++) {
92- if (tpm_models[i] == model) {
93- return true;
94- }
95- }
96- return false;
97+ tpm_models[model] = true;
98 }
99
100 const TPMDriverOps *tpm_get_backend_driver(const char *type)
101@@ -270,7 +243,7 @@ TPMInfoList *qmp_query_tpm(Error **errp)
102 TPMInfoList *info, *head = NULL, *cur_item = NULL;
103
104 QLIST_FOREACH(drv, &tpm_backends, list) {
105- if (!tpm_model_is_registered(drv->fe_model)) {
106+ if (!tpm_models[drv->fe_model]) {
107 continue;
108 }
109 info = g_new0(TPMInfoList, 1);
110@@ -317,7 +290,7 @@ TpmModelList *qmp_query_tpm_models(Error **errp)
111 TpmModelList *head = NULL, *prev = NULL, *cur_item;
112
113 for (i = 0; i < TPM_MODEL__MAX; i++) {
114- if (!tpm_model_is_registered(i)) {
115+ if (!tpm_models[i]) {
116 continue;
117 }
118 cur_item = g_new0(TpmModelList, 1);
119--
1202.11.0
121