Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1351150ybt; Thu, 18 Jun 2020 06:47:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf9CbDyOuA+4fNOKw5lppieINLIlrlfM6NkxN23uGeyUsUccV9T2RA2A/ii2RoKZad7jmX X-Received: by 2002:aa7:c496:: with SMTP id m22mr4262138edq.187.1592488057838; Thu, 18 Jun 2020 06:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592488057; cv=none; d=google.com; s=arc-20160816; b=h6xW9Va6t81a62XdLMvXCo6P0XQCDYBXaRPfjG265VbchMp4VGPSB+YqNmjJj5ounu jQaB+5OX3vuqShFqtktKPBBycI0pXYKeTeB6Dz8IxgpdjRJqGfXtJAl20Gw14xIbYPVi KlfosUhrbnKv9ig8iWrOon5IBv5ObGfkRBw1UkP+eHB59C927XZPpfZehOFa1W35nCxw 1pEOCR/rkW8pb6cbMYsYYR9hEr7B1xkApWPnL+q8QL5R3vUJEC0Hw+qxlV8JmJ2sqYBa voX94JFue1vK/CC6VM79pyIdHgwdydePqjTzwOPnWiYhF3Asn0HghaASux6OTUHhxVOi +cgA== 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=XsEnKG8PC7cm5GibfE1SvoWl1kh/GQMlwpAErSZBEF8=; b=mTxqRNbcVD630ezbAj0gG+wvhaa4eWnQ65sOWjJuqweJyZG5dfFCdxf9W3/6akcmTv iP1B5MqOaQxX1VFNi2NazSMHHM+Z9CP2JgRyKsRdHk54v1wptTAKYmuAFmM+G3aFxmkV AMm1AY0vHjphTjrolAk/TfWz6vcQQKsBREwwxJk1pDXd3dLzSB+S9RznHBE5JwvmiQfV LEdaumCIOq8Be0hGRVdlS9AqjFnL6bgR0qsdSYmzKVBvSup0daa0K87SVMM9PdfhEWmv ogcYEZR8uFEGBSMir6YZxO895f+NUKyuHJYEYnjYbvl8wy/Se5v23/Uz4M1WwVTIDpWD 4A+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n7si1943033ejk.154.2020.06.18.06.47.14; Thu, 18 Jun 2020 06:47:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730431AbgFRNpG (ORCPT + 99 others); Thu, 18 Jun 2020 09:45:06 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:50930 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730326AbgFRNot (ORCPT ); Thu, 18 Jun 2020 09:44:49 -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 05IDiUdi001784; Thu, 18 Jun 2020 16:44:30 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 10140) id 4C794639BF; Thu, 18 Jun 2020 16:44:30 +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 v11 5/8] tpm: Handle an exception for TPM Firmware Update mode. Date: Thu, 18 Jun 2020 16:43:40 +0300 Message-Id: <20200618134344.243537-6-amirmizi6@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200618134344.243537-1-amirmizi6@gmail.com> References: <20200618134344.243537-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..6e42946 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