diff mbox

[v3,02/13] tpm_tis: limit size of buffer from backend

Message ID 1510323112-2207-3-git-send-email-stefanb@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Berger Nov. 10, 2017, 2:11 p.m. UTC
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>
---
 hw/tpm/tpm_tis.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Marc-André Lureau Dec. 21, 2017, 2:11 p.m. UTC | #1
On Fri, Nov 10, 2017 at 3:11 PM, Stefan Berger
<stefanb@linux.vnet.ibm.com> wrote:
> 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 | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 69fe531..90c6df2 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -1008,7 +1008,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);
>
> @@ -1040,7 +1041,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 = {
> --
> 2.5.5
>
>
diff mbox

Patch

diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 69fe531..90c6df2 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -1008,7 +1008,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);
 
@@ -1040,7 +1041,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 = {