From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934276AbdBVVNM (ORCPT ); Wed, 22 Feb 2017 16:13:12 -0500 Received: from mga05.intel.com ([192.55.52.43]:27260 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932493AbdBVVNF (ORCPT ); Wed, 22 Feb 2017 16:13:05 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,196,1484035200"; d="scan'208";a="67898487" Date: Wed, 22 Feb 2017 23:13:01 +0200 From: Jarkko Sakkinen To: Peter Huewe Cc: Jason Gunthorpe , tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, peterhuewe@gmx.de, Alexander Steffen , stable@vger.kernel.org Subject: Re: [PATCH] tpm_tis_core: Choose appropriate timeout for reading burstcount Message-ID: <20170222211301.wnm5mb52civnmcdj@intel.com> References: <1487259216-28955-1-git-send-email-peter.huewe@infineon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1487259216-28955-1-git-send-email-peter.huewe@infineon.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.6.2-neo (2016-08-21) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 16, 2017 at 03:33:36PM +0000, Peter Huewe wrote: > From: Alexander Steffen > > TIS v1.3 for TPM 1.2 and PTP for TPM 2.0 disagree about which timeout > value applies to reading a valid burstcount. It is TIMEOUT_D according to > TIS, but TIMEOUT_A according to PTP, so choose the appropriate value > depending on whether we deal with a TPM 1.2 or a TPM 2.0. > > This is important since according to the PTP TIMEOUT_D is much smaller > than TIMEOUT_A. So the previous implementation could run into timeouts > with a TPM 2.0, even though the TPM was behaving perfectly fine. > > During tpm2_probe TIMEOUT_D will be used even with a TPM 2.0, because > TPM_CHIP_FLAG_TPM2 is not yet set. This is fine, since the timeout values > will only be changed afterwards by tpm_get_timeouts. Until then > TIS_TIMEOUT_D_MAX applies, which is large enough. > > Cc: stable@vger.kernel.org > Fixes: aec04cbdf723 ("tpm: TPM 2.0 FIFO Interface") > > Signed-off-by: Alexander Steffen > Signed-off-by: Peter Huewe Reviewed-by: Jarkko Sakkinen /Jarkko > --- > drivers/char/tpm/tpm_tis_core.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index c0f296b5d413..fc0e9a2734ed 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -160,8 +160,10 @@ static int get_burstcount(struct tpm_chip *chip) > u32 value; > > /* wait for burstcount */ > - /* which timeout value, spec has 2 answers (c & d) */ > - stop = jiffies + chip->timeout_d; > + if (chip->flags & TPM_CHIP_FLAG_TPM2) > + stop = jiffies + chip->timeout_a; > + else > + stop = jiffies + chip->timeout_d; > do { > rc = tpm_tis_read32(priv, TPM_STS(priv->locality), &value); > if (rc < 0) > -- > 2.7.4 >