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>,
	Thirupathaiah Annapureddy <thiruan@linux.microsoft.com>,
	Walter Lozano <walter.lozano@collabora.com>
Subject: Re: [PATCH 4/9] sandbox: tpm: Correct handling of get-capability
Date: Thu, 15 Jul 2021 21:07:38 +0300	[thread overview]
Message-ID: <YPB5atBw+iFRxzik@enceladus> (raw)
In-Reply-To: <20210705154849.2083972-5-sjg@chromium.org>

Hi Simon, 

On Mon, Jul 05, 2021 at 09:48:44AM -0600, Simon Glass wrote:
> This function current handles the kernel case incorrectly. Fix it, and
> use the shorter TPM_HDR_LEN while we are here.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  drivers/tpm/tpm_tis_sandbox.c | 14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/tpm/tpm_tis_sandbox.c b/drivers/tpm/tpm_tis_sandbox.c
> index 85b22afa4d9..efbeb00ab63 100644
> --- a/drivers/tpm/tpm_tis_sandbox.c
> +++ b/drivers/tpm/tpm_tis_sandbox.c
> @@ -140,16 +140,13 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf,
>  			printf("Get flags index %#02x\n", index);
>  			*recv_len = 22;
>  			memset(recvbuf, '\0', *recv_len);
> -			data = recvbuf + TPM_RESPONSE_HEADER_LENGTH +
> -					sizeof(uint32_t);
> +			data = recvbuf + TPM_HDR_LEN + sizeof(uint32_t);
>  			switch (index) {
>  			case FIRMWARE_NV_INDEX:
>  				break;
>  			case KERNEL_NV_INDEX:
>  				handle_cap_flag_space(&data, index);
> -				*recv_len = data - recvbuf -
> -					TPM_RESPONSE_HEADER_LENGTH -
> -					sizeof(uint32_t);
> +				*recv_len = data - recvbuf;

This is the only actual fix right?
TPM_RESPONSE_HEADER_LENGTH and TPM_HDR_LEN are both defined to 10?
Is it worth updating the commit message with exactly the problem that was
fixed?

>  				break;
>  			case TPM_CAP_FLAG_PERMANENT: {
>  				struct tpm_permanent_flags *pflags;
> @@ -166,15 +163,12 @@ static int sandbox_tpm_xfer(struct udevice *dev, const uint8_t *sendbuf,
>  				printf("   ** Unknown flags index %x\n", index);
>  				return -ENOSYS;
>  			}
> -			put_unaligned_be32(*recv_len,
> -					   recvbuf +
> -					   TPM_RESPONSE_HEADER_LENGTH);
> +			put_unaligned_be32(*recv_len, recvbuf + TPM_HDR_LEN);
>  			break;
>  		case TPM_CAP_NV_INDEX:
>  			index = get_unaligned_be32(sendbuf + 18);
>  			printf("Get cap nv index %#02x\n", index);
> -			put_unaligned_be32(22, recvbuf +
> -					   TPM_RESPONSE_HEADER_LENGTH);
> +			put_unaligned_be32(22, recvbuf + TPM_HDR_LEN);
>  			break;
>  		default:
>  			printf("   ** Unknown 0x65 command type %#02x\n",
> -- 
> 2.32.0.93.g670b81a890-goog
> 

  reply	other threads:[~2021-07-15 18:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-05 15:48 [PATCH 0/9] tpm: Enhance sandbox tpm2 emulation Simon Glass
2021-07-05 15:48 ` [PATCH 1/9] sandbox: tpm: Split out common nvdata code Simon Glass
2021-07-05 15:48 ` [PATCH 2/9] sandbox: tpm: Tidy up reading and writing of device state Simon Glass
2021-07-05 15:48 ` [PATCH 3/9] sandbox: tpm: Support the define-space command Simon Glass
2021-07-05 15:48 ` [PATCH 4/9] sandbox: tpm: Correct handling of get-capability Simon Glass
2021-07-15 18:07   ` Ilias Apalodimas [this message]
2021-07-05 15:48 ` [PATCH 5/9] sandbox: tpm: Finish comments for struct sandbox_tpm2 Simon Glass
2021-07-15 18:09   ` Ilias Apalodimas
2021-07-05 15:48 ` [PATCH 6/9] sandbox: tpm: Track whether the state is valid Simon Glass
2021-07-05 15:48 ` [PATCH 7/9] sandbox: tpm: Support nvdata in TPM2 Simon Glass
2021-07-05 15:48 ` [PATCH 8/9] sandbox: tpm: Support storing device state in tpm2 Simon Glass
2021-07-05 15:48 ` [PATCH 9/9] sandbox: tpm: Support extending a PCR multiple times Simon Glass
2021-07-15 19:04   ` Ilias Apalodimas
2021-07-15 19:20     ` Ilias Apalodimas
2021-07-20 18:33       ` Simon Glass
2021-07-14 19:51 ` [PATCH 0/9] tpm: Enhance sandbox tpm2 emulation Simon Glass
2021-07-14 21:07   ` Ilias Apalodimas
2021-07-14 22:16     ` Simon Glass

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=YPB5atBw+iFRxzik@enceladus \
    --to=ilias.apalodimas@linaro.org \
    --cc=sjg@chromium.org \
    --cc=thiruan@linux.microsoft.com \
    --cc=u-boot@lists.denx.de \
    --cc=walter.lozano@collabora.com \
    /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