Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7CA7C4346E for ; Mon, 28 Sep 2020 01:22:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CEB623A33 for ; Mon, 28 Sep 2020 01:22:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b="mqaW3Pwc"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b="mqaW3Pwc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726406AbgI1BWd (ORCPT ); Sun, 27 Sep 2020 21:22:33 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:51342 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726387AbgI1BWd (ORCPT ); Sun, 27 Sep 2020 21:22:33 -0400 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id A9BD08EE17F; Sun, 27 Sep 2020 18:22:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1601256152; bh=yoHIHM3+Su6TOLDsV9bLyo6wb/q8x7fR8ORf1mIC/QI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=mqaW3PwczvahHGO2n+c8gTA28ei4nSKyxypJ/dja9Kp/et1p+GZGLVoLMjU6mVbE9 U2Km0YFUY+/Xruo/5+Slq7prrE6P9wmjoHmFNFIkvejBpUzVCRhVxFJu66kT3iEEoL T9Qy7XfAi1JUwIdE72ncZxJil2DdhRi1VZJNQj0s= Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MaCHzYzCib9D; Sun, 27 Sep 2020 18:22:32 -0700 (PDT) Received: from jarvis (c-73-35-198-56.hsd1.wa.comcast.net [73.35.198.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 0D2458EE012; Sun, 27 Sep 2020 18:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hansenpartnership.com; s=20151216; t=1601256152; bh=yoHIHM3+Su6TOLDsV9bLyo6wb/q8x7fR8ORf1mIC/QI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=mqaW3PwczvahHGO2n+c8gTA28ei4nSKyxypJ/dja9Kp/et1p+GZGLVoLMjU6mVbE9 U2Km0YFUY+/Xruo/5+Slq7prrE6P9wmjoHmFNFIkvejBpUzVCRhVxFJu66kT3iEEoL T9Qy7XfAi1JUwIdE72ncZxJil2DdhRi1VZJNQj0s= Message-ID: <0c896ca8eb0e30d6e75843cfbf2aa627ddc63feb.camel@HansenPartnership.com> Subject: Re: [PATCH] Fix Atmel TPM crash caused by too frequent queries From: James Bottomley To: Hao Wu Cc: peterhuewe@gmx.de, jarkko.sakkinen@linux.intel.com, jgg@ziepe.ca, arnd@arndb.de, gregkh@linuxfoundation.org, Hamza Attak , nayna@linux.vnet.ibm.com, why2jjj.linux@gmail.com, zohar@linux.vnet.ibm.com, linux-integrity@vger.kernel.org, Paul Menzel , Ken Goldman , Seungyeop Han , Shrihari Kalkar , Anish Jhaveri Date: Sun, 27 Sep 2020 18:22:30 -0700 In-Reply-To: References: <20200926223150.109645-1-hao.wu@rubrik.com> <73405d14d7665e8a4e3e9defde7fb12aeae7784c.camel@HansenPartnership.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org On Sun, 2020-09-27 at 17:11 -0700, Hao Wu wrote: > Hi James, > > Maybe there is a misunderstanding. Here I am using tpm_msleep, not > msleep. tpm_msleep is using usleep underlaying. See > https://github.com/torvalds/linux/blob/master/drivers/char/tpm/tpm.h#L188 Right, I had missed that. > The reasons I choose 15ms, is because before > https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3 > (Where msleep is changed to tpm_msleep (which is essentially > usleep)), The actual sleep time is 15ms, thus here we change this > back to 15ms to fix regression. Right now most TIS TPMs operate successfully with a sleep in there of the range 0.1-0.5ms. Upping that to 15ms introduces a 100x delay in our status wait for the TPM to become ready, potentially slowing down all TIS TPM operations by 100x, which will hit us most with the PCR writes we do for IMA logging ... that seems like a bad bargain for a single TPM family manufacturer. However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in tpm_tis_status() allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton. James