public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
To: Simon Glass <sjg@chromium.org>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Masahisa Kojima <masahisa.kojima@linaro.org>,
	Ruchika Gupta <ruchika.gupta@linaro.org>
Subject: Re: [PATCH v4 7/7] tpm: Allow committing non-volatile data
Date: Sat, 3 Sep 2022 17:05:58 +0300	[thread overview]
Message-ID: <YxNfRqqs9N4raGv+@hades> (raw)
In-Reply-To: <20220823171240.386269-8-sjg@chromium.org>

Thanks Simon,

I'll queue up the series once the CI completes

On Tue, Aug 23, 2022 at 10:12:40AM -0700, Simon Glass wrote:
> Add an option to tell the TPM to commit non-volatile data immediately it
> is changed, rather than waiting until later. This is needed in some
> situations, since if the device reboots it may not write the data.
> 
> Add definitions for the rest of the Cr50 commands while we are here.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
> Changes in v4:
> - Rename function and add arguments for the command/subcmd
> 
>  include/tpm-v2.h | 17 +++++++++++++++++
>  lib/tpm-v2.c     | 21 +++++++++++++++++++++
>  2 files changed, 38 insertions(+)
> 
> diff --git a/include/tpm-v2.h b/include/tpm-v2.h
> index 36c6ac0be6e..737e57551d7 100644
> --- a/include/tpm-v2.h
> +++ b/include/tpm-v2.h
> @@ -671,4 +671,21 @@ u32 tpm2_submit_command(struct udevice *dev, const u8 *sendbuf,
>  u32 tpm2_report_state(struct udevice *dev, uint vendor_cmd, uint vendor_subcmd,
>  		      u8 *recvbuf, size_t *recv_size);
>  
> +/**
> + * tpm2_enable_nvcommits() - Tell TPM to commit NV data immediately
> + *
> + * For Chromium OS verified boot, we may reboot or reset at different times,
> + * possibly leaving non-volatile data unwritten by the TPM.
> + *
> + * This vendor command is used to indicate that non-volatile data should be
> + * written to its store immediately.
> + *
> + * @dev		TPM device
> + * @vendor_cmd:	Vendor command number to send
> + * @vendor_subcmd: Vendor sub-command number to send
> + * Return: result of the operation
> + */
> +u32 tpm2_enable_nvcommits(struct udevice *dev, uint vendor_cmd,
> +			  uint vendor_subcmd);
> +
>  #endif /* __TPM_V2_H */
> diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
> index edee9854a7c..697b982e079 100644
> --- a/lib/tpm-v2.c
> +++ b/lib/tpm-v2.c
> @@ -704,3 +704,24 @@ u32 tpm2_report_state(struct udevice *dev, uint vendor_cmd, uint vendor_subcmd,
>  
>  	return 0;
>  }
> +
> +u32 tpm2_enable_nvcommits(struct udevice *dev, uint vendor_cmd,
> +			  uint vendor_subcmd)
> +{
> +	u8 command_v2[COMMAND_BUFFER_SIZE] = {
> +		/* header 10 bytes */
> +		tpm_u16(TPM2_ST_NO_SESSIONS),		/* TAG */
> +		tpm_u32(10 + 2),			/* Length */
> +		tpm_u32(vendor_cmd),	/* Command code */
> +
> +		tpm_u16(vendor_subcmd),
> +	};
> +	int ret;
> +
> +	ret = tpm_sendrecv_command(dev, command_v2, NULL, NULL);
> +	log_debug("ret=%s, %x\n", dev->name, ret);
> +	if (ret)
> +		return ret;
> +
> +	return 0;
> +}
> -- 
> 2.37.2.609.g9ff673ca1a-goog
> 

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

      reply	other threads:[~2022-09-03 14:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 17:12 [PATCH v4 0/7] tpm: Various minor fixes and enhancements Simon Glass
2022-08-23 17:12 ` [PATCH v4 1/7] tpm: Require a digest source when extending the PCR Simon Glass
2022-08-26  6:30   ` Ilias Apalodimas
2022-08-23 17:12 ` [PATCH v4 2/7] tpm: Correct the permissions command in TPMv1 Simon Glass
2022-08-26  6:30   ` Ilias Apalodimas
2022-08-23 17:12 ` [PATCH v4 3/7] tpm: Correct the define-space command in TPMv2 Simon Glass
2022-08-26  6:31   ` Ilias Apalodimas
2022-08-23 17:12 ` [PATCH v4 4/7] tpm: sandbox: Allow init of TPM in a different phase Simon Glass
2022-08-23 17:12 ` [PATCH v4 5/7] tpm: Allow reporting the internal state Simon Glass
2022-08-26  6:37   ` Ilias Apalodimas
2022-08-23 17:12 ` [PATCH v4 6/7] tpm: Implement state command for Cr50 Simon Glass
2022-08-24  8:32   ` Ilias Apalodimas
2022-09-03 13:51   ` Ilias Apalodimas
2022-08-23 17:12 ` [PATCH v4 7/7] tpm: Allow committing non-volatile data Simon Glass
2022-09-03 14:05   ` Ilias Apalodimas [this message]

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=YxNfRqqs9N4raGv+@hades \
    --to=ilias.apalodimas@linaro.org \
    --cc=masahisa.kojima@linaro.org \
    --cc=ruchika.gupta@linaro.org \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /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