Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3938028ybv; Mon, 10 Feb 2020 09:10:22 -0800 (PST) X-Google-Smtp-Source: APXvYqxTL0Sq+2XLYxihjAC3g3yA6U1YWeOYi04YEPNsFI12E14UVncY16JtcZKPJkwNb1E/N+2s X-Received: by 2002:aca:bb54:: with SMTP id l81mr10040oif.175.1581354621988; Mon, 10 Feb 2020 09:10:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581354621; cv=none; d=google.com; s=arc-20160816; b=TEg48HE4z8CnYQGlB+eVPIjATuWHhyn8yZujqnS9mBZomBt8BF8MTUA6821wnEJ4/W yV//2tYe7lG62BXnrL6s2dqt6L/kfb5ehqIaVekBZTIJ9ZIc8yNxbNYGlupHQ+W1k7ra BxlfgvGNS0oTThgw7pOB4NWoLfNJRREPs5yv8RZ4oXZjpUlFUYL8CbklraA4iajadJok Rbv3XxugBN1RYT9qnaMSzxZTaVoYkPj3wOwpHvlXthoUqKk0tm5mUQ0b0IlMsoCu/eWr yuSvdB0lQDwt0EKnaJeFf5+Td1OhXp8KxnZBA9v0AjfY6MMfm01IhWiSQuwaZBHdgE+A NQcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jGW0KF3XI86LcNn2o9qNrEMTRDFgSeR/MnBh6ClMspM=; b=GpMB87prNLeFm0oS0r8mTKTLMyZiNTCffhhA6GS2ab5ZekeRK0PMTffLtowK5cSYLm ZBquvXK8uSSlTh40Y1wCnSHCOutAphTxJqiXGivHtfs+kdrXLM7lLL40u1ZGWyceuY58 /vtmvm2PLQO1mOmMvfuBW4zKd2radPFJxQEfz1GuC4kaW6JHPIdbyohtLq5UsvovVwGK u5DuvDPCOu9YMiJH1KBBG993c+RTnAVbimfIM7PjlmUUbMP61u5yNmKicPSJ4sOcIzan zJ6ocGqcwLZtcqiPSgbk5M6gyg+ytcNjTRKuRydTFQh1hS/413bSVP1PwobyndehhYqA GmJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si434177otq.298.2020.02.10.09.10.10; Mon, 10 Feb 2020 09:10:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727942AbgBJRJ7 (ORCPT + 99 others); Mon, 10 Feb 2020 12:09:59 -0500 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:36755 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727536AbgBJRJ6 (ORCPT ); Mon, 10 Feb 2020 12:09:58 -0500 X-Greylist: delayed 2425 seconds by postgrey-1.27 at vger.kernel.org; Mon, 10 Feb 2020 12:09:57 EST Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id 01AGT7qd011297; Mon, 10 Feb 2020 18:29:07 +0200 Received: by taln60.nuvoton.co.il (Postfix, from userid 10140) id B87046032E; Mon, 10 Feb 2020 18:29:07 +0200 (IST) From: amirmizi6@gmail.com To: Eyal.Cohen@nuvoton.com, jarkko.sakkinen@linux.intel.com, oshrialkoby85@gmail.com, alexander.steffen@infineon.com, robh+dt@kernel.org, mark.rutland@arm.com, peterhuewe@gmx.de, jgg@ziepe.ca, arnd@arndb.de, gregkh@linuxfoundation.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, oshri.alkoby@nuvoton.com, tmaimon77@gmail.com, gcwilson@us.ibm.com, kgoldman@us.ibm.com, Dan.Morav@nuvoton.com, oren.tanami@nuvoton.com, shmulik.hager@nuvoton.com, amir.mizinski@nuvoton.com, Amir Mizinski Subject: [PATCH v3 5/7] tpm: Handle an exception for TPM Firmware Update mode. Date: Mon, 10 Feb 2020 18:28:36 +0200 Message-Id: <20200210162838.173903-6-amirmizi6@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200210162838.173903-1-amirmizi6@gmail.com> References: <20200210162838.173903-1-amirmizi6@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amir Mizinski An extra precaution for TPM Firmware Update Mode. For example if TPM power was cut while in Firmware update, platform should ignore selftest failure and skip TPM initialization sequence. This improvment was suggested by Benoit Houyere. Signed-off-by: Amir Mizinski --- drivers/char/tpm/tpm2-cmd.c | 4 ++++ include/linux/tpm.h | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index 13696de..997b11e 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -725,6 +725,10 @@ int tpm2_auto_startup(struct tpm_chip *chip) goto out; rc = tpm2_do_selftest(chip); + + if ((rc == TPM2_RC_UPGRADE) || (rc == TPM2_RC_COMMAND_CODE)) + return 0; + if (rc && rc != TPM2_RC_INITIALIZE) goto out; diff --git a/include/linux/tpm.h b/include/linux/tpm.h index 03e9b18..5a2e031 100644 --- a/include/linux/tpm.h +++ b/include/linux/tpm.h @@ -199,6 +199,7 @@ enum tpm2_return_codes { TPM2_RC_INITIALIZE = 0x0100, /* RC_VER1 */ TPM2_RC_FAILURE = 0x0101, TPM2_RC_DISABLED = 0x0120, + TPM2_RC_UPGRADE = 0x012D, TPM2_RC_COMMAND_CODE = 0x0143, TPM2_RC_TESTING = 0x090A, /* RC_WARN */ TPM2_RC_REFERENCE_H0 = 0x0910, -- 2.7.4