aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-03-04 15:56:07 +0000
committerPeter Maydell <peter.maydell@linaro.org>2019-03-04 15:56:08 +0000
commit88687719c8859bf98ed94ce91612608c99c51c1a (patch)
treee193cc9693d2b7a1a683c59769285d3f72103d7e
parent1ba530a4ecba6015d52d8f392fd327cfa07bc37a (diff)
parentcd38cc519b60bbe5dd8d85f6aaa72b2d7902930b (diff)
Merge remote-tracking branch 'remotes/stefanberger/tags/pull-tpm-2019-02-25-1' into staging
Merge tpm 2029/02/25 v1 # gpg: Signature made Mon 25 Feb 2019 15:05:12 GMT # gpg: using RSA key 75AD65802A0B4211 # gpg: Good signature from "Stefan Berger <stefanb@linux.vnet.ibm.com>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: B818 B9CA DF90 89C2 D5CE C66B 75AD 6580 2A0B 4211 * remotes/stefanberger/tags/pull-tpm-2019-02-25-1: tpm_tis: convert tpm_tis_show_buffer() to use trace event tpm_tis: fix loop that cancels any seizure by a lower locality Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--hw/tpm/tpm_tis.c33
-rw-r--r--hw/tpm/trace-events1
2 files changed, 21 insertions, 13 deletions
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index fd6bb9b59a..fd183e8deb 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -106,17 +106,26 @@ static uint8_t tpm_tis_locality_from_addr(hwaddr addr)
static void tpm_tis_show_buffer(const unsigned char *buffer,
size_t buffer_size, const char *string)
{
- uint32_t len, i;
+ size_t len, i;
+ char *line_buffer, *p;
len = MIN(tpm_cmd_get_size(buffer), buffer_size);
- printf("tpm_tis: %s length = %d\n", string, len);
- for (i = 0; i < len; i++) {
+
+ /*
+ * allocate enough room for 3 chars per buffer entry plus a
+ * newline after every 16 chars and a final null terminator.
+ */
+ line_buffer = g_malloc(len * 3 + (len / 16) + 1);
+
+ for (i = 0, p = line_buffer; i < len; i++) {
if (i && !(i % 16)) {
- printf("\n");
+ p += sprintf(p, "\n");
}
- printf("%.2X ", buffer[i]);
+ p += sprintf(p, "%.2X ", buffer[i]);
}
- printf("\n");
+ trace_tpm_tis_show_buffer(string, len, line_buffer);
+
+ g_free(line_buffer);
}
/*
@@ -143,9 +152,8 @@ static void tpm_tis_sts_set(TPMLocality *l, uint32_t flags)
*/
static void tpm_tis_tpm_send(TPMState *s, uint8_t locty)
{
- if (DEBUG_TIS) {
- tpm_tis_show_buffer(s->buffer, s->be_buffer_size,
- "tpm_tis: To TPM");
+ if (trace_event_get_state_backends(TRACE_TPM_TIS_SHOW_BUFFER)) {
+ tpm_tis_show_buffer(s->buffer, s->be_buffer_size, "To TPM");
}
/*
@@ -313,9 +321,8 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret)
s->loc[locty].state = TPM_TIS_STATE_COMPLETION;
s->rw_offset = 0;
- if (DEBUG_TIS) {
- tpm_tis_show_buffer(s->buffer, s->be_buffer_size,
- "tpm_tis: From TPM");
+ if (trace_event_get_state_backends(TRACE_TPM_TIS_SHOW_BUFFER)) {
+ tpm_tis_show_buffer(s->buffer, s->be_buffer_size, "From TPM");
}
if (TPM_TIS_IS_VALID_LOCTY(s->next_locty)) {
@@ -624,7 +631,7 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
}
/* cancel any seize by a lower locality */
- for (l = 0; l < locty - 1; l++) {
+ for (l = 0; l < locty; l++) {
s->loc[l].access &= ~TPM_TIS_ACCESS_SEIZE;
}
diff --git a/hw/tpm/trace-events b/hw/tpm/trace-events
index 920d32ad55..f45dcd2209 100644
--- a/hw/tpm/trace-events
+++ b/hw/tpm/trace-events
@@ -36,6 +36,7 @@ tpm_emulator_pre_save(void) ""
tpm_emulator_inst_init(void) ""
# hw/tpm/tpm_tis.c
+tpm_tis_show_buffer(const char *direction, size_t len, const char *buf) "direction: %s len: %zu\nbuf: %s"
tpm_tis_raise_irq(uint32_t irqmask) "Raising IRQ for flag 0x%08x"
tpm_tis_new_active_locality(uint8_t locty) "Active locality is now %d"
tpm_tis_abort(uint8_t locty) "New active locality is %d"