public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: peterhuewe@gmx.de, safford@us.ibm.com,
	Marcel Selhorst <tpmdd@selhorst.net>,
	"moderated list:TPM DEVICE DRIVER" 
	<tpmdd-devel@lists.sourceforge.net>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tpm: introduce struct tpm_buf
Date: Tue, 2 Jun 2015 12:13:15 -0600	[thread overview]
Message-ID: <20150602181315.GE17776@obsidianresearch.com> (raw)
In-Reply-To: <1433250262-17200-1-git-send-email-jarkko.sakkinen@linux.intel.com>

On Tue, Jun 02, 2015 at 04:04:22PM +0300, Jarkko Sakkinen wrote:
> +/* A string buffer type for constructing TPM commands. This is based on the
> + * code in security/keys/trusted.h.
> + */
> +
> +#define TPM_BUF_SIZE 512
> +
> +struct tpm_buf {
> +	u8 data[TPM_BUF_SIZE];

This should be u32 or u64 to guarentee correct alignment for the
casting.


> +};
> +
> +static inline void tpm_buf_init(struct tpm_buf *buf, u16 tag, u32 ordinal)
> +{
> +	struct tpm_input_header *head;
> +
> +	head = (struct tpm_input_header *) buf->data;
> +
> +	head->tag = cpu_to_be16(tag);
> +	head->length = cpu_to_be32(sizeof(*head));
> +	head->ordinal = cpu_to_be32(ordinal);
> +}
> +
> +static inline u32 tpm_buf_length(struct tpm_buf *buf)
> +{
> +	struct tpm_input_header *head = (struct tpm_input_header *) buf->data;
> +
> +	return be32_to_cpu(head->length);
> +}
> +
> +static inline u16 tpm_buf_tag(struct tpm_buf *buf)
> +{
> +	return be16_to_cpu(*(__be16 *) &buf->data[0]);

be16_to_cpup ?

Any thought on someday using this for tpm1 as well?

Jason

  parent reply	other threads:[~2015-06-02 18:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 13:04 [PATCH] tpm: introduce struct tpm_buf Jarkko Sakkinen
2015-06-02 13:18 ` Aw: " Peter Huewe
2015-06-02 14:36   ` Jarkko Sakkinen
2015-06-02 18:13 ` Jason Gunthorpe [this message]
2015-06-03 12:23   ` Jarkko Sakkinen
2015-06-03 16:11     ` Jason Gunthorpe
2015-06-03 16:43       ` Jarkko Sakkinen
2015-06-03 16:48         ` Jason Gunthorpe
2015-06-03 17: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=20150602181315.GE17776@obsidianresearch.com \
    --to=jgunthorpe@obsidianresearch.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=safford@us.ibm.com \
    --cc=tpmdd-devel@lists.sourceforge.net \
    --cc=tpmdd@selhorst.net \
    /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