Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp1052715rdf; Wed, 22 Nov 2023 04:34:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMIdaKJH03VnWHamgACHSAL+LX62WBSQkjUDYb/UtojVfvuIEzTTXaMEb+TnbKJTNAM18S X-Received: by 2002:a05:6808:211b:b0:3b5:69c2:59cd with SMTP id r27-20020a056808211b00b003b569c259cdmr2599633oiw.25.1700656489149; Wed, 22 Nov 2023 04:34:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700656489; cv=none; d=google.com; s=arc-20160816; b=Bn5d0gTebPzaYIpl0aRKvRTLahL+6h2RQcEi8VSAUuER+5CoPjpLExxELSiKogRoQa L+ILa3zNteu3eI2j258MBsfeLXc/YVOgBgB/eB0DCzzGmLB0k2rFPMpScqMC4wyxuPMA bK5QY4qkvZwIKLENA4qo5iSyQV1zGluVmH0sPNtuZkhgZp9lEhVJoFGfJmv/0f4ekgR6 vsgjX2aO9NCHuJjHKSY41GVU6zAfcDlo5awDhXqOiql+RzT0KdwcRZhqsRu59WSJbYR+ +oKxdppeBdd3wr3ZVNvZHkiRbPW7Lo62uY6C9T1Io7vqPE1uU9x9BTVKf6cZcscvzaaM pwOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=JfDEp2rYNNMJNDqWlkXnSrW+7ZX3LJDn+wjWCugogRE=; fh=d/581fXMyQLRhlpaqCtTcAHumYLN6HDPdF2V23qtX3A=; b=zReKrtFM4gjwxjmPkOz6P4SHehbsEFpP9Sw4lexmw6eRG9YKvbaZ3njV8O7HvJm/jT Grj+Lsn2P1Bn25ZZlFGEcWiBKeSvyC6C3nQ/ixT5UgctnDA6/K+OxyJYhDwqZMwUqyc6 lcYBSS/1Qte/iNjDif6KcbMHQwc6gHhzRU6ZgbFq/3hqyCYhK4Li9yXYX+SG70ERwWmU mZTZT/6dCsSh5j0LHahf6OdgZtMICt0qC1p4sOrtSQnSwC8/WXuc8RWnlDvWwkaHGaby XIcOVPR6uKOE3r4399ruFddD0P+4iD0dJTdYAgiOkKadvjGYp73ltrsxjFqNHDzAJA9V jlUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=cSOF+PIx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u17-20020a632351000000b00588fdd9504bsi12010016pgm.858.2023.11.22.04.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 04:34:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=cSOF+PIx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 1B69B806501E; Wed, 22 Nov 2023 04:34:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344077AbjKVMer (ORCPT + 99 others); Wed, 22 Nov 2023 07:34:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343795AbjKVMeq (ORCPT ); Wed, 22 Nov 2023 07:34:46 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D8DA91; Wed, 22 Nov 2023 04:34:43 -0800 (PST) Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AMBVnbg031299; Wed, 22 Nov 2023 12:34:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=JfDEp2rYNNMJNDqWlkXnSrW+7ZX3LJDn+wjWCugogRE=; b=cSOF+PIxGHmfVH8gXZeM4IQXDsjrzeQ+LIpOQ2dkN6NZTLTa01xYKdhKV2gM5prBNuWE bgt7jzmGPk15zoKoD6L+owY+SpeQfCx41gIRRh7SzeIIAqld5tvlzY6pZZ/LczKySpjN mPMSikfHCOglkK4qaKjHkRKfyttx9xWohGKjQRpNkQcNubuQ5/NoeTmOdJCgrtnjix3h iIExx5v0NxdG6m5NeD3xFxkA+G8qm5pfsvVuynl10OFfbC6GQZmzBtpHOhhxQhvyEE/n +b9h6oBoKCApe1eQyIJIWYSdQOJNPNSOjqlqXVl/AmLXcByet9dR6bYavKTjGW5jyBt+ Gw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uhgq2hx2b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Nov 2023 12:34:38 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3AMBv4th023999; Wed, 22 Nov 2023 12:34:37 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uhgq2hx1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Nov 2023 12:34:37 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3AMAJr1B001763; Wed, 22 Nov 2023 12:34:36 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uf93kymyh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 22 Nov 2023 12:34:36 +0000 Received: from smtpav03.dal12v.mail.ibm.com (smtpav03.dal12v.mail.ibm.com [10.241.53.102]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3AMCYZXP14942944 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Nov 2023 12:34:35 GMT Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A49B15803F; Wed, 22 Nov 2023 12:34:35 +0000 (GMT) Received: from smtpav03.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB5165805A; Wed, 22 Nov 2023 12:34:34 +0000 (GMT) Received: from [9.47.158.152] (unknown [9.47.158.152]) by smtpav03.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 22 Nov 2023 12:34:34 +0000 (GMT) Message-ID: <85154bfe-6bd5-440a-acc1-f01497d59af5@linux.ibm.com> Date: Wed, 22 Nov 2023 07:34:33 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] tpm: Start the tpm2 before running a self test. Content-Language: en-US To: Hermin Anggawijaya , peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231122065528.1049819-1-hermin.anggawijaya@alliedtelesis.co.nz> From: Stefan Berger In-Reply-To: <20231122065528.1049819-1-hermin.anggawijaya@alliedtelesis.co.nz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: LbJzGeycirY9ZjRWDHlyNiY9chUMTGIY X-Proofpoint-GUID: pWk4bk2Bxre_FEY90RMSySOWmCNkLYQ_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-22_08,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 malwarescore=0 clxscore=1011 priorityscore=1501 spamscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311220088 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 04:34:48 -0800 (PST) On 11/22/23 01:55, Hermin Anggawijaya wrote: > Before sending a command to attempt the self test, the TPM > may need to be started, otherwise the self test returns > TPM2_RC_INITIALIZE value causing a log as follows: > "tpm tpm0: A TPM error (256) occurred attempting the self test". > > Signed-off-by: Hermin Anggawijaya > --- > drivers/char/tpm/tpm2-cmd.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c > index 93545be190a5..0530f3b5f86a 100644 > --- a/drivers/char/tpm/tpm2-cmd.c > +++ b/drivers/char/tpm/tpm2-cmd.c > @@ -737,15 +737,15 @@ int tpm2_auto_startup(struct tpm_chip *chip) > if (rc) > goto out; > > + rc = tpm2_startup(chip); > + if (rc && rc != TPM2_RC_INITIALIZE) > + goto out; > + Most platforms should have firmware initialize the TPM 2 these days. Therefore, a selftest should work and in case it doesn't work you fall back to the tpm2_startup below and if you get an error message in the log you at least know that you firmware is not up-to-date. > rc = tpm2_do_selftest(chip); > if (rc && rc != TPM2_RC_INITIALIZE) > goto out; > > if (rc == TPM2_RC_INITIALIZE) { > - rc = tpm2_startup(chip); > - if (rc) > - goto out; > - > rc = tpm2_do_selftest(chip); > if (rc) > goto out;