From: Stefan Berger <stefanb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: Jarkko Sakkinen
<jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: Peter Huewe <peterhuewe-Mmb7MZpHnFY@public.gmane.org>,
Ashley Lai <ashley-fm2HMyfA2y6tG0bUXCXiUA@public.gmane.org>,
Marcel Selhorst <tpmdd-yWjUBOtONefk1uMJSBkQmQ@public.gmane.org>,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
josh.triplett-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
jason.gunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org,
trousers-tech-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [tpmdd-devel] [PATCH v7 08/10] tpm: TPM 2.0 CRB Interface
Date: Fri, 28 Nov 2014 12:23:51 -0500 [thread overview]
Message-ID: <5478AFA7.6040200@linux.vnet.ibm.com> (raw)
In-Reply-To: <20141127154023.GD24791-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
On 11/27/2014 10:40 AM, Jarkko Sakkinen wrote:
> On Wed, Nov 26, 2014 at 09:06:57AM -0500, Stefan Berger wrote:
>> On 11/11/2014 08:45 AM, Jarkko Sakkinen wrote:
>>> tpm_crb is a driver for TPM 2.0 Command Response Buffer (CRB) Interface
>>> as defined in PC Client Platform TPM Profile (PTP) Specification.
>>>
>>> Only polling and single locality is supported as these are the limitations
>>> of the available hardware, Platform Trust Techonlogy (PTT) in Haswell
>>> CPUs.
>>>
>>> The driver always applies CRB with ACPI start because PTT reports using
>>> only ACPI start as start method but as a result of my testing it requires
>>> also CRB start.
>>>
>>> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
>>> ---
>>>
[...]
>>> +static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
>>> +{
>>> + struct crb_priv *priv = chip->vendor.priv;
>>> + struct crb_control_area *cca;
>>> + u8 *cmd;
>>> + int rc = 0;
>>> +
>>> + cca = priv->cca;
>>> +
>>> + if (len > le32_to_cpu(cca->cmd_size)) {
>>> + dev_err(&chip->dev,
>>> + "invalid command count value %x %zx\n",
>>> + (unsigned int) len,
>>> + (size_t) le32_to_cpu(cca->cmd_size));
>>> + return -E2BIG;
>>> + }
>>> +
>>> + cmd = (u8 *) ((unsigned long) cca + le64_to_cpu(cca->cmd_pa) -
>>> + priv->cca_pa);
>> cca = priv->cca per statement above -> cmd = cca + x - cca = x
>>
>> -> cmd = le64_to_cpu(cca->cmd_pa);
>>
>> Should do the trick, no ?
> Virtual address might be different where CCA is ioremapped.
My bad. Is the 'Command Address' then guaranteed to lie within the
remapped area of the 'Control Area' or should there be a check whether
you would need a separate remapping? It's not clear from the specs where
it lies (2.1 4th paragraph: "They can all be in system RAM, or all be in
device memory, or any combination"). Same is true for the 'Response
Address'. Maybe you should have the ioremapped address for the 'Command
Address' calculated elsewhere and simplify the address calculation here
to basically cmd = priv->command_address.
Make the address calculations in cbr_recv and crb_send look the same.
[So, (cca - priv->cca_pa) calculates the offset of the remapping.
Adding to this the address of the command buffer gives the ioremapped
address of the command buffer, assuming it lies within that remapped area. ]
Stefan
>
>>> + memcpy(cmd, buf, len);
>>> +
>>> + /* Make sure that cmd is populated before issuing start. */
>>> + wmb();
>>> +
>>> + cca->start = cpu_to_le32(1);
>>> + rc = crb_do_acpi_start(chip);
next prev parent reply other threads:[~2014-11-28 17:23 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-11 13:45 [PATCH v7 00/10] TPM 2.0 support Jarkko Sakkinen
[not found] ` <1415713513-16524-1-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-11-11 13:45 ` [PATCH v7 01/10] tpm: merge duplicate transmit_cmd() functions Jarkko Sakkinen
2014-11-25 21:18 ` [tpmdd-devel] " Stefan Berger
[not found] ` <5474F22F.1030301-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2014-11-27 11:43 ` Jarkko Sakkinen
2014-11-11 13:45 ` [PATCH v7 02/10] tpm: two-phase chip management functions Jarkko Sakkinen
[not found] ` <1415713513-16524-3-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-11-26 14:38 ` [tpmdd-devel] " Stefan Berger
2014-11-11 13:45 ` [PATCH v7 03/10] tpm: fix multiple race conditions in tpm_ppi.c Jarkko Sakkinen
2014-11-25 21:40 ` [tpmdd-devel] " Stefan Berger
2014-11-11 13:45 ` [PATCH v7 04/10] tpm: rename chip->dev to chip->pdev Jarkko Sakkinen
[not found] ` <1415713513-16524-5-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-11-25 21:44 ` [tpmdd-devel] " Stefan Berger
[not found] ` <5474F855.7080207-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2014-11-27 14:51 ` Jarkko Sakkinen
2014-11-11 13:45 ` [PATCH v7 05/10] tpm: device class for tpm Jarkko Sakkinen
[not found] ` <1415713513-16524-6-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-11-26 12:34 ` [tpmdd-devel] " Stefan Berger
2014-11-11 13:45 ` [PATCH v7 06/10] tpm: fix: move sysfs attributes to the correct place Jarkko Sakkinen
[not found] ` <1415713513-16524-7-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-11-18 9:29 ` Jarkko Sakkinen
2014-11-26 0:48 ` [tpmdd-devel] " Stefan Berger
2014-11-11 13:45 ` [PATCH v7 07/10] tpm: TPM 2.0 baseline support Jarkko Sakkinen
[not found] ` <1415713513-16524-8-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-11-26 0:42 ` [tpmdd-devel] " Stefan Berger
[not found] ` <547521F1.7040209-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2014-12-01 17:55 ` Jarkko Sakkinen
2014-11-11 13:45 ` [PATCH v7 08/10] tpm: TPM 2.0 CRB Interface Jarkko Sakkinen
[not found] ` <1415713513-16524-9-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-11-26 14:06 ` [tpmdd-devel] " Stefan Berger
[not found] ` <5475DE81.50308-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2014-11-27 15:40 ` Jarkko Sakkinen
[not found] ` <20141127154023.GD24791-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-11-28 17:23 ` Stefan Berger [this message]
2014-12-01 13:26 ` Jarkko Sakkinen
2014-11-11 13:45 ` [PATCH v7 09/10] tpm: TPM 2.0 FIFO Interface Jarkko Sakkinen
[not found] ` <1415713513-16524-10-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-11-25 21:52 ` [tpmdd-devel] " Stefan Berger
2014-11-26 18:10 ` Jarkko Sakkinen
2014-11-27 1:38 ` Stefan Berger
2014-11-11 13:45 ` [PATCH v7 10/10] tpm: TPM 2.0 sysfs attributes Jarkko Sakkinen
[not found] ` <1415713513-16524-11-git-send-email-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-11-25 23:55 ` [tpmdd-devel] " Stefan Berger
2014-11-18 6:33 ` [PATCH v7 00/10] TPM 2.0 support 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=5478AFA7.6040200@linux.vnet.ibm.com \
--to=stefanb-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@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=peterhuewe-Mmb7MZpHnFY@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 \
/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).