All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nayna Jain <nayna@linux.vnet.ibm.com>
To: Alexander.Steffen@infineon.com
Cc: linux-integrity@vger.kernel.org, zohar@linux.vnet.ibm.com,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, peterhuewe@gmx.de,
	jarkko.sakkinen@linux.intel.com, tpmdd@selhorst.net,
	patrickc@us.ibm.com
Subject: Re: [PATCH v4 2/4] tpm: ignore burstcount to improve tpm_tis send() performance
Date: Thu, 23 Nov 2017 20:17:42 +0530	[thread overview]
Message-ID: <20171123144742.GC8862@swastik> (raw)
In-Reply-To: <3ff12c6536de4379aa61cb09ebc9d105@infineon.com>

On Wed, Nov 22, 2017 at 06:52:03AM +0000, Alexander.Steffen@infineon.com wrote:
> > > > > This seems to fail reliably with my SPI TPM 2.0. I get EIO when trying to
> > > > send large amounts of data, e.g. with TPM2_Hash, and subsequent tests
> > > > seem to take an unusual amount of time. More analysis probably has to
> > > wait
> > > > until November, since I am going to be in Prague next week.
> > > >
> > > > Thanks Alex for testing these.. Did you get the chance to do any further
> > > > analysis ?
> > >
> > > I am working on that now. Ken's suggestion seems reasonable, so I am
> > going
> > > to test whether correctly waiting for the flags to change fixes the problem.
> > If
> > > it does, I'll send the patches.
> > 
> > Sorry for the delay, I had to take care of some device tree changes in v4.14
> > that broke my ARM test machines.
> > 
> > I've implemented some patches that fix the issue that Ken pointed out and
> > rebased your patch 2/4 ("ignore burstcount") on top. While doing this I
> > noticed that your original patch does not, as the commit message says, write
> > all the bytes at once, but still unnecessarily splits all commands into at least
> > two transfers (as did the original code). I've fixed this as well in my patches,
> > so that all bytes are indeed sent in a single call, without special handling for
> > the last byte. This should speed up things further, especially for small
> > commands and drivers like tpm_tis_spi, where writing a single byte
> > translates into additional SPI transfers.

Thanks Alex, for digging into.

Yeah, you are right, the first version of this patch sent all the bytes together, but after hearing ddwg inputs,
i.e. "The last byte was introduced for error checking purposes (history).", I reverted back to original to be safe.

It seems that the last byte was sent from the beginning (27084ef [PATCH] tpm: driver for next generation TPM chips,),
does anyone remember the reason ?

> > 
> > Unfortunately, even with those changes the problem persists. But I've got
> > more detailed logs now and will try to understand and hopefully fix the issue.
> > I'll follow up with more details and/or patches once I know more.
> 
> Okay, so the problem seems to be that at some point the TPM starts inserting wait states for the FIFO access. The driver tries to handle this, but fails since even the 50 retries that are currently used do not seem to be enough. Adding small (millisecond) delays between the attempts did not help so far.
> 
> Is there any limit in the specification for how many wait states the TPM may generate or for how long it may do so? I could not find anything, but we need to use something there to prevent a faulty TPM from blocking the kernel forever.
> 

I have been thinking on this, so was wondering:

1. As you said the problem started while sending large amounts of data for TPM2_Hash, how large is "large" ? I mean did it work for some specific large values before failing.
2. Are these wait states limited to SPI, or does it happen on LPC as well?

Thanks & Regards,
   - Nayna


> Alexander
> 

WARNING: multiple messages have this Message-ID (diff)
From: nayna@linux.vnet.ibm.com (Nayna Jain)
To: linux-security-module@vger.kernel.org
Subject: [PATCH v4 2/4] tpm: ignore burstcount to improve tpm_tis send() performance
Date: Thu, 23 Nov 2017 20:17:42 +0530	[thread overview]
Message-ID: <20171123144742.GC8862@swastik> (raw)
In-Reply-To: <3ff12c6536de4379aa61cb09ebc9d105@infineon.com>

On Wed, Nov 22, 2017 at 06:52:03AM +0000, Alexander.Steffen at infineon.com wrote:
> > > > > This seems to fail reliably with my SPI TPM 2.0. I get EIO when trying to
> > > > send large amounts of data, e.g. with TPM2_Hash, and subsequent tests
> > > > seem to take an unusual amount of time. More analysis probably has to
> > > wait
> > > > until November, since I am going to be in Prague next week.
> > > >
> > > > Thanks Alex for testing these.. Did you get the chance to do any further
> > > > analysis ?
> > >
> > > I am working on that now. Ken's suggestion seems reasonable, so I am
> > going
> > > to test whether correctly waiting for the flags to change fixes the problem.
> > If
> > > it does, I'll send the patches.
> > 
> > Sorry for the delay, I had to take care of some device tree changes in v4.14
> > that broke my ARM test machines.
> > 
> > I've implemented some patches that fix the issue that Ken pointed out and
> > rebased your patch 2/4 ("ignore burstcount") on top. While doing this I
> > noticed that your original patch does not, as the commit message says, write
> > all the bytes at once, but still unnecessarily splits all commands into at least
> > two transfers (as did the original code). I've fixed this as well in my patches,
> > so that all bytes are indeed sent in a single call, without special handling for
> > the last byte. This should speed up things further, especially for small
> > commands and drivers like tpm_tis_spi, where writing a single byte
> > translates into additional SPI transfers.

Thanks Alex, for digging into.

Yeah, you are right, the first version of this patch sent all the bytes together, but after hearing ddwg inputs,
i.e. "The last byte was introduced for error checking purposes (history).", I reverted back to original to be safe.

