From: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Nayna Jain <nayna-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH 1/2] tpm: implement TPM 2.0 capability to get active PCR banks
Date: Sun, 9 Oct 2016 13:21:15 +0300 [thread overview]
Message-ID: <20161009102115.GA733@intel.com> (raw)
In-Reply-To: <1475979357-1167-2-git-send-email-nayna-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
On Sat, Oct 08, 2016 at 10:15:56PM -0400, Nayna Jain wrote:
> As per the TCG 2.0 spec, the extend operation should be done to
> all active PCR banks. However, current TPM 2.0 support doesn't
> have the capability implemented to get active PCR banks.
>
> This patch implements the TPM 2.0 capability TPM_CAP_PCRS to
> retrieve active PCR banks from the TPM.
>
> Signed-off-by: Nayna Jain <nayna-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
I'll try to give some guidelines how to get this done.
> +#define TPM2_GET_CAPABILITY_IN_SIZE \
> + (sizeof(struct tpm_input_header) + \
> + sizeof(struct tpm2_get_cap_in))
> +
> +static const struct tpm_input_header tpm2_get_capability_header = {
> + .tag = cpu_to_be16(TPM2_ST_NO_SESSIONS),
> + .length = cpu_to_be32(TPM2_GET_CAPABILITY_IN_SIZE),
> + .ordinal = cpu_to_be32(TPM2_CC_GET_CAPABILITY)
> +};
> +
> +int tpm2_get_capability(struct tpm_chip *chip, struct tpm2_get_cap_in *cap_in,
> + struct tpm2_get_cap_out *cap_out)
> +{
> +
> + struct tpm2_cmd cmd;
> + int rc;
> + u32 cap_id;
> +
> + cmd.header.in = tpm2_get_capability_header;
> + cmd.params.get_cap_in.cap_id = cpu_to_be32(cap_in->cap_id);
> + cmd.params.get_cap_in.property_id = cpu_to_be32(cap_in->property_id);
> + cmd.params.get_cap_in.property_cnt = cpu_to_be32(cap_in->property_cnt);
> +
> + rc = tpm_transmit_cmd(chip, (const char *) &cmd, sizeof(cmd), 0,
> + "attempting get capability operation");
> + if (rc < 0)
> + return rc;
> + cap_id = be32_to_cpu(cmd.params.get_cap_out.cap_data.cap_id);
> +
> + switch (cap_id) {
> + case TPM2_CAP_PCRS:
> + memcpy(&cap_out->cap_data, &cmd.params.get_cap_out.cap_data,
> + sizeof(cmd.params.get_cap_out.cap_data));
> + break;
> + default:
> + return -EOPNOTSUPP;
> + }
> +
> + return rc;
I think it would be better to start with a function that grabs one
attribute and call that in a loop. Performance is not an issue here and
you are storing the result. Simpler is really better in this case.
Rather refactor tpm2_get_tpm_pt to be more generic and call that in a
loop. I don't think the performance is really an issue here and you
anyway store the result to struct tpm_chip. Also, your implementation is
not generic (more_data is not taken into account).
I just sent patches that I've written for the access broker [1]. I think
it'd be better if you would use them in your patch set.
[1] https://lkml.org/lkml/2016/10/9/49
/Jarkko
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
next prev parent reply other threads:[~2016-10-09 10:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-09 2:15 [PATCH 0/2] tpm: enhance TPM 2.0 extend function to support multiple PCR banks Nayna Jain
[not found] ` <1475979357-1167-1-git-send-email-nayna-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2016-10-09 2:15 ` [PATCH 1/2] tpm: implement TPM 2.0 capability to get active " Nayna Jain
[not found] ` <1475979357-1167-2-git-send-email-nayna-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2016-10-09 9:05 ` Jarkko Sakkinen
2016-10-09 10:21 ` Jarkko Sakkinen [this message]
2016-10-09 2:15 ` [PATCH 2/2] tpm: enhance TPM 2.0 PCR extend to support multiple banks Nayna Jain
[not found] ` <1475979357-1167-3-git-send-email-nayna-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2016-10-09 6:28 ` Winkler, Tomas
[not found] ` <5B8DA87D05A7694D9FA63FD143655C1B542F6C75-Jy8z56yoSI8MvF1YICWikbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2016-10-12 16:50 ` Nayna
[not found] ` <57FE69D9.4070304-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2016-10-12 19:02 ` Winkler, Tomas
2016-10-09 9:06 ` Jarkko Sakkinen
2016-10-09 10:24 ` Jarkko Sakkinen
2016-10-09 9:08 ` [PATCH 0/2] tpm: enhance TPM 2.0 extend function to support multiple PCR banks Jarkko Sakkinen
[not found] ` <20161009090827.GC31891-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-10-09 9:29 ` Jarkko Sakkinen
[not found] ` <20161009092911.GF31891-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-10-09 10:00 ` Nayna
[not found] ` <57FA1532.30603-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2016-10-09 10:37 ` Jarkko Sakkinen
[not found] ` <20161009103705.GA2855-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2016-10-09 11:10 ` Nayna
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=20161009102115.GA733@intel.com \
--to=jarkko.sakkinen-vuqaysv1563yd54fqh9/ca@public.gmane.org \
--cc=nayna-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=tpmdd-devel-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).