Message ID | 1510323112-2207-9-git-send-email-stefanb@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
Series | tpm: Extend TPM with state migration support (not 2.11) | expand |
On Fri, Nov 10, 2017 at 3:11 PM, Stefan Berger <stefanb@linux.vnet.ibm.com> wrote: > Move the definition of TPMSizedBuffer out of tpm_tis.c into tpm_util.h > and implement tpm_sized_buffer_reset() for the following patches to use. > > Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Or maybe it's time to use qemu Buffer or glib GArray... could be done later so, Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > hw/tpm/tpm_tis.c | 5 ----- > hw/tpm/tpm_util.c | 7 +++++++ > hw/tpm/tpm_util.h | 7 +++++++ > 3 files changed, 14 insertions(+), 5 deletions(-) > > diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c > index 7d7e2cd..035c6ef 100644 > --- a/hw/tpm/tpm_tis.c > +++ b/hw/tpm/tpm_tis.c > @@ -48,11 +48,6 @@ typedef enum { > TPM_TIS_STATE_RECEPTION, > } TPMTISState; > > -typedef struct TPMSizedBuffer { > - uint32_t size; > - uint8_t *buffer; > -} TPMSizedBuffer; > - > /* locality data -- all fields are persisted */ > typedef struct TPMLocality { > TPMTISState state; > diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c > index a317243..bf97811 100644 > --- a/hw/tpm/tpm_util.c > +++ b/hw/tpm/tpm_util.c > @@ -288,3 +288,10 @@ int tpm_util_get_buffer_size(int tpm_fd, TPMVersion tpm_version, > > return 0; > } > + > +void tpm_sized_buffer_reset(TPMSizedBuffer *tsb) > +{ > + g_free(tsb->buffer); > + tsb->buffer = NULL; > + tsb->size = 0; > +} > diff --git a/hw/tpm/tpm_util.h b/hw/tpm/tpm_util.h > index 1c17e39..26c9613 100644 > --- a/hw/tpm/tpm_util.h > +++ b/hw/tpm/tpm_util.h > @@ -39,4 +39,11 @@ static inline uint32_t tpm_cmd_get_size(const void *b) > int tpm_util_get_buffer_size(int tpm_fd, TPMVersion tpm_version, > size_t *buffersize); > > +typedef struct TPMSizedBuffer { > + uint32_t size; > + uint8_t *buffer; > +} TPMSizedBuffer; > + > +void tpm_sized_buffer_reset(TPMSizedBuffer *tsb); > + > #endif /* TPM_TPM_UTIL_H */ > -- > 2.5.5 > >
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c index 7d7e2cd..035c6ef 100644 --- a/hw/tpm/tpm_tis.c +++ b/hw/tpm/tpm_tis.c @@ -48,11 +48,6 @@ typedef enum { TPM_TIS_STATE_RECEPTION, } TPMTISState; -typedef struct TPMSizedBuffer { - uint32_t size; - uint8_t *buffer; -} TPMSizedBuffer; - /* locality data -- all fields are persisted */ typedef struct TPMLocality { TPMTISState state; diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c index a317243..bf97811 100644 --- a/hw/tpm/tpm_util.c +++ b/hw/tpm/tpm_util.c @@ -288,3 +288,10 @@ int tpm_util_get_buffer_size(int tpm_fd, TPMVersion tpm_version, return 0; } + +void tpm_sized_buffer_reset(TPMSizedBuffer *tsb) +{ + g_free(tsb->buffer); + tsb->buffer = NULL; + tsb->size = 0; +} diff --git a/hw/tpm/tpm_util.h b/hw/tpm/tpm_util.h index 1c17e39..26c9613 100644 --- a/hw/tpm/tpm_util.h +++ b/hw/tpm/tpm_util.h @@ -39,4 +39,11 @@ static inline uint32_t tpm_cmd_get_size(const void *b) int tpm_util_get_buffer_size(int tpm_fd, TPMVersion tpm_version, size_t *buffersize); +typedef struct TPMSizedBuffer { + uint32_t size; + uint8_t *buffer; +} TPMSizedBuffer; + +void tpm_sized_buffer_reset(TPMSizedBuffer *tsb); + #endif /* TPM_TPM_UTIL_H */
Move the definition of TPMSizedBuffer out of tpm_tis.c into tpm_util.h and implement tpm_sized_buffer_reset() for the following patches to use. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com> --- hw/tpm/tpm_tis.c | 5 ----- hw/tpm/tpm_util.c | 7 +++++++ hw/tpm/tpm_util.h | 7 +++++++ 3 files changed, 14 insertions(+), 5 deletions(-)