Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1446898
| Path | csiph.com!news.mixmin.net!feeds.phibee-telecom.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Andrey Pronin <apronin@chromium.org> |
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 1/2] tpm_tis_core: add optional max xfer size check |
| Date | Wed, 20 Jul 2016 04:40:01 +0200 |
| Message-ID | <rWPAt-3ST-13@gated-at.bofh.it> (permalink) |
| References | <rV0gF-qZ-9@gated-at.bofh.it> <rWPAt-3ST-1@gated-at.bofh.it> |
| X-Original-To | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=e/Y1h9MxNVJ53v90p0MPNV9wGCDyjf6TURtImHpWJUg=; b=MaONZgSyGxPsCPbS9I6UXM5nEQb3Qnnyod3WM5bPNr8mT+tIut65FVFMIzu8fpqvJN 8h6TUpjWGdLFey8I9+m2x8+T2XBKsmibOE/0tPUW3lTnbW/xXwxtDrX5opzWxBkyUmSt /R1Ke1VzOozoX7yneGxQMKIO58H4Ih0tY7vHo= |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=e/Y1h9MxNVJ53v90p0MPNV9wGCDyjf6TURtImHpWJUg=; b=jO0wW6hJwj7u50U4dR8XPkjg/WbK6Ccm1zFJf4EGbySny/nGjcKgBpagzkjmYz4Pra bGbw1UHtIHuv1O38N3JoLt1vP8GtAEQVmZ7VsE9A0x0NauVwRpVnptaWRGqIcYJi1UJF rZ1qPk5I8sdn6Vg0ZNbK3LxdY5YfUyEUEdM7xomaXTUTxFJbrYgnAnBlUB+jiO3s2ub2 zKOrE9Q2GegTcEVVxSf7ydA2icyDOiBNZMjxSOoHIVgkku1KNVRA+S7/FcWbtSX/CdM8 yh97T0AiQOCoD2LI8joY+aFaHcM/CwG8fh+V/HZbpNyNmJ6xROCV72N5e4zvYqQZkfNB GtCA== |
| X-Gm-Message-State | ALyK8tJQrwyGZkZFuUi3ef0EjEfH8fgQzV6HKpV5HP3d2+1o39H5+bqIW3c+jEgclkv9d46Q |
| X-Received | by 10.98.21.131 with SMTP id 125mr60824234pfv.92.1468982063521; Tue, 19 Jul 2016 19:34:23 -0700 (PDT) |
| X-Mailer | git-send-email 2.8.0.rc3.226.g39d4020 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 64 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Peter Huewe <peterhuewe@gmx.de>, Marcel Selhorst <tpmdd@selhorst.net>, Jason Gunthorpe <jgunthorpe@obsidianresearch.com>, tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Christophe Ricard <christophe.ricard@gmail.com>, Andrey Pronin <apronin@chromium.org> |
| X-Original-Date | Tue, 19 Jul 2016 19:34:19 -0700 |
| X-Original-Message-ID | <faf81974821d1748f671888afffba5721847aa6d.1468981325.git.apronin@chromium.org> |
| X-Original-References | <1468546745-14646-1-git-send-email-apronin@chromium.org> <cover.1468981325.git.apronin@chromium.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1446898 |
Show key headers only | View raw
If tpm reports a bigger burstcnt than allowed by the physical protocol,
re-query the burstcnt and correct, if needed, if still too large.
In practice, seen in case of xfer issues (e.g. in spi interface case,
lost header causing flow control issues and wrong values returned on read
from TPM_STS). Without catching, causes the physical layer to reject xfer,
while is easily preventable by re-querying TPM_STS.
Signed-off-by: Andrey Pronin <apronin@chromium.org>
---
drivers/char/tpm/tpm_tis_core.c | 18 ++++++++++++++++--
drivers/char/tpm/tpm_tis_core.h | 1 +
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index d66f51b..ffc1acb 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -158,6 +158,7 @@ static int get_burstcount(struct tpm_chip *chip)
unsigned long stop;
int burstcnt, rc;
u32 value;
+ bool retry_burstcnt = false;
/* wait for burstcount */
/* which timeout value, spec has 2 answers (c & d) */
@@ -168,8 +169,21 @@ static int get_burstcount(struct tpm_chip *chip)
return rc;
burstcnt = (value >> 8) & 0xFFFF;
- if (burstcnt)
- return burstcnt;
+ if (burstcnt) {
+ /* If burstcnt is larger than max allowed xfer
+ * size, retry once - may be a glitch. Return
+ * max_xfer_size on the 2nd try to avoid being
+ * stuck forever.
+ */
+ if ((priv->phy_ops->max_xfer_size == 0) ||
+ (burstcnt <= priv->phy_ops->max_xfer_size))
+ return burstcnt;
+ if (retry_burstcnt)
+ return priv->phy_ops->max_xfer_size;
+ dev_warn(&chip->dev,
+ "Bad burstcnt read: %d\n", burstcnt);
+ retry_burstcnt = true;
+ }
msleep(TPM_TIMEOUT);
} while (time_before(jiffies, stop));
return -EBUSY;
diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
index 9191aab..58e8b14 100644
--- a/drivers/char/tpm/tpm_tis_core.h
+++ b/drivers/char/tpm/tpm_tis_core.h
@@ -102,6 +102,7 @@ struct tpm_tis_phy_ops {
int (*read16)(struct tpm_tis_data *data, u32 addr, u16 *result);
int (*read32)(struct tpm_tis_data *data, u32 addr, u32 *result);
int (*write32)(struct tpm_tis_data *data, u32 addr, u32 src);
+ u16 max_xfer_size;
};
static inline int tpm_tis_read_bytes(struct tpm_tis_data *data, u32 addr,
--
2.6.6
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/2] tpm: add optional max xfer size check Andrey Pronin <apronin@chromium.org> - 2016-07-15 03:40 +0200
[PATCH 1/2] tpm_tis_core: add optional max xfer size check Andrey Pronin <apronin@chromium.org> - 2016-07-15 03:40 +0200
Re: [PATCH 1/2] tpm_tis_core: add optional max xfer size check Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-07-15 05:20 +0200
Re: [PATCH 1/2] tpm_tis_core: add optional max xfer size check Andrey Pronin <apronin@chromium.org> - 2016-07-15 05:30 +0200
Re: [PATCH 1/2] tpm_tis_core: add optional max xfer size check Guenter Roeck <groeck@google.com> - 2016-07-15 05:50 +0200
Re: [PATCH 1/2] tpm_tis_core: add optional max xfer size check Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-07-18 21:00 +0200
[PATCH 2/2] tpm_tis_spi: add max xfer size Andrey Pronin <apronin@chromium.org> - 2016-07-15 03:40 +0200
[PATCH v2 0/2] tpm: add optional max xfer size check Andrey Pronin <apronin@chromium.org> - 2016-07-20 04:40 +0200
[PATCH v2 2/2] tpm_tis_spi: add max xfer size Andrey Pronin <apronin@chromium.org> - 2016-07-20 04:40 +0200
[PATCH v2 1/2] tpm_tis_core: add optional max xfer size check Andrey Pronin <apronin@chromium.org> - 2016-07-20 04:40 +0200
Re: [PATCH v2 0/2] tpm: add optional max xfer size check Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-07-20 17:20 +0200
csiph-web