Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2456298rdb; Sun, 3 Dec 2023 18:36:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEgkJXY2u9qcWS9ugpJdqpDHIkeokF7HiG9EaNMURfPLb6eCVocBnK6VhEocvrg3K6/DU3 X-Received: by 2002:a17:902:7897:b0:1cf:ee16:84fd with SMTP id q23-20020a170902789700b001cfee1684fdmr742196pll.53.1701657388884; Sun, 03 Dec 2023 18:36:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701657388; cv=none; d=google.com; s=arc-20160816; b=ZctCl0GyWI3VTUH6D3IGrhsYu1kmyJWjFhQ883IZsIOygLtuxbusDhI/fZ7kDDjg9j cNYpM+dFkYj1ffS4F7Z3CFV/xu0bJpDYvCabWKdHSky9f++hvJ3csO4Ga+R3Kq1D5eVh j1/e2PHUCp8IN9H2h31zfzAOsa1oUvn8G4zveQbtoYE6qfUq9HtfZ0SukkAisauWdL5+ rCx/kCfOSdgrMPcDK+5OloMYcIXfq+x94T66jtiTmCXYMpLQ2BHtDhcdh2jsCHvqzxvC xg1ar4+G2OoVQnW5YR3J1L+uRGhntjmXNdMzWOp5uMQPUh/cIMOYDRQZpbTnf779Kz2H R4oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:from:subject:cc:to :message-id:date:content-transfer-encoding:mime-version :dkim-signature; bh=PYeF07rEgepH06KQnhf/cogiGP7iBaCv1QN0e6AXkSg=; fh=cTwZF2+mU1r5ChZXfOHykJag9H1WpzaNMnnX1lgLkhc=; b=uRe+5Xlu43hYeDeQWbvPMRtUWH/D9lvfQS8LhNIjbz229KmbeIa4QoznuhUD92+5LK oqexA6zIf1lLzT6d8PMcu6+yalasObX1O3VHTx5+qV4aDwynbBGTQPrzohC2CKc69hl9 ifNwk0oyVYLNIQpVdKrZyS0gWn9xn1CrqMi0zCfeBa5U3wgBa14UYI1R3LgCt5xtUuN1 c6FAm7dg62B9RpvyFWS4dQ2wA0c/RtJBb/yGKZZ8ItKJUspGXx+TGQoOy13xvgUK/3Gx V4teAI4+ImE0YbQiugZS273ah4zQefupZkpVe0ZFsjtcxSuyzDOz271YvhUddV5PzsJY /K/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WR8uiLKG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id y10-20020a17090322ca00b001d09c539cd5si1111535plg.133.2023.12.03.18.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 18:36:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WR8uiLKG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3D0A2806D810; Sun, 3 Dec 2023 18:36:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229918AbjLDCgM (ORCPT + 99 others); Sun, 3 Dec 2023 21:36:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbjLDCgL (ORCPT ); Sun, 3 Dec 2023 21:36:11 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A802C5 for ; Sun, 3 Dec 2023 18:36:17 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 971D8C433C7; Mon, 4 Dec 2023 02:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701657376; bh=PYeF07rEgepH06KQnhf/cogiGP7iBaCv1QN0e6AXkSg=; h=Date:To:Cc:Subject:From:References:In-Reply-To:From; b=WR8uiLKGdRjtzzaL8yFDg1RHQwJt8ii46A4yFwPKj+OTZoKKa+rReBol14SaSly5u uaa5MGVCWn1+hWtm9xOCqb8y9UZGa0Fm0g9oiw/ic0g/baiUSTpT+/gsMWNksa4zC9 3CBcGmu4Dq4u8+1Y/lV6hcUH3vSu20rwG0OM7yszs5kXd+aeTm/8YBX/qv+L/Xutek wTSLCWmE9rn1TBKX5ABqYznVAInTD558IsCMjJvdqMsPWom/U6VepHmJHi1XrdcWKa zw/Egq91urStUPTJ2FZEWxdoZCYQPboPFCa/GOuuvtOeu0iEIorfuh1IB77pwjZug1 Ipgxav/7NShsg== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 04 Dec 2023 04:36:13 +0200 Message-Id: To: "Angga" , "Stefan Berger" , "peterhuewe@gmx.de" , "jgg@ziepe.ca" Cc: "linux-integrity@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] tpm: Start the tpm2 before running a self test. From: "Jarkko Sakkinen" X-Mailer: aerc 0.15.2 References: <20231122065528.1049819-1-hermin.anggawijaya@alliedtelesis.co.nz> <85154bfe-6bd5-440a-acc1-f01497d59af5@linux.ibm.com> In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Sun, 03 Dec 2023 18:36:26 -0800 (PST) On Mon Nov 27, 2023 at 4:02 AM EET, Angga wrote: > On 23/11/2023 1:34 am, Stefan Berger wrote: > > > > > > 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=20 > >> > >> --- > >> =C2=A0 drivers/char/tpm/tpm2-cmd.c | 8 ++++---- > >> =C2=A0 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) > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc) > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out; > >> =C2=A0 +=C2=A0=C2=A0=C2=A0 rc =3D tpm2_startup(chip); > >> +=C2=A0=C2=A0=C2=A0 if (rc && rc !=3D TPM2_RC_INITIALIZE) > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out; > >> + > > > > Most platforms should have firmware initialize the TPM 2 these days.=20 > > Therefore, a selftest should work and in case it doesn't work you fall= =20 > > back to the tpm2_startup below and if you get an error message in the= =20 > > log you at least know that you firmware is not up-to-date. > > > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D tpm2_do_selftest(chip); > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc && rc !=3D TPM2_RC_INITIALIZE) > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out; > >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc =3D=3D TPM2_RC_INITIALIZE= ) { > >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D tpm2_startup(chip); > >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc) > >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 go= to out; > >> - > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rc =3D tpm2_do_= selftest(chip); > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rc) > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 goto out; > > Hello Stefan > > Thank you for your comments. > > Unfortunately our platforms (custom hardware design) are the ones which= =20 > do not initialize/start the TPM2 from boot loader yet, and because of=20 > that the > self test in tpm2_auto_startup always produce a log error message on the= =20 > platform start up. > > While I understand your point about the log being useful for "pointing=20 > out not up-to-date firmware", but it might also generate unnecessary supp= ort > queries from some users on such platforms ? And maybe the kernel being=20 > able to deal with TPM being started more than once is better ? > > If wanted, I have the second version of the patch which consist of code= =20 > changes as in v1, plus ability for tpm2_transmit_cmd to handle multiple > attempts to start up the TPM silently, for example, once by the firmware= =20 > and another by the kernel during tpm2 auto-startup. To save your time: no. Mainline kernel is not modified based hardware prototypes. You have freedom to maintain your own kernel tree for whatever changes you need but this is totally wrong place for these type of patches. > > Kind regards > > Hermin Anggawijaya BR, Jarkko