From: Kylene Hall <kjhall@us.ibm.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] tpm: improve output in sysfs files when the TPM fails
Date: Thu, 12 May 2005 17:20:22 -0500 (CDT) [thread overview]
Message-ID: <Pine.LNX.4.62.0505121717240.11837@localhost.localdomain> (raw)
When the TPM is in a disabled or deactivated state the sysfs pcrs and
pubek files will appear empty. To remove any confusion this might cause,
the files will instead contain the error the TPM returned (also indicative
of what state the TPM is in and what actions might be needed to change
that state).
Signed-off-by: Kylene Hall <kjhall@us.ibm.com>
---
diff -uprN linux-2.6.12-rc3/drivers/char/tpm/tpm.c /home/kylie/kernel/linux-2.6.12-rc3-tpmdd/drivers/char/tpm/tpm.c
--- linux-2.6.12-rc3/drivers/char/tpm/tpm.c 2005-05-12 18:03:43.000000000 -0500
+++ /home/kylie/kernel/linux-2.6.12-rc3-tpmdd/drivers/char/tpm/tpm.c 2005-05-12 17:40:26.000000000 -0500
@@ -212,8 +183,11 @@ ssize_t tpm_show_pcrs(struct device *dev
memcpy(data, cap_pcr, sizeof(cap_pcr));
if ((len = tpm_transmit(chip, data, sizeof(data)))
- < CAP_PCR_RESULT_SIZE)
- return len;
+ < CAP_PCR_RESULT_SIZE) {
+ str += sprintf( str, "TPM ERROR: %d\n",
+ be32_to_cpu(*((__be32 *) (data + 6))));
+ goto out;
+ }
num_pcrs = be32_to_cpu(*((__be32 *) (data + 14)));
@@ -222,13 +196,17 @@ ssize_t tpm_show_pcrs(struct device *dev
index = cpu_to_be32(i);
memcpy(data + 10, &index, 4);
if ((len = tpm_transmit(chip, data, sizeof(data)))
- < READ_PCR_RESULT_SIZE)
- return len;
+ < READ_PCR_RESULT_SIZE){
+ str += sprintf( str, "TPM ERROR: %d\n",
+ be32_to_cpu(*((__be32 *) (data + 6))));
+ goto out;
+ }
str += sprintf(str, "PCR-%02d: ", i);
for (j = 0; j < TPM_DIGEST_SIZE; j++)
str += sprintf(str, "%02X ", *(data + 10 + j));
str += sprintf(str, "\n");
}
+out:
return str - buf;
}
@@ -262,7 +240,8 @@ ssize_t tpm_show_pubek(struct device *de
if ((len = tpm_transmit(chip, data, READ_PUBEK_RESULT_SIZE)) <
READ_PUBEK_RESULT_SIZE) {
- rc = len;
+ str += sprintf( str, "TPM ERROR: %d\n",
+ be32_to_cpu(*((__be32 *) (data + 6))));
goto out;
}
@@ -294,8 +273,8 @@ ssize_t tpm_show_pubek(struct device *de
if ((i + 1) % 16 == 0)
str += sprintf(str, "\n");
}
- rc = str - buf;
out:
+ rc = str - buf;
kfree(data);
return rc;
}
next reply other threads:[~2005-05-12 22:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-12 22:20 Kylene Hall [this message]
2005-05-12 22:55 ` Greg KH
2005-05-13 19:25 ` Kylene Hall
2005-05-14 5:30 ` Andrew Morton
2005-05-16 17:33 ` Kylene Hall
2005-06-14 15:00 ` Kylene Jo Hall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.62.0505121717240.11837@localhost.localdomain \
--to=kjhall@us.ibm.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®