[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <32f0bc58-c0a1-4c11-bd02-c6e61b0e2eb6@apertussolutions.com>
Date: Thu, 15 Aug 2024 15:24:00 -0400
From: "Daniel P. Smith" <dpsmith@...rtussolutions.com>
To: Jarkko Sakkinen <jarkko@...nel.org>,
Ross Philipson <ross.philipson@...cle.com>, linux-kernel@...r.kernel.org,
x86@...nel.org, linux-integrity@...r.kernel.org, linux-doc@...r.kernel.org,
linux-crypto@...r.kernel.org, kexec@...ts.infradead.org,
linux-efi@...r.kernel.org, iommu@...ts.linux-foundation.org
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com,
dave.hansen@...ux.intel.com, ardb@...nel.org, mjg59@...f.ucam.org,
James.Bottomley@...senpartnership.com, peterhuewe@....de, jgg@...pe.ca,
luto@...capital.net, nivedita@...m.mit.edu, herbert@...dor.apana.org.au,
davem@...emloft.net, corbet@....net, ebiederm@...ssion.com,
dwmw2@...radead.org, baolu.lu@...ux.intel.com, kanth.ghatraju@...cle.com,
andrew.cooper3@...rix.com, trenchboot-devel@...glegroups.com
Subject: Re: [PATCH v9 14/19] tpm: Ensure tpm is in known state at startup
On 6/4/24 16:14, Jarkko Sakkinen wrote:
> On Fri May 31, 2024 at 4:03 AM EEST, Ross Philipson wrote:
>> From: "Daniel P. Smith" <dpsmith@...rtussolutions.com>
>>
>> When tis core initializes, it assumes all localities are closed. There
>
> s/tis_core/tpm_tis_core/
Ack.
>> are cases when this may not be the case. This commit addresses this by
>> ensuring all localities are closed before initializing begins.
>>
>> Signed-off-by: Daniel P. Smith <dpsmith@...rtussolutions.com>
>> Signed-off-by: Ross Philipson <ross.philipson@...cle.com>
>> ---
>> 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_core.c
>> index 7c1761bd6000..9fb53bb3e73f 100644
>> --- a/drivers/char/tpm/tpm_tis_core.c
>> +++ b/drivers/char/tpm/tpm_tis_core.c
>> @@ -1104,7 +1104,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
>> u32 intmask;
>> u32 clkrun_val;
>> u8 rid;
>> - int rc, probe;
>> + int rc, probe, i;
>> struct tpm_chip *chip;
>>
>> chip = tpmm_chip_alloc(dev, &tpm_tis);
>> @@ -1166,6 +1166,15 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq,
>> goto out_err;
>> }
>>
>> + /*
>> + * There are environments, like Intel TXT, that may leave a TPM
>
> What else at this point than Intel TXT reflecting the state of the
> mainline?
Leaving the TPM in Locality 2 is a requirement of the TCG D-RTM
specification. This will be the situation for AMD and Arm as well. The
comment can be updated to ref the TCG spec instead of a specific
implementation.
>> + * locality open. Close all localities to start from a known state.
>> + */
>> + for (i = 0; i <= TPM_MAX_LOCALITY; i++) {
>> + if (check_locality(chip, i))
>> + tpm_tis_relinquish_locality(chip, i);
>> + }
>
> To be strict this should be enabled only for x86 platforms.
>
> I.e. should be flagged.
As mentioned above, this will also affect Arm.
>> +
>> /* Take control of the TPM's interrupt hardware and shut it off */
>> rc = 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 c17e4efbb2e5..363f7078c3a9 100644
>> --- a/include/linux/tpm.h
>> +++ b/include/linux/tpm.h
>> @@ -147,6 +147,12 @@ struct tpm_chip_seqops {
>> */
>> #define TPM2_MAX_CONTEXT_SIZE 4096
>>
>> +/*
>> + * 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;
>
>
> BR, Jarkko
v/r,
dps
Powered by blists - more mailing lists