qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

hw/tpm: Make TRACE_TPM_UTIL_SHOW_BUFFER check local to tpm_util.c

The trace_event_get_state_backends() call is useful to avoid
making extensive calls (usually preparing arguments passed to
the tracing framework. In this case, the extensive work is
done in tpm_util_show_buffer(), and the arguments used to
call it don't involve extra processing. Simplify by moving
the TRACE_TPM_UTIL_SHOW_BUFFER check to tpm_util_show_buffer.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Message-id: 20200612085444.8362-9-philmd@redhat.com
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

authored by

Philippe Mathieu-Daudé and committed by
Stefan Berger
f670a562 68072565

+5 -6
+2 -6
hw/tpm/tpm_tis_common.c
··· 78 78 */ 79 79 static void tpm_tis_tpm_send(TPMState *s, uint8_t locty) 80 80 { 81 - if (trace_event_get_state_backends(TRACE_TPM_UTIL_SHOW_BUFFER)) { 82 - tpm_util_show_buffer(s->buffer, s->be_buffer_size, "To TPM"); 83 - } 81 + tpm_util_show_buffer(s->buffer, s->be_buffer_size, "To TPM"); 84 82 85 83 /* 86 84 * rw_offset serves as length indicator for length of data; ··· 246 244 s->loc[locty].state = TPM_TIS_STATE_COMPLETION; 247 245 s->rw_offset = 0; 248 246 249 - if (trace_event_get_state_backends(TRACE_TPM_UTIL_SHOW_BUFFER)) { 250 - tpm_util_show_buffer(s->buffer, s->be_buffer_size, "From TPM"); 251 - } 247 + tpm_util_show_buffer(s->buffer, s->be_buffer_size, "From TPM"); 252 248 253 249 if (TPM_TIS_IS_VALID_LOCTY(s->next_locty)) { 254 250 tpm_tis_abort(s);
+3
hw/tpm/tpm_util.c
··· 357 357 size_t len, i; 358 358 char *line_buffer, *p; 359 359 360 + if (!trace_event_get_state_backends(TRACE_TPM_UTIL_SHOW_BUFFER)) { 361 + return; 362 + } 360 363 len = MIN(tpm_cmd_get_size(buffer), buffer_size); 361 364 362 365 /*