Depends-on: <[email protected]>
hw/tpm/tpm_tis.h | 6 ++++-
hw/tpm/tpm_tis_common.c | 56 +++++++++++++++++++++++++++++++++++------
hw/tpm/tpm_tis_i2c.c | 28 +++++++++++++++++++--
hw/tpm/tpm_tis_isa.c | 31 +++++++++++++++++++++--
hw/tpm/tpm_tis_sysbus.c | 32 +++++++++++++++++++++--
5 files changed, 138 insertions(+), 15 deletions(-)
diff --git a/hw/tpm/tpm_tis.h b/hw/tpm/tpm_tis.h
index b2d9c0116c..c736ecedc1 100644
--- a/hw/tpm/tpm_tis.h
+++ b/hw/tpm/tpm_tis.h
@@ -56,7 +56,9 @@ typedef struct TPMLocality {
typedef struct TPMState {
MemoryRegion mmio;
- unsigned char buffer[TPM_TIS_BUFFER_MAX];
+ uint8_t *buffer;
+ uint8_t *ext_buffer;
+ uint32_t ext_size;
uint16_t rw_offset;
uint8_t active_locty;
@@ -82,6 +84,8 @@ extern const VMStateDescription vmstate_locty;
extern const MemoryRegionOps tpm_tis_memory_ops;
int tpm_tis_pre_save(TPMState *s);
+int tpm_tis_post_load(TPMState *s);
+int tpm_tis_ext_buffer_post_load(TPMState *s);
void tpm_tis_reset(TPMState *s, bool ppi_enabled);
enum TPMVersion tpm_tis_get_tpm_version(TPMState *s);
void tpm_tis_request_completed(TPMState *s, int ret);
diff --git a/hw/tpm/tpm_tis_common.c b/hw/tpm/tpm_tis_common.c
index 43e68410f8..c9c4dd1190 100644
--- a/hw/tpm/tpm_tis_common.c
+++ b/hw/tpm/tpm_tis_common.c
@@ -270,7 +270,7 @@ static uint32_t tpm_tis_data_read(TPMState *s, uint8_t
locty)
uint16_t len;
if ((s->loc[locty].sts & TPM_TIS_STS_DATA_AVAILABLE)) {
- len = MIN(tpm_cmd_get_size(&s->buffer),
+ len = MIN(tpm_cmd_get_size(s->buffer),
s->be_buffer_size);
ret = s->buffer[s->rw_offset++];
@@ -317,7 +317,7 @@ static void tpm_tis_dump_state(TPMState *s, hwaddr addr)
"tpm_tis: result buffer : ",
s->rw_offset);
for (idx = 0;
- idx < MIN(tpm_cmd_get_size(&s->buffer), s->be_buffer_size);
+ idx < MIN(tpm_cmd_get_size(s->buffer), s->be_buffer_size);
idx++) {
printf("%c%02x%s",
s->rw_offset == idx ? '>' : ' ',
@@ -383,7 +383,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr,
if (s->active_locty == locty) {
if ((s->loc[locty].sts & TPM_TIS_STS_DATA_AVAILABLE)) {
val = TPM_TIS_BURST_COUNT(
- MIN(tpm_cmd_get_size(&s->buffer),
+ MIN(tpm_cmd_get_size(s->buffer),
s->be_buffer_size)
- s->rw_offset) | s->loc[locty].sts;
} else {
@@ -754,7 +754,7 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
/* we have a packet length - see if we have all of it */
bool need_irq = !(s->loc[locty].sts & TPM_TIS_STS_VALID);
- len = tpm_cmd_get_size(&s->buffer);
+ len = tpm_cmd_get_size(s->buffer);
if (len > s->rw_offset) {
tpm_tis_sts_set(&s->loc[locty],
TPM_TIS_STS_EXPECT | TPM_TIS_STS_VALID);
@@ -818,9 +818,10 @@ void tpm_tis_reset(TPMState *s, bool ppi_enabled)
int c;
s->be_tpm_version = tpm_backend_get_tpm_version(s->be_driver);
- s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->be_driver),
- TPM_TIS_BUFFER_MAX);
+ s->be_buffer_size = tpm_backend_get_buffer_size(s->be_driver);
+ s->buffer = g_realloc(s->buffer, MAX(s->be_buffer_size,
+ TPM_TIS_BUFFER_MAX));