linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Peter Hüwe" <PeterHuewe-Mmb7MZpHnFY@public.gmane.org>
To: Jarkko Sakkinen
	<jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: Ashley Lai <ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org>,
	Marcel Selhorst <tpmdd-yWjUBOtONefk1uMJSBkQmQ@public.gmane.org>,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	josh.triplett-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	jason.gunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org,
	linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	trousers-tech-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	Will Arthur
	<will.c.arthur-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH v9 8/8] tpm: TPM 2.0 FIFO Interface
Date: Thu, 4 Dec 2014 23:18:33 +0100	[thread overview]
Message-ID: <201412042318.33889.PeterHuewe@gmx.de> (raw)
In-Reply-To: <1417672518-4530-9-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

Hi Jarkko,

Am Donnerstag, 4. Dezember 2014, 06:55:18 schrieb Jarkko Sakkinen:
> From: Will Arthur <will.c.arthur-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> 
> Detect TPM 2.0 by using the extended STS (STS3) register. For TPM 2.0,
> instead of calling tpm_get_timeouts(), assign duration and timeout
> values defined in the TPM 2.0 PTP specification.
> 
> Signed-off-by: Will Arthur <will.c.arthur-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> ---
>  drivers/char/tpm/tpm_tis.c | 80
> ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 67
> insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 89e1abb..71cbb2d 100644
> --- a/drivers/char/tpm/tpm_tis.c
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -1,5 +1,6 @@
>  /*
>   * Copyright (C) 2005, 2006 IBM Corporation
> + * Copyright (C) 2014 Intel Corporation
>   *
>   * Authors:
>   * Leendert van Doorn <leendert-aZOuKsOsJu3MbYB6QlFGEg@public.gmane.org>
> @@ -44,6 +45,10 @@ enum tis_status {
>  	TPM_STS_DATA_EXPECT = 0x08,
>  };
> 
> +enum tis_status3 {
> +	TPM_STS3_TPM2_FAM = 0x04,
> +};
> +
>  enum tis_int_flags {
>  	TPM_GLOBAL_INT_ENABLE = 0x80000000,
>  	TPM_INTF_BURST_COUNT_STATIC = 0x100,
> @@ -70,6 +75,7 @@ enum tis_defaults {
>  #define	TPM_INT_STATUS(l)		(0x0010 | ((l) << 12))
>  #define	TPM_INTF_CAPS(l)		(0x0014 | ((l) << 12))
>  #define	TPM_STS(l)			(0x0018 | ((l) << 12))
> +#define	TPM_STS3(l)			(0x001b | ((l) << 12))
>  #define	TPM_DATA_FIFO(l)		(0x0024 | ((l) << 12))
> 
>  #define	TPM_DID_VID(l)			(0x0F00 | ((l) << 12))
> @@ -363,6 +369,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8
> *buf, size_t len) {
>  	int rc;
>  	u32 ordinal;
> +	unsigned long dur;
> 
>  	rc = tpm_tis_send_data(chip, buf, len);
>  	if (rc < 0)
> @@ -374,9 +381,14 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8
> *buf, size_t len)
> 
>  	if (chip->vendor.irq) {
>  		ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
> +
> +		if (chip->flags & TPM_CHIP_FLAG_TPM2)
> +			dur = tpm2_calc_ordinal_duration(chip, ordinal);
> +		else
> +			dur = tpm_calc_ordinal_duration(chip, ordinal);
> +
>  		if (wait_for_tpm_stat
> -		    (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
> -		     tpm_calc_ordinal_duration(chip, ordinal),
> +		    (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
>  		     &chip->vendor.read_queue, false) < 0) {
>  			rc = -ETIME;
>  			goto out_err;
> @@ -588,6 +600,7 @@ static int tpm_tis_init(struct device *dev, acpi_handle
> acpi_dev_handle, int rc, i, irq_s, irq_e, probe;
>  	struct tpm_chip *chip;
>  	struct priv_data *priv;
> +	u8 sts3;
> 
>  	priv = devm_kzalloc(dev, sizeof(struct priv_data), GFP_KERNEL);
>  	if (priv == NULL)
> @@ -604,11 +617,28 @@ static int tpm_tis_init(struct device *dev,
> acpi_handle acpi_dev_handle, if (!chip->vendor.iobase)
>  		return -EIO;
> 
> +	sts3 = ioread8(chip->vendor.iobase + TPM_STS3(1));
> +	if ((sts3 & TPM_STS3_TPM2_FAM) == TPM_STS3_TPM2_FAM)
> +		chip->flags = TPM_CHIP_FLAG_TPM2;
> +
>  	/* Default timeouts */
> -	chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> -	chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
> -	chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> -	chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> +	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
> +		chip->vendor.timeout_a = usecs_to_jiffies(TPM2_TIMEOUT_A);
> +		chip->vendor.timeout_b = usecs_to_jiffies(TPM2_TIMEOUT_B);
> +		chip->vendor.timeout_c = usecs_to_jiffies(TPM2_TIMEOUT_C);
> +		chip->vendor.timeout_d = usecs_to_jiffies(TPM2_TIMEOUT_D);
> +		chip->vendor.duration[TPM_SHORT] =
> +			usecs_to_jiffies(TPM2_DURATION_SHORT);
> +		chip->vendor.duration[TPM_MEDIUM] =
> +			usecs_to_jiffies(TPM2_DURATION_MEDIUM);
> +		chip->vendor.duration[TPM_LONG] =
> +			usecs_to_jiffies(TPM2_DURATION_LONG);
> +	} else {
> +		chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> +		chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
> +		chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> +		chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
> +	}
> 
>  	if (wait_startup(chip, 0) != 0) {
>  		rc = -ENODEV;
> @@ -623,8 +653,8 @@ static int tpm_tis_init(struct device *dev, acpi_handle
> acpi_dev_handle, vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0));
>  	chip->vendor.manufacturer_id = vendor;
> 
> -	dev_info(dev,
> -		 "1.2 TPM (device-id 0x%X, rev-id %d)\n",
> +	dev_info(dev, "%s TPM (device-id 0x%X, rev-id %d)\n",
> +		 (chip->flags & TPM_CHIP_FLAG_TPM2) ? "2.0" : "1.2",
>  		 vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0)));
> 


