Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2370159ybb; Sun, 5 Apr 2020 05:56:33 -0700 (PDT) X-Google-Smtp-Source: APiQypIbjlo75tmynxpX+TO+cXtwp8NHcDDv1GPQppkLFhCOMc6K+dmdjL2OF13oKs2yb/qKSbwY X-Received: by 2002:a9d:4e3:: with SMTP id 90mr14305875otm.261.1586091393234; Sun, 05 Apr 2020 05:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586091393; cv=none; d=google.com; s=arc-20160816; b=UgK0tUuscoUSwtY/R0alLUaI6rO3bBgCAf6lG2hfjwkp0BHBJrtpX7tnyZ9XeFmN4s fOWDCb7TcCc1WHdykyFhtEsGgfDTsxFqZzdC2HdqFXkVhTQcsbNuVGYg+pZe2gf+hhKP HZMl47LP3kPeDQYBq+PTjqykzZauOk4I8p5MaQk8XRs1sZb97xy5YL8XlLc9uiH83KLF NsEWr7zzL+CuU35B3CFFGRDu8kA8l1HjmGVENT0Y+D2u846mJKIKcdhtG3bV/PYMRCK6 ndpCnxIHGncWXmQouuvaP16cvspdVaYpmPx/K495EDNCMSYD+DDa5QnqxIf4ehnnBM6e vOmg== 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=nzL1KE+4KkXOAsSM/SoQFRkhC7GXKumkwmwAtnauNDI=; b=jGNquq8tWGeS1VJ/GkoMkm4G4tkuBn9orZE0W8Ks/BKjysUTNKda/lFpEGOfa3dpuK W3WJHSfCruQmtwvjIpDlG7lQ0M6/+dvMg5GPsPvbh0lBEox/pVpdXcQaRpPejPuehxUC wh84jgncq/pojxFVUinLcHHqK9ktw3mv9g/RATap3I0jZ6cd0X61JUPeqhnoD+l59kjo Hiw7D4PyMPbfap+O7jUVZiIO5/yOLVhF45QYYR6hIzG8iQPP0zcVWEIsHrRqimTu9eIN Svl6F88I1rOlson0V85egDtQQJQC4Ft+L/aTCeDPiIFOOPrbUHDOgSxl2xFT4Dl8QJIa yDgQ== 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 j1si6052296oiw.205.2020.04.05.05.56.21; Sun, 05 Apr 2020 05:56:33 -0700 (PDT) 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 S1726833AbgDEMzk (ORCPT + 99 others); Sun, 5 Apr 2020 08:55:40 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:40253 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726473AbgDEMzj (ORCPT ); Sun, 5 Apr 2020 08:55:39 -0400 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 035CtMiD005496; Sun, 5 Apr 2020 15:55:22 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 10140) id C8349639B0; Sun, 5 Apr 2020 15:55:22 +0300 (IDT) 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, "benoit.houyere@st.com--to=mark.rutland"@arm.com, peterhuewe@gmx.de, christophe-h.richard@st.com, 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 , Benoit Houyere Subject: [PATCH v5 5/7] tpm: Handle an exception for TPM Firmware Update mode. Date: Sun, 5 Apr 2020 15:53:50 +0300 Message-Id: <20200405125352.183693-6-amirmizi6@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200405125352.183693-1-amirmizi6@gmail.com> References: <20200405125352.183693-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. 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 7603295..b77e394 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -727,6 +727,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