Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1576452 > unrolled thread

[PATCH 2/6] tpm: export tpm2_flush_context_cmd

Started byJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
First post2017-02-08 12:20 +0100
Last post2017-02-10 08:50 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 2/6] tpm: export tpm2_flush_context_cmd Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-02-08 12:20 +0100
    Re: [PATCH 2/6] tpm: export tpm2_flush_context_cmd Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-02-08 19:10 +0100
      Re: [PATCH 2/6] tpm: export tpm2_flush_context_cmd Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-02-10 08:50 +0100

#1576452 — [PATCH 2/6] tpm: export tpm2_flush_context_cmd

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2017-02-08 12:20 +0100
Subject[PATCH 2/6] tpm: export tpm2_flush_context_cmd
Message-ID<t8ys1-84Y-13@gated-at.bofh.it>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 drivers/char/tpm/tpm.h      |  2 ++
 drivers/char/tpm/tpm2-cmd.c | 62 +++++++++++++++++++++------------------------
 2 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 4f21e42..ba483f1 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -554,6 +554,8 @@ int tpm2_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf);
 int tpm2_pcr_extend(struct tpm_chip *chip, int pcr_idx, u32 count,
 		    struct tpm2_digest *digests);
 int tpm2_get_random(struct tpm_chip *chip, u8 *out, size_t max);
+void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
+			    unsigned int flags);
 int tpm2_seal_trusted(struct tpm_chip *chip,
 		      struct trusted_key_payload *payload,
 		      struct trusted_key_options *options);
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index fe57fce..86565a9 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -419,6 +419,35 @@ static const struct tpm_input_header tpm2_get_tpm_pt_header = {
 };
 
 /**
+ * tpm2_flush_context_cmd() - execute a TPM2_FlushContext command
+ * @chip: TPM chip to use
+ * @payload: the key data in clear and encrypted form
+ * @options: authentication values and other options
+ *
+ * Return: same as with tpm_transmit_cmd
+ */
+void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
+			    unsigned int flags)
+{
+	struct tpm_buf buf;
+	int rc;
+
+	rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_FLUSH_CONTEXT);
+	if (rc) {
+		dev_warn(&chip->dev, "0x%08x was not flushed, out of memory\n",
+			 handle);
+		return;
+	}
+
+	tpm_buf_append_u32(&buf, handle);
+
+	(void) tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, 0, flags,
+				"flushing context");
+
+	tpm_buf_destroy(&buf);
+}
+
+/**
  * tpm_buf_append_auth() - append TPMS_AUTH_COMMAND to the buffer.
  *
  * @buf: an allocated tpm_buf instance
@@ -628,39 +657,6 @@ static int tpm2_load_cmd(struct tpm_chip *chip,
 }
 
 /**
- * tpm2_flush_context_cmd() - execute a TPM2_FlushContext command
- *
- * @chip: TPM chip to use
- * @handle: the key data in clear and encrypted form
- * @flags: tpm transmit flags
- *
- * Return: Same as with tpm_transmit_cmd.
- */
-static void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
-				   unsigned int flags)
-{
-	struct tpm_buf buf;
-	int rc;
-
-	rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_FLUSH_CONTEXT);
-	if (rc) {
-		dev_warn(&chip->dev, "0x%08x was not flushed, out of memory\n",
-			 handle);
-		return;
-	}
-
-	tpm_buf_append_u32(&buf, handle);
-
-	rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, 0, flags,
-			      "flushing context");
-	if (rc)
-		dev_warn(&chip->dev, "0x%08x was not flushed, rc=%d\n", handle,
-			 rc);
-
-	tpm_buf_destroy(&buf);
-}
-
-/**
  * tpm2_unseal_cmd() - execute a TPM2_Unload command
  *
  * @chip: TPM chip to use
-- 
2.9.3

[toc] | [next] | [standalone]


#1576791

FromJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Date2017-02-08 19:10 +0100
Message-ID<t8EQN-3Ed-1@gated-at.bofh.it>
In reply to#1576452
>  /**
> + * tpm2_flush_context_cmd() - execute a TPM2_FlushContext command
> + * @chip: TPM chip to use
> + * @payload: the key data in clear and encrypted form
> + * @options: authentication values and other options
> + *
> + * Return: same as with tpm_transmit_cmd
> + */
> +void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
> +			    unsigned int flags)

Why did you move the function in the same file? Adding a prototype
shouldn't require that..

Jason

[toc] | [prev] | [next] | [standalone]


#1578240

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2017-02-10 08:50 +0100
Message-ID<t9e7U-tH-31@gated-at.bofh.it>
In reply to#1576791
On Wed, Feb 08, 2017 at 10:58:30AM -0700, Jason Gunthorpe wrote:
> >  /**
> > + * tpm2_flush_context_cmd() - execute a TPM2_FlushContext command
> > + * @chip: TPM chip to use
> > + * @payload: the key data in clear and encrypted form
> > + * @options: authentication values and other options
> > + *
> > + * Return: same as with tpm_transmit_cmd
> > + */
> > +void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
> > +			    unsigned int flags)
> 
> Why did you move the function in the same file? Adding a prototype
> shouldn't require that..
> 
> Jason

To be logically positioned in the same way as it is in the header.

It cannot in-between the helper functions for tpm2_seal_trusted().

/Jarkko

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web