Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7396734ioo; Fri, 3 Jun 2022 05:57:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAo218XtGRuUAA2kEhqRVd6TqEd0pl8QtH09+h1ll/Rc6w095RXLgyl45YyVFE4rDl95Y+ X-Received: by 2002:a05:6a00:319b:b0:51b:c5ec:62ba with SMTP id bj27-20020a056a00319b00b0051bc5ec62bamr9009061pfb.1.1654261066898; Fri, 03 Jun 2022 05:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654261066; cv=none; d=google.com; s=arc-20160816; b=xBFFrZFCoe+X8gv7GlGdnG3FSmTPyufkDUcNhTjc4rZkiOEMmaGpabmSoOI6Co8z7t h5IpJIUGUdALyJkXVCif2T6kWpVS8QfeEKbhMOKOa+flJ1NMOaUrf0b9rl3OdBFy7kS9 ODD6R/+Zs6RpWWmq3CFyMy+bMNNhszZD8HgdRyMP49TGLD5ruxPO9nGlvfXjoY9M/Vm4 byj8MSsd4SCiZgWIEsjOGSUnNP05X2eZ0hqpRUcf3m0VNy9y0Z5WziCLppeAK1cIPPKx INTqhF6HNzWu1buzpgs4+AbJhAbOLHTIRDr/VJO1gir7FGoUAJKJkyGyCfWnrLWFTdwp t2cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=AYLTXeMEtv7NOoBq0gdyu8buQw6rvgMAKICI6Snqam0=; b=uNJhMUDDtxUJA7sFsAr69+RoqkgDU1eJF3SE4GYYAtvIoLM7NfI8XLF3iSyWMyNIC5 F5H8tLDYY2Qm8qN4lsX+4dOifVk8K3Hw3ZPYHfJFcnV3dD7GCcFOsbrsG3SFEEHehzWk yjJ+dOyxtPCbU51c6y5AFQqhvHSRrsgFdCVrL7iYaPFJNJUr0jPEuKgm8IKpAfwFMqS9 RrdRaRNVdvq2ew9ODDUvNvTlx+JcYH5zS+KTckuu8zueLbP0ZzI6ytGKTHuahR+ETyQX jtN9KyAHToqxnLpPOp4Ig+KWqadvTIKUdFJBoHhHogpbaUeeLA1mJ/5Ujzckpd40jM85 LHCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infineon.com header.s=IFXMAIL header.b=hDWnUUpf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=infineon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y16-20020a62f250000000b00505974f8b58si9560542pfl.307.2022.06.03.05.57.31; Fri, 03 Jun 2022 05:57:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@infineon.com header.s=IFXMAIL header.b=hDWnUUpf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=infineon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242823AbiFCInK (ORCPT + 99 others); Fri, 3 Jun 2022 04:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241085AbiFCInI (ORCPT ); Fri, 3 Jun 2022 04:43:08 -0400 Received: from smtp11.infineon.com (smtp11.infineon.com [IPv6:2a00:18f0:1e00:4::5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D7471AF08; Fri, 3 Jun 2022 01:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infineon.com; i=@infineon.com; q=dns/txt; s=IFXMAIL; t=1654245788; x=1685781788; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=yxeS19Ie7EpNl/oaJ6C+O+T88X917wAoRTSCg0t/yDo=; b=hDWnUUpfuVuWUfF7fKyWaxGowEWUyR5tAhWeZaMHcjmgBJ38F24M0a4A 0o+29KO1WXtZvFxwI6WGDmBu/SU/X3Kgg99Z3hd1rq3m3Aokt8r42LH+E snjuP+mYj39QOumeoSrtHiCRGZv/bgegv0L4gF9H1BusHFSjXYzQtHmzT A=; X-SBRS: None X-IronPort-AV: E=McAfee;i="6400,9594,10366"; a="299504368" X-IronPort-AV: E=Sophos;i="5.91,274,1647298800"; d="scan'208";a="299504368" Received: from unknown (HELO mucxv002.muc.infineon.com) ([172.23.11.17]) by smtp11.infineon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2022 10:43:05 +0200 Received: from MUCSE814.infineon.com (MUCSE814.infineon.com [172.23.29.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mucxv002.muc.infineon.com (Postfix) with ESMTPS; Fri, 3 Jun 2022 10:43:04 +0200 (CEST) Received: from MUCSE818.infineon.com (172.23.29.44) by MUCSE814.infineon.com (172.23.29.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 3 Jun 2022 10:43:04 +0200 Received: from smaha-lin-dev01.agb.infineon.com (172.23.8.247) by MUCSE818.infineon.com (172.23.29.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 3 Jun 2022 10:43:04 +0200 From: Stefan Mahnke-Hartmann To: , , CC: , , Stefan Mahnke-Hartmann Subject: [PATCH v3] tpm: Add upgrade/reduced mode support for TPM1.2 modules Date: Fri, 3 Jun 2022 10:41:58 +0200 Message-ID: <20220603084156.7090-1-stefan.mahnke-hartmann@infineon.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.23.8.247] X-ClientProxiedBy: MUCSE805.infineon.com (172.23.29.31) To MUCSE818.infineon.com (172.23.29.44) X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case a TPM in failure mode is detected, the TPM should be accessible through a transparent communication channel for analysing purposes (e.g. TPM_GetTestResult) or a field upgrade. Since a TPM in failure mode has similar reduced functionality as in field upgrade mode, the flag TPM_CHIP_FLAG_FIRMWARE_UPGRADE is also valid. As described in TCG TPM Main Part1 Design Principles, Revision 116, chapter 9.2.1. the TPM also allows an update function in case a TPM is in failure mode. If the TPM in failure mode is detected, the function tpm1_auto_startup() sets TPM_CHIP_FLAG_FIRMWARE_UPGRADE flag, which is used later during driver initialization/deinitialization to disable functionality which makes no sense or will fail in the current TPM state. The following functionality is affected: * Do not register TPM as a hwrng * Do not get pcr allocation * Do not register sysfs entries which provide information impossible to obtain in limited mode Signed-off-by: Stefan Mahnke-Hartmann --- Changelog: * v3: * Change kernel messages drivers/char/tpm/tpm.h | 1 + drivers/char/tpm/tpm1-cmd.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 2163c6ee0d36..24ee4e1cc452 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -55,6 +55,7 @@ enum tpm_addr { #define TPM_WARN_DOING_SELFTEST 0x802 #define TPM_ERR_DEACTIVATED 0x6 #define TPM_ERR_DISABLED 0x7 +#define TPM_ERR_FAILEDSELFTEST 0x1C #define TPM_ERR_INVALID_POSTINIT 38 #define TPM_TAG_RQU_COMMAND 193 diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c index f7dc986fa4a0..cf64c7385105 100644 --- a/drivers/char/tpm/tpm1-cmd.c +++ b/drivers/char/tpm/tpm1-cmd.c @@ -709,7 +709,12 @@ int tpm1_auto_startup(struct tpm_chip *chip) if (rc) goto out; rc = tpm1_do_selftest(chip); - if (rc) { + if (rc == TPM_ERR_FAILEDSELFTEST) { + dev_warn(&chip->dev, "TPM self test failed, switching to the firmware upgrade mode\n"); + /* A TPM in this state possibly allows or needs a firmware upgrade */ + chip->flags |= TPM_CHIP_FLAG_FIRMWARE_UPGRADE; + return 0; + } else if (rc) { dev_err(&chip->dev, "TPM self test failed\n"); goto out; } -- 2.25.1