mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: "tpmdd-devel@lists.sourceforge.net" 
	<tpmdd-devel@lists.sourceforge.net>,
	James Morris <jmorris@namei.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Rajiv Andrade <srajiv@linux.vnet.ibm.com>,
	m.selhorst@sirrix.com
Cc: a.miskiewicz@gmail.com
Subject: [PATCH] Refuse activation of tpm_tis driver if TPM is not working correctly
Date: Mon, 10 Oct 2011 08:16:45 -0400	[thread overview]
Message-ID: <1318249005.5482.5.camel@d941e-10> (raw)

Refuse activation of tpm_tis driver if the TPM is found not to be
working correctly. This prevents suspend/resume problems for me on
Lenovo W500 and T61p.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

---
 drivers/char/tpm/tpm_tis.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 3f4051a..7f2761d 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -549,6 +549,7 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
 	u32 vendor, intfcaps, intmask;
 	int rc, i, irq_s, irq_e;
 	struct tpm_chip *chip;
+	u8 digest[TPM_DIGEST_SIZE];
 
 	if (!(chip = tpm_register_hardware(dev, &tpm_tis)))
 		return -ENODEV;
@@ -616,6 +617,18 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
 	/* get the timeouts before testing for irqs */
 	tpm_get_timeouts(chip);
 
+	/* test for correctly working TPM; refuse driver if not working 
+	   to prevent suspend/resume problems */
+	rc = tpm_pcr_read(chip->dev_num, 0, digest);
+	if (rc != 0) {
+		dev_err(dev, "Could not read PCR 0. "
+			"TPM is not working correctly.\n");
+		dev_err(dev, "Was machine previously suspended without TPM "
+			"driver present?\n");
+		rc = -ENODEV;
+		goto out_err;
+	}
+
 	/* INTERRUPT Setup */
 	init_waitqueue_head(&chip->vendor.read_queue);
 	init_waitqueue_head(&chip->vendor.int_queue);
-- 
1.7.6.4



             reply	other threads:[~2011-10-10 12:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10 12:16 Stefan Berger [this message]
2011-10-10 13:04 ` Rajiv Andrade
2011-10-10 15:07   ` [tpmdd-devel] " Rajiv Andrade

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=1318249005.5482.5.camel@d941e-10 \
    --to=stefanb@linux.vnet.ibm.com \
    --cc=a.miskiewicz@gmail.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.selhorst@sirrix.com \
    --cc=srajiv@linux.vnet.ibm.com \
    --cc=tpmdd-devel@lists.sourceforge.net \
    /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®