tpm_tis: limit size of buffer from backend
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Fri, 10 Nov 2017 00:24:02 +0000 (19:24 -0500)
committerStefan Berger <stefanb@linux.vnet.ibm.com>
Fri, 22 Dec 2017 14:01:09 +0000 (09:01 -0500)
This is a preparatory patch for the subsequent ones where we
get rid of the flexibility of supporting any kind of buffer size
that the backend may support. We keep the size at 4096, which is
also the size the external emulator supports. So, limit the size
of the buffer we can support and pass it back to the backend.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
hw/tpm/tpm_tis.c

index ac5f51f108e29c3628828e6ecf0c8be82a6343f2..a6e2f6eb6c2ce07530d0f67e28e6e2a2f45c2fe0 100644 (file)
@@ -1012,7 +1012,8 @@ static void tpm_tis_reset(DeviceState *dev)
     int c;
 
     s->be_tpm_version = tpm_backend_get_tpm_version(s->be_driver);
-    s->be_buffer_size = tpm_backend_get_buffer_size(s->be_driver);
+    s->be_buffer_size = MIN(tpm_backend_get_buffer_size(s->be_driver),
+                            TPM_TIS_BUFFER_MAX);
 
     tpm_backend_reset(s->be_driver);
 
@@ -1044,7 +1045,7 @@ static void tpm_tis_reset(DeviceState *dev)
         tpm_tis_realloc_buffer(&s->loc[c].r_buffer, s->be_buffer_size);
     }
 
-    tpm_tis_do_startup_tpm(s, 0);
+    tpm_tis_do_startup_tpm(s, s->be_buffer_size);
 }
 
 static const VMStateDescription vmstate_tpm_tis = {