From: Amarnath Valluri <amarnath.valluri@intel.com>
To: qemu-devel@nongnu.org
Cc: "Stefan Berger" <stefanb@linux.vnet.ibm.com>,
"Marc-André Lureau" <marcandre.lureau@gmail.com>,
"Amarnath Valluri" <amarnath.valluri@intel.com>
Subject: [Qemu-devel] [PATCH v7 6/8] tpm-backend: Move realloc_buffer() implementation to tpm-tis model
Date: Fri, 22 Sep 2017 15:33:42 +0300 [thread overview]
Message-ID: <1506083624-20621-7-git-send-email-amarnath.valluri@intel.com> (raw)
In-Reply-To: <1506083624-20621-1-git-send-email-amarnath.valluri@intel.com>
buffer reallocation is very unlikely to be backend specific. Hence move inside
the tis.
Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
backends/tpm.c | 9 ---------
hw/tpm/tpm_passthrough.c | 12 ------------
hw/tpm/tpm_tis.c | 14 ++++++++++++--
include/sysemu/tpm_backend.h | 12 ------------
4 files changed, 12 insertions(+), 35 deletions(-)
diff --git a/backends/tpm.c b/backends/tpm.c
index 6ade9e4..ffc9d88 100644
--- a/backends/tpm.c
+++ b/backends/tpm.c
@@ -78,15 +78,6 @@ bool tpm_backend_had_startup_error(TPMBackend *s)
return k->ops->had_startup_error(s);
}
-size_t tpm_backend_realloc_buffer(TPMBackend *s, TPMSizedBuffer *sb)
-{
- TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
-
- assert(k->ops->realloc_buffer);
-
- return k->ops->realloc_buffer(sb);
-}
-
void tpm_backend_deliver_request(TPMBackend *s)
{
g_thread_pool_push(s->thread_pool, (gpointer)TPM_BACKEND_CMD_PROCESS_CMD,
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index fb7dad8..82e7003 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -258,17 +258,6 @@ static bool tpm_passthrough_get_startup_error(TPMBackend *tb)
return tpm_pt->had_startup_error;
}
-static size_t tpm_passthrough_realloc_buffer(TPMSizedBuffer *sb)
-{
- size_t wanted_size = 4096; /* Linux tpm.c buffer size */
-
- if (sb->size != wanted_size) {
- sb->buffer = g_realloc(sb->buffer, wanted_size);
- sb->size = wanted_size;
- }
- return sb->size;
-}
-
static void tpm_passthrough_cancel_cmd(TPMBackend *tb)
{
TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb);
@@ -460,7 +449,6 @@ static const TPMDriverOps tpm_passthrough_driver = {
.opts = tpm_passthrough_cmdline_opts,
.desc = "Passthrough TPM backend driver",
.create = tpm_passthrough_create,
- .realloc_buffer = tpm_passthrough_realloc_buffer,
.reset = tpm_passthrough_reset,
.had_startup_error = tpm_passthrough_get_startup_error,
.cancel_cmd = tpm_passthrough_cancel_cmd,
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index a6440fe..d5118e7 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -963,6 +963,16 @@ static int tpm_tis_do_startup_tpm(TPMState *s)
return tpm_backend_startup_tpm(s->be_driver);
}
+static void tpm_tis_realloc_buffer(TPMSizedBuffer *sb)
+{
+ size_t wanted_size = 4096; /* Linux tpm.c buffer size */
+
+ if (sb->size != wanted_size) {
+ sb->buffer = g_realloc(sb->buffer, wanted_size);
+ sb->size = wanted_size;
+ }
+}
+
/*
* Get the TPMVersion of the backend device being used
*/
@@ -1010,9 +1020,9 @@ static void tpm_tis_reset(DeviceState *dev)
tis->loc[c].state = TPM_TIS_STATE_IDLE;
tis->loc[c].w_offset = 0;
- tpm_backend_realloc_buffer(s->be_driver, &tis->loc[c].w_buffer);
+ tpm_tis_realloc_buffer(&tis->loc[c].w_buffer);
tis->loc[c].r_offset = 0;
- tpm_backend_realloc_buffer(s->be_driver, &tis->loc[c].r_buffer);
+ tpm_tis_realloc_buffer(&tis->loc[c].r_buffer);
}
tpm_tis_do_startup_tpm(s);
diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h
index 809eec2..6163edf 100644
--- a/include/sysemu/tpm_backend.h
+++ b/include/sysemu/tpm_backend.h
@@ -85,8 +85,6 @@ struct TPMDriverOps {
/* returns true if nothing will ever answer TPM requests */
bool (*had_startup_error)(TPMBackend *t);
- size_t (*realloc_buffer)(TPMSizedBuffer *sb);
-
void (*reset)(TPMBackend *t);
void (*cancel_cmd)(TPMBackend *t);
@@ -141,16 +139,6 @@ int tpm_backend_startup_tpm(TPMBackend *s);
bool tpm_backend_had_startup_error(TPMBackend *s);
/**
- * tpm_backend_realloc_buffer:
- * @s: the backend
- * @sb: the TPMSizedBuffer to re-allocated to the size suitable for the
- * backend.
- *
- * This function returns the size of the allocated buffer
- */
-size_t tpm_backend_realloc_buffer(TPMBackend *s, TPMSizedBuffer *sb);
-
-/**
* tpm_backend_deliver_request:
* @s: the backend to send the request to
*
--
2.7.4
next prev parent reply other threads:[~2017-09-22 12:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-22 12:33 [Qemu-devel] [PATCH v7 0/8] Provide support for the software TPM emulator Amarnath Valluri
2017-09-22 12:33 ` [Qemu-devel] [PATCH v7 1/8] tpm-backend: Remove unneeded member variable from backend class Amarnath Valluri
2017-09-22 12:33 ` [Qemu-devel] [PATCH v7 2/8] tpm-backend: Move thread handling inside TPMBackend Amarnath Valluri
2017-09-22 12:33 ` [Qemu-devel] [PATCH v7 3/8] tpm-backend: Initialize and free data members in it's own methods Amarnath Valluri
2017-09-22 12:33 ` [Qemu-devel] [PATCH v7 4/8] tpm-backend: Made few interface methods optional Amarnath Valluri
2017-09-27 12:23 ` [Qemu-devel] [PATCH v8 " Amarnath Valluri
2017-09-22 12:33 ` [Qemu-devel] [PATCH v7 5/8] tmp backend: Add new api to read backend TpmInfo Amarnath Valluri
2017-09-22 15:35 ` Marc-André Lureau
2017-09-25 12:01 ` Valluri, Amarnath
2017-09-27 12:16 ` [Qemu-devel] [PATCH v8 " Amarnath Valluri
2017-09-22 12:33 ` Amarnath Valluri [this message]
2017-09-22 12:33 ` [Qemu-devel] [PATCH v7 7/8] tpm-passthrough: move reusable code to utils Amarnath Valluri
2017-09-22 12:33 ` [Qemu-devel] [PATCH v7 8/8] tpm: Added support for TPM emulator Amarnath Valluri
2017-09-22 16:23 ` Stefan Berger
2017-09-24 18:52 ` Marc-André Lureau
2017-09-25 0:35 ` Stefan Berger
2017-09-26 12:05 ` Valluri, Amarnath
2017-09-26 12:24 ` Marc-André Lureau
2017-09-26 13:28 ` Valluri, Amarnath
2017-09-26 13:55 ` Marc-André Lureau
2017-09-26 13:59 ` Eric Blake
2017-09-27 12:18 ` [Qemu-devel] [PATCH v8 " Amarnath Valluri
2017-09-27 14:18 ` Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1506083624-20621-7-git-send-email-amarnath.valluri@intel.com \
--to=amarnath.valluri@intel.com \
--cc=marcandre.lureau@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).