Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp485184rdb; Thu, 1 Feb 2024 14:44:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6ynMl1iHRIfYGqFTzje8QIPAVcIb6VB37D6Hgkqyi8wGhCp/qXPr7BXAiBPBIsJ1d/ZSZ X-Received: by 2002:a62:d11d:0:b0:6db:d986:5c1a with SMTP id z29-20020a62d11d000000b006dbd9865c1amr3661871pfg.25.1706827487976; Thu, 01 Feb 2024 14:44:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706827487; cv=pass; d=google.com; s=arc-20160816; b=C0VbCeE7fpgyKcGzigKE+jw0cSTD9QOl90KSVt8uigO5nlpB1AcGFQgoUOBvK12Rky aXSBKnh6zut2TYuuMUKhpjBBp7P2feY/3jSmbEee6whke5N454e9tERjX2i7QMP/UUer OEmwd1fS8ahCMpRDwuL3nk++zHevSymwUdv27PAT/ig9c9w05Pn48UdsGnVL0IwgeIMP Sbwv9LBnJnd1uAmXkEPkCbJSHb83MZeAUE8dsD7kGmcgvuCXErd2aExbw3lrEZCN40PS A3tOVqPMuS++/V6kY9onhgjlI6f9pupCUQDxxbk6PU+xRaN5hBiJrP6q5agIWvTtHDdy 3fkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:message-id:cc:to:from:subject:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=6F7B9MOL16YOVRp8RMKzX2HUSDeK7XH11Syhxp+j90o=; fh=pcUF66KQVNmrX64z53k/gzz1jj/4Ay0Zc9aceWpU6ts=; b=bVwWDVAWjg73ZUKtG/Jqf89qu1qOH4VccmD6huqxEoLFvQg5h+ILgl8pr6tA7hjVzZ stcSTD2WhfgoC2tyCGjvjTJGp760aWw472yjNoaKrZtCjRkMRFeoaSiZ9sJEWjnkNSav Ld30sMWmiKu0LwfQpa00uEnVuzH+DB65XJpYRLwkQIxn4bIW18ea7WOt+2g6SjVLT3dn wB8GbF0am73c4qI2RCAc1SSSnObs+Qn87JIKNUkyzGgXhLrc/qtLXsGLslyIMmHZ9CWU RhZ1GzrBLw/IWMjTQrOAdc0dCOD2AvHk38uJMv2v64sKc+wrpT45LmFKY2i3ts3OXJ6P Fomg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q1XfYw9e; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-48947-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48947-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUxnnO27vmFP9xk8RfPX0ssLIwOshJhURS1WAUNSFsK91kxpfRwPFo9ENZJcyaelcdi5sBIdP65/Jnda3aM5sV1JqvIKxUalidNmj42kQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g8-20020aa79f08000000b006ddc1bf70ecsi389079pfr.34.2024.02.01.14.44.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 14:44:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48947-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q1XfYw9e; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-48947-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48947-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id DC1F2B2277E for ; Thu, 1 Feb 2024 22:33:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 62E7C46433; Thu, 1 Feb 2024 22:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q1XfYw9e" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8758046439; Thu, 1 Feb 2024 22:33:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706826809; cv=none; b=pb/WV8Ae5K5v5VrJztAtCWD1FVpiJFqm2y2NjoDIX6bU84uLxFViXlsywYPmw/xnb/vmmZBpC98lC1NDRcjePbHyLpMpEK0Elac0S1BjlBBlz69LjkARQbLiiKlzkpQV4bQcMFHu6EK1/syOSAddzku2kUsPJg0Lr1Q1ici8bIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706826809; c=relaxed/simple; bh=dbpaJ6xp7dnMzLTQgOGkgQ/59dglQ1pro5UKwxRA1ZI=; h=Mime-Version:Content-Type:Date:Subject:From:To:Cc:Message-Id: References:In-Reply-To; b=jhF1Sn0PtpM5IBipeZevE+V9trzkXP5Hl2xZWGY+gncX4QDEaITlPdlzYGr/IkxzLewFFnE414ToSVloYViHybdtUEctyQPrNHaJ3roMoy3lQEEH4Beht+jrPv33rUnT9Ng6eyTcY+wtK6wYOd4nfaNyz4dmB5s9fOiPcplxcxg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q1XfYw9e; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5769C433C7; Thu, 1 Feb 2024 22:33:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706826809; bh=dbpaJ6xp7dnMzLTQgOGkgQ/59dglQ1pro5UKwxRA1ZI=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=Q1XfYw9eheza+NUrhrdtku/nykjTnSunIqOZjdzuF5y6IfPJpn8ETdm6pxs6XsyS1 9pA8xZNw3L833Awrw4mQQH8n7gluq1R1T5GvA1yn+mbqf2/KSK7JGmPx/DL5NZPlK/ kXHL/ewGeFBlFiuzqcpE6u62g6+Cltdv08gtwDDEtUF6LoZQnyugUO6xCgXHtVG4LL O5DUH5iLNKfsC3kGjAvIy1R3R4cId3L0SsWYtDOL+E7vwhBm1iqmD/FbUv24yv2fhK b23FDmjFIATI2K/oEaa0BvAUl/OtW1Vuy21WnPbFgwRE11w6GoL0HTxpoQu9cu2gty /w2VtnOLimZdg== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 02 Feb 2024 00:33:25 +0200 Subject: Re: [PATCH 2/3] tpm: ensure tpm is in known state at startup From: "Jarkko Sakkinen" To: "Daniel P. Smith" , "Jason Gunthorpe" , , Cc: "Ross Philipson" , "Peter Huewe" Message-Id: X-Mailer: aerc 0.15.2 References: <20240131170824.6183-1-dpsmith@apertussolutions.com> <20240131170824.6183-3-dpsmith@apertussolutions.com> In-Reply-To: <20240131170824.6183-3-dpsmith@apertussolutions.com> On Wed Jan 31, 2024 at 7:08 PM EET, Daniel P. Smith wrote: > When tis core initializes, it assumes all localities are closed. There ~~~~~~~~ tpm_tis_core > are cases when this may not be the case. This commit addresses this by > ensuring all localities are closed before initializing begins. Remove the last sentence and replace with this paragraph: "Address this by ensuring all the localities are closed in the beginning of tpm_tis_core_init(). There are environments, like Intel TXT, which may leave a locality open. Close all localities to start from a known state." BTW, why we should motivated to take this patch anyway? Since the patch is not marked as a bug fix the commit message must pitch why it is important to care. > Signed-off-by: Daniel P. Smith > Signed-off-by: Ross Philipson > --- > drivers/char/tpm/tpm_tis_core.c | 11 ++++++++++- > include/linux/tpm.h | 6 ++++++ > 2 files changed, 16 insertions(+), 1 deletion(-) > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_c= ore.c > index 4176d3bd1f04..5709f87991d9 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -1109,7 +1109,7 @@ int tpm_tis_core_init(struct device *dev, struct tp= m_tis_data *priv, int irq, > u32 intmask; > u32 clkrun_val; > u8 rid; > - int rc, probe; > + int rc, probe, i; > struct tpm_chip *chip; > =20 > chip =3D tpmm_chip_alloc(dev, &tpm_tis); > @@ -1170,6 +1170,15 @@ int tpm_tis_core_init(struct device *dev, struct t= pm_tis_data *priv, int irq, > goto out_err; > } > =20 > + /* > + * There are environments, like Intel TXT, that may leave a TPM > + * locality open. Close all localities to start from a known state. > + */ > + for (i =3D 0; i <=3D TPM_MAX_LOCALITY; i++) { > + if (check_locality(chip, i)) > + tpm_tis_relinquish_locality(chip, i); > + } > + > /* Take control of the TPM's interrupt hardware and shut it off */ > rc =3D tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); > if (rc < 0) > diff --git a/include/linux/tpm.h b/include/linux/tpm.h > index 4ee9d13749ad..abe0d44d00ee 100644 > --- a/include/linux/tpm.h > +++ b/include/linux/tpm.h > @@ -116,6 +116,12 @@ struct tpm_chip_seqops { > const struct seq_operations *seqops; > }; > =20 > +/* > + * The maximum locality (0 - 4) for a TPM, as defined in section 3.2 of = the > + * Client Platform Profile Specification. > + */ > +#define TPM_MAX_LOCALITY 4 > + > struct tpm_chip { > struct device dev; > struct device devs; Is there a dependency to 1/3? BR, Jarkko