linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Kent Yoder <key@linux.vnet.ibm.com>
Cc: Peter.Huewe@infineon.com, linux-kernel@vger.kernel.org,
	tpmdd-devel@lists.sourceforge.net
Subject: Re: [tpmdd-devel] [PATCH] TPM: Issue TPM_STARTUP at driver load if the TPM has not been started
Date: Mon, 1 Oct 2012 11:39:08 -0600	[thread overview]
Message-ID: <20121001173908.GA22342@obsidianresearch.com> (raw)
In-Reply-To: <20121001171003.GA1117@ennui.austin.ibm.com>

On Mon, Oct 01, 2012 at 12:10:03PM -0500, Kent Yoder wrote:

> > I'm not familiar enough with how the power management flow works with
> > the TPM to do this. I don't think that can be the general case
> > because:
> > 
> > 3. If stType = TPM_ST_STATE
> >   a. If the TPM has no state to restore, the TPM MUST set the internal
> >      state such that it returns TPM_FAILEDSELFTEST to all subsequent
> >      commands.
> > 
> > So you need to know a save state exists in the TPM before attempting
> > the command?
> 
>  Presumably we'd have called TPM_SaveState on suspend. It might be
> possible to set a flag based on whether we needed to call startup at
> init time that tells the driver to call save/restore state during
> suspend/resume.

Curiously the current code does call TPM_SaveState on suspend, but
relies on the BIOS to do TPM_Startup(ST_STATE) on resume, why the
asymmetry?

Anyhow, I think the thing would be something like this. I have no
means to test TPM suspend, so I'll just post this as a note here. It
will apply over v2 of my patch.

diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index b13ad77..7a8136a 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1336,10 +1336,23 @@ EXPORT_SYMBOL_GPL(tpm_pm_suspend);
 int tpm_pm_resume(struct device *dev)
 {
        struct tpm_chip *chip = dev_get_drvdata(dev);
+       struct tpm_cmd_t tpm_cmd;
 
        if (chip == NULL)
                return -ENODEV;
 
+       tpm_cmd.header.in = tpm_getcap_header;
+       tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
+       tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
+       tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
+       rc = transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0);
+       if (rc == TPM_ERR_INVALID_POSTINIT) {
+               /* The BIOS did not restart the TPM, execute a startup
+                  command. */
+               dev_info(chip->dev, "Issuing TPM_STARTUP");
+               tpm_startup(chip, TPM_ST_STATE);
+       }
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(tpm_pm_resume);

Jason

  reply	other threads:[~2012-10-01 17:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-30 23:30 [PATCH] TPM: Issue TPM_STARTUP at driver load if the TPM has not been started Jason Gunthorpe
2012-10-01  9:17 ` [tpmdd-devel] " Peter.Huewe
2012-10-01 16:15   ` Jason Gunthorpe
2012-10-01 17:10     ` Kent Yoder
2012-10-01 17:39       ` Jason Gunthorpe [this message]
2012-10-04 17:41         ` Kent Yoder
2012-10-04 18:02           ` Jason Gunthorpe
2012-10-08  7:09           ` Peter.Huewe
2012-11-21  7:10             ` [PATCH resend] " Jason Gunthorpe
2012-11-21  8:59               ` Peter.Huewe
2012-11-21 17:29                 ` Jason Gunthorpe
2012-11-21 17:37                   ` Peter.Huewe
2012-11-21 18:37                     ` [PATCH v4] " Jason Gunthorpe
2012-11-21 20:17                       ` Peter Hüwe
2012-11-21 20:12                         ` Jason Gunthorpe
2012-11-21 20:54                         ` [PATCH v5] " Jason Gunthorpe
2012-11-26 20:08                           ` Kent Yoder
2012-10-01 15:14 ` [PATCH] " Kent Yoder
     [not found] <4347_1349050738_q910IviQ005340_20120930233012.GH30637@obsidianresearch.com>
2012-10-01 12:57 ` [tpmdd-devel] " Jonathan McCune
2012-10-01 15:15   ` Peter.Huewe

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=20121001173908.GA22342@obsidianresearch.com \
    --to=jgunthorpe@obsidianresearch.com \
    --cc=Peter.Huewe@infineon.com \
    --cc=key@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).