Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4538911ybb; Tue, 7 Apr 2020 09:22:58 -0700 (PDT) X-Google-Smtp-Source: APiQypI+ZMvL7uLxvFHz9vLnwRMZyYaYitUi7eGHJsObg70ML+1lJB4VjqasMWYoCSAJVajyX9eb X-Received: by 2002:a05:6830:1046:: with SMTP id b6mr2375862otp.229.1586276578624; Tue, 07 Apr 2020 09:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586276578; cv=none; d=google.com; s=arc-20160816; b=uDeJwhCGxJGzuiq9KIvhdFk+6uB4nNIdez08cT3Dz3/5nGgR7q54BEP3cU6MU6KT1F bGgpe4meBMLO5DXz77mbu2wHZRc5VOPdCtwcfEbHq2bPexBjd0haxfHTSk0R2dbmRxsx jkFOkynXVltldgCyjn9xI0/YuQQrxaPHbO10LWc6xygKwVS6+5iFSgFGPYB+YscjwGVq oyJLbx/d/vOS1aFkOFFfROMfFKt1xEPrMXk3TIkHy5/AnGT/RCeYEGLs2Wg3r497EL2p SIk/Dd7KilvppsqyfMuUhgBPPdnvv57l5MYRBPO2D7dajyo6diDZ2CH6idQmbzxHyQNG 32rg== 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=kG0ZQSEIL4UbKVyIzeoEoNAuzkjysCWH3w6zHiNxR7TLLbRmcfvDLvRyJL0ib5VA+s DY+q7/qE8OSeA6dm5SeaIEV546w3Vcip9P56hNfrBKvOG2QrQXc5HANdv80T65lbwOAC 3ue62dW7qrNn1G7JZ7Yu4lfIQkVkiNQzOaR9waQznlBBbP5qmc9WMpKQe89QWTiXNwzo pO2MoTzfNjnjGOrH9Xq/fCnwEMfh4DPw9yPAtUI94M+rUwCLPZWSRo90jubmV6yDlyK8 4BDc1HyG8hAZwRIBgHcM7IFepye4/15KZhiJw842dTOvDPpp3tQPEN933oVN7m0iQ3+V /dEg== 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 w65si1521322ooa.42.2020.04.07.09.22.46; Tue, 07 Apr 2020 09:22:58 -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 S1728142AbgDGQV0 (ORCPT + 99 others); Tue, 7 Apr 2020 12:21:26 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:40601 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728034AbgDGQVZ (ORCPT ); Tue, 7 Apr 2020 12:21:25 -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 037GKu01002275; Tue, 7 Apr 2020 19:20:56 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 10140) id 8B583639B0; Tue, 7 Apr 2020 19:20:56 +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, 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 , Benoit Houyere Subject: [PATCH v6 5/7] tpm: Handle an exception for TPM Firmware Update mode. Date: Tue, 7 Apr 2020 19:20:42 +0300 Message-Id: <20200407162044.168890-6-amirmizi6@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200407162044.168890-1-amirmizi6@gmail.com> References: <20200407162044.168890-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