From patchwork Tue Jun 7 03:37:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ed Swierk X-Patchwork-Id: 631312 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rNyf53kByz9t3t for ; Tue, 7 Jun 2016 14:05:33 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bA8Ge-0001sl-4y; Tue, 07 Jun 2016 04:05:28 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bA8Gd-0001sg-0s for tpmdd-devel@lists.sourceforge.net; Tue, 07 Jun 2016 04:05:27 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of skyportsystems.com designates 209.85.220.42 as permitted sender) client-ip=209.85.220.42; envelope-from=eswierk@skyportsystems.com; helo=mail-pa0-f42.google.com; Received: from mail-pa0-f42.google.com ([209.85.220.42]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1bA8Gb-0005vh-0t for tpmdd-devel@lists.sourceforge.net; Tue, 07 Jun 2016 04:05:26 +0000 Received: by mail-pa0-f42.google.com with SMTP id b5so13148212pas.3 for ; Mon, 06 Jun 2016 21:05:24 -0700 (PDT) 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; bh=o8fvgBBFFuAU1TDZB8g75/671ecx9zUbjfP2e8K2PRs=; b=ETcbGRaDlhhKdhYPYnKSTwoivMM1a9B4Bdr/Em0221w5xwoURuw7eJ1Wrwu04/hB24 fLbH+w2PkrSpjNX9DDlYFgUvo4xe24KHn1zg4IqKkxI8NewGdvohSpBDFXSNBu15FnNY aA7EBCgDUh0CoFjgjiu95nuyKx9fUeid3SNMUgJaQdYkC+VjIZOlRkCo5u39pIOHKA6n zPMfIkv5Vee39LIuiItKrMwkASu0HFDf8rhl0TJpNi8shqNH5VMRnQPp0UfXCiB+8DGh tcxzBlrpQ464xg0JTsj7aYXIcAoEGCnMOR+pj2ICPACmFwENBqKzdKRI8x9TaP6B9jUB MDZA== X-Gm-Message-State: ALyK8tLD4Bkj23Wx1D8sHYIr6qvaMdRj7S21ns/EUhwJw7pLSEdNkaaxTVfpKcI4UyKkLEHM X-Received: by 10.67.3.161 with SMTP id bx1mr28510134pad.86.1465270685283; Mon, 06 Jun 2016 20:38:05 -0700 (PDT) Received: from eswierk-sc.localdomain (67-207-112-138.static.wiline.com. [67.207.112.138]) by smtp.gmail.com with ESMTPSA id fl1sm28516535pab.43.2016.06.06.20.38.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Jun 2016 20:38:04 -0700 (PDT) From: Ed Swierk To: tpmdd-devel@lists.sourceforge.net Date: Mon, 6 Jun 2016 20:37:29 -0700 Message-Id: <1465270649-22498-5-git-send-email-eswierk@skyportsystems.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465270649-22498-1-git-send-email-eswierk@skyportsystems.com> References: <1465270649-22498-1-git-send-email-eswierk@skyportsystems.com> X-Spam-Score: -1.6 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1bA8Gb-0005vh-0t Subject: [tpmdd-devel] [PATCH v3 4/4] tpm_tis: Increase ST19NP18 TPM command duration to avoid chip lockup X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net The STMicro ST19NP18-TPM sometimes takes much longer to execute commands than it reports in its capabilities. For example, command 186 (TPM_FlushSpecific) has been observed to take 14560 msec to complete, far longer than the 3000 msec limit for "short" commands reported by the chip. The behavior has also been seen with command 101 (TPM_GetCapability). Worse, when the tpm_tis driver attempts to cancel the current command (by writing commandReady = 1 to TPM_STS_x), the chip locks up completely, returning all-1s from all memory-mapped register reads. The lockup can be cleared only by resetting the system. The occurrence of this excessive command duration depends on the sequence of commands preceding it. One sequence is creating at least 2 new keys via TPM_CreateWrapKey, then letting the TPM idle for at least 30 seconds, then loading a key via TPM_LoadKey2. The next TPM_FlushSpecific occasionally takes tens of seconds to complete. Another sequence is creating many keys in a row without pause. The TPM_CreateWrapKey operation gets much slower after the first few iterations, as one would expect when the pool of precomputed keys is exhausted. Then after a 35-second pause, the same TPM_LoadKey2 followed by TPM_FlushSpecific sequence triggers the behavior. Our working theory is that this older TPM sometimes pauses to precompute keys, which modern chips implement as a background process. Without access to the chip's implementation details it's impossible to know whether any commands are immune to being blocked by this process. So it seems safest to ignore the chip's reported command durations, and use a value much higher than any observed duration, like 180 sec (which is the duration this chip reports for "long" commands). Signed-off-by: Ed Swierk --- drivers/char/tpm/tpm_tis.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index 3baba73..6b95667 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -511,6 +511,10 @@ struct tis_vendor_duration_override { }; static const struct tis_vendor_duration_override vendor_duration_overrides[] = { + /* STMicro ST19NP18-TPM */ + { 0x0000104a, { (180*USEC_PER_SEC), + (180*USEC_PER_SEC), + (180*USEC_PER_SEC) } }, }; static bool tpm_tis_update_durations(struct tpm_chip *chip,