When loading tpm_tis force=1 with my tpm1.2 chip on a machine without bios 
integration, it fets detected as a TPM2.0 chip :/

sudo rmmod tpm_tis
# modprobe tpm_tis force=1
modprobe: ERROR: could not insert 'tpm_tis': No such device
# dmesg 
[  263.903828] tpm_tis tpm_tis: 2.0 TPM (device-id 0xB, rev-id 16)
[  263.948049] tpm_tis tpm_tis: A TPM error (10) occurred continue selftest
[  263.948120] tpm_tis tpm_tis: TPM self test failed


sts3 is reported as 0xff from my TPM1.2

Thanks,
Peter

  parent reply	other threads:[~2014-12-04 22:18 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-04  5:55 [PATCH v9 0/8] TPM 2.0 support Jarkko Sakkinen
2014-12-04  5:55 ` [PATCH v9 1/8] tpm: merge duplicate transmit_cmd() functions Jarkko Sakkinen
2014-12-04  5:55 ` [PATCH v9 2/8] tpm: two-phase chip management functions Jarkko Sakkinen
2014-12-04  5:55 ` [PATCH v9 3/8] tpm: fix raciness of PPI interface lookup Jarkko Sakkinen
     [not found]   ` <1417672518-4530-4-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-12-04 20:34     ` Peter Hüwe
     [not found] ` <1417672518-4530-1-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-12-04  5:55   ` [PATCH v9 4/8] tpm: rename chip->dev to chip->pdev Jarkko Sakkinen
     [not found]     ` <1417672518-4530-5-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-12-04 20:49       ` Peter Hüwe
2014-12-04  5:55 ` [PATCH v9 5/8] tpm: device class for tpm Jarkko Sakkinen
2014-12-04  5:55 ` [PATCH v9 6/8] tpm: TPM 2.0 baseline support Jarkko Sakkinen
     [not found]   ` <1417672518-4530-7-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-12-04 23:17     ` Peter Hüwe
     [not found]       ` <201412050017.40668.PeterHuewe-Mmb7MZpHnFY@public.gmane.org>
2014-12-05 14:13         ` Jarkko Sakkinen
     [not found]           ` <20141205141303.GF6993-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-12-05 14:35             ` Aw: " Peter Huewe
2014-12-06 11:54               ` Jarkko Sakkinen
2014-12-04  5:55 ` [PATCH v9 7/8] tpm: TPM 2.0 CRB Interface Jarkko Sakkinen
2014-12-04 20:19   ` Peter Hüwe
     [not found]     ` <201412042119.21493.PeterHuewe-Mmb7MZpHnFY@public.gmane.org>
2014-12-05 13:10       ` Jarkko Sakkinen
     [not found]   ` <1417672518-4530-8-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-12-04 22:55     ` Peter Hüwe
2014-12-04  5:55 ` [PATCH v9 8/8] tpm: TPM 2.0 FIFO Interface Jarkko Sakkinen
     [not found]   ` <1417672518-4530-9-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-12-04 15:25     ` [tpmdd-devel] " Scot Doyle
     [not found]       ` <alpine.DEB.2.11.1412041459470.5705-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2014-12-05 13:05         ` Jarkko Sakkinen
2014-12-04 22:18     ` Peter Hüwe [this message]
     [not found]       ` <201412042318.33889.PeterHuewe-Mmb7MZpHnFY@public.gmane.org>
2014-12-04 22:28         ` Peter Hüwe
     [not found]           ` <201412042328.29578.PeterHuewe-Mmb7MZpHnFY@public.gmane.org>
2014-12-05 15:01             ` Aw: " Peter Huewe
2014-12-05 20:44               ` Stefan Berger
2014-12-09 15:47               ` Jarkko Sakkinen
2014-12-04 21:46   ` Peter Hüwe
     [not found]     ` <201412042246.25662.PeterHuewe-Mmb7MZpHnFY@public.gmane.org>
2014-12-05 13:06       ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201412042318.33889.PeterHuewe@gmx.de \
    --to=peterhuewe-mmb7mzphnfy@public.gmane.org \
    --cc=ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org \
    --cc=christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    --cc=jason.gunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
    --cc=josh.triplett-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=tpmdd-yWjUBOtONefk1uMJSBkQmQ@public.gmane.org \
    --cc=trousers-tech-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=will.c.arthur-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).