It seems that the last byte was sent from the beginning (27084ef [PATCH] tpm: driver for next generation TPM chips,),
does anyone remember the reason ?

> > 
> > Unfortunately, even with those changes the problem persists. But I've got
> > more detailed logs now and will try to understand and hopefully fix the issue.
> > I'll follow up with more details and/or patches once I know more.
> 
> Okay, so the problem seems to be that at some point the TPM starts inserting wait states for the FIFO access. The driver tries to handle this, but fails since even the 50 retries that are currently used do not seem to be enough. Adding small (millisecond) delays between the attempts did not help so far.
> 
> Is there any limit in the specification for how many wait states the TPM may generate or for how long it may do so? I could not find anything, but we need to use something there to prevent a faulty TPM from blocking the kernel forever.
> 

I have been thinking on this, so was wondering:

1. As you said the problem started while sending large amounts of data for TPM2_Hash, how large is "large" ? I mean did it work for some specific large values before failing.
2. Are these wait states limited to SPI, or does it happen on LPC as well?

Thanks & Regards,
   - Nayna


> Alexander
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-11-23 14:48 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17 20:32 [PATCH v4 0/4] additional TPM performance improvements Nayna Jain
2017-10-17 20:32 ` Nayna Jain
2017-10-17 20:32 ` [PATCH v4 1/4] tpm: move wait_for_tpm_stat() to respective driver files Nayna Jain
2017-10-17 20:32   ` Nayna Jain
2017-10-19 14:21   ` Jarkko Sakkinen
2017-10-19 14:21     ` Jarkko Sakkinen
2017-10-19 17:00     ` Alexander.Steffen
2017-10-19 17:00       ` Alexander.Steffen at infineon.com
2017-10-20  8:56       ` Jarkko Sakkinen
2017-10-20  8:56         ` Jarkko Sakkinen
2017-10-23 13:32         ` Nayna Jain
2017-10-23 13:32           ` Nayna Jain
2017-10-23 13:32           ` Nayna Jain
2017-10-24 13:45           ` Jarkko Sakkinen
2017-10-24 13:45             ` Jarkko Sakkinen
2017-10-17 20:32 ` [PATCH v4 2/4] tpm: ignore burstcount to improve tpm_tis send() performance Nayna Jain
2017-10-17 20:32   ` Nayna Jain
2017-10-18 15:25   ` Jarkko Sakkinen
2017-10-18 15:25     ` Jarkko Sakkinen
2017-10-19 14:23   ` Jarkko Sakkinen
2017-10-19 14:23     ` Jarkko Sakkinen
2017-10-20 14:42   ` Alexander.Steffen
2017-10-20 14:42     ` Alexander.Steffen at infineon.com
2017-10-20 18:02     ` Ken Goldman
2017-10-20 18:02       ` Ken Goldman
2017-10-23  2:57     ` Jarkko Sakkinen
2017-10-23  2:57       ` Jarkko Sakkinen
2017-11-07 18:29     ` Nayna Jain
2017-11-07 18:29       ` Nayna Jain
2017-11-07 18:29       ` Nayna Jain
2017-11-08 11:32       ` Alexander.Steffen
2017-11-08 11:32         ` Alexander.Steffen at infineon.com
2017-11-16 14:34       ` Alexander.Steffen
2017-11-16 14:34         ` Alexander.Steffen at infineon.com
2017-11-22  6:52       ` Alexander.Steffen
2017-11-22  6:52         ` Alexander.Steffen at infineon.com
2017-11-23 14:47         ` Nayna Jain [this message]
2017-11-23 14:47           ` Nayna Jain
2017-11-23 16:19           ` Alexander.Steffen
2017-11-23 16:19             ` Alexander.Steffen at infineon.com
2017-11-26 15:22           ` Jarkko Sakkinen
2017-11-26 15:22             ` Jarkko Sakkinen
2017-11-26 16:37             ` Mimi Zohar
2017-11-26 16:37               ` Mimi Zohar
2017-11-27  7:08               ` Leendert van Doorn
2017-11-27  7:08                 ` Leendert van Doorn
2017-11-27  7:08                 ` Leendert van Doorn
2017-11-27 13:22                 ` Mimi Zohar
2017-11-27 13:22                   ` Mimi Zohar
2017-11-27 13:22                   ` Mimi Zohar
2017-11-28 20:19                 ` Jarkko Sakkinen
2017-11-28 20:19                   ` Jarkko Sakkinen
2017-11-28 20:19                   ` Jarkko Sakkinen
2017-10-17 20:32 ` [PATCH v4 3/4] tpm: reduce tpm polling delay in tpm_tis_core Nayna Jain
2017-10-17 20:32   ` Nayna Jain
2017-10-18 15:24   ` Jarkko Sakkinen
2017-10-18 15:24     ` Jarkko Sakkinen
2017-10-19 14:22     ` Jarkko Sakkinen
2017-10-19 14:22       ` Jarkko Sakkinen
2017-10-17 20:32 ` [PATCH v4 4/4] tpm: use tpm_msleep() value as max delay Nayna Jain
2017-10-17 20:32   ` Nayna Jain
2017-10-19 14:22   ` Jarkko Sakkinen
2017-10-19 14:22     ` Jarkko Sakkinen

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=20171123144742.GC8862@swastik \
    --to=nayna@linux.vnet.ibm.com \
    --cc=Alexander.Steffen@infineon.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=patrickc@us.ibm.com \
    --cc=peterhuewe@gmx.de \
    --cc=tpmdd@selhorst.net \
    --cc=zohar@linux.vnet.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.