Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp209698ybs; Tue, 26 May 2020 07:23:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzA/RrWdA+f9/YbCyDw2ixWFtVZDRffa1+cPNvHKqeFWfoFtTBNv1dryNgKP2frl5sWZnAd X-Received: by 2002:a50:ed0e:: with SMTP id j14mr13325666eds.52.1590502986143; Tue, 26 May 2020 07:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590502986; cv=none; d=google.com; s=arc-20160816; b=pmxUBqsmtBWKzoXK7yxwWzrxjk1nmqyui/b63GF1Vy4tZBUqr1HkYXCJW44X8plWKu RRA2XUKHVcfwlcxFYsLOMHsbicPqH6TnkUmm8Sq+q/mDfdKvoUR5spda72aNgjPjCtY6 upY/JEfPvWz6Zu0la27a5g+YOqb8LUzY9izsK1REK+/VHohkMhWxayg4/uJgnXd4jFZ6 o9ZWyxFChc6sTZhW4VqlJLR4nMqKAtGtLxUYfZ0YlEQ9k9MLCBwGIrEFzZs41TitQ5pl GSO+5Erbwvzcnt6Ylv8c5I1kmyx25hiX/p0WFQPL+7Sgbo3ZsVnEPHq46RuCPTwyZZEO Nbug== 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=IrRyPU5+ouxb51+6a5GfFIyagTcajWQaNzFOLsZfcaHdi1rB4VGghBZ8DxmBDnFO6b ndRQisWRKd5mGbiolo7twg/RONeSDXyOQ6fxHasKAHTQ3pQVqsTd9LKllYtLPvHIjgQe 9+18TOJ02+Foaspkr5p3nKbfMGXT6aNmJmRJUd1NFcsTw5gKm+LBTC3KHarJ75gcOZT0 XVVx7vg2ufdAF5U9GyDAd8tSumSYWBh0Mml2D9ZmYVPiwQpVqgyGbH1dDXK5efyc8RoR FQKFQs4mJPW5JnY8oL2k1760DB0yx4JjiRNLHoJt6hDAIiIWFr0SQ3ygLmG5vsJqhaLk iOhQ== 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 s7si1186298ejo.438.2020.05.26.07.22.42; Tue, 26 May 2020 07:23:06 -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 S1729085AbgEZOSC (ORCPT + 99 others); Tue, 26 May 2020 10:18:02 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:49590 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727976AbgEZOSA (ORCPT ); Tue, 26 May 2020 10:18:00 -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 04QEHYro008680; Tue, 26 May 2020 17:17:34 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 10140) id BBEA9639BE; Tue, 26 May 2020 17:17:34 +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 v9 5/8] tpm: Handle an exception for TPM Firmware Update mode. Date: Tue, 26 May 2020 17:16:55 +0300 Message-Id: <20200526141658.157801-6-amirmizi6@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200526141658.157801-1-amirmizi6@gmail.com> References: <20200526141658.157801-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