From: Jarkko Sakkinen <jarkko@kernel.org>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Naveen N Rao <naveen@kernel.org>,
Sumit Garg <sumit.garg@kernel.org>,
linux-integrity@vger.kernel.org, Peter Huewe <peterhuewe@gmx.de>,
Jens Wiklander <jens.wiklander@linaro.org>,
James Bottomley <James.Bottomley@hansenpartnership.com>,
linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Nicholas Piggin <npiggin@gmail.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
Michael Ellerman <mpe@ellerman.id.au>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Madhavan Srinivasan <maddy@linux.ibm.com>
Subject: Re: [PATCH v6 4/4] tpm/tpm_svsm: support TPM_CHIP_FLAG_SYNC
Date: Wed, 25 Jun 2025 15:02:49 +0300 [thread overview]
Message-ID: <aFvlaY0BNjaGxU1D@kernel.org> (raw)
In-Reply-To: <20250620130810.99069-5-sgarzare@redhat.com>
On Fri, Jun 20, 2025 at 03:08:10PM +0200, Stefano Garzarella wrote:
> From: Stefano Garzarella <sgarzare@redhat.com>
>
> This driver does not support interrupts, and receiving the response is
> synchronous with sending the command.
>
> Enable synchronous send() with TPM_CHIP_FLAG_SYNC, which implies that
> ->send() already fills the provided buffer with a response, and ->recv()
> is not implemented.
>
> Keep using the same pre-allocated buffer to avoid having to allocate
> it for each command. We need the buffer to have the header required by
> the SVSM protocol and the command contiguous in memory.
>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> v5:
> - changed order and parameter names to match tpm_try_transmit() [Jarkko]
> v4:
> - reworked commit description [Jarkko]
> ---
> drivers/char/tpm/tpm_svsm.c | 27 +++++++++++----------------
> 1 file changed, 11 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_svsm.c b/drivers/char/tpm/tpm_svsm.c
> index 0847cbf450b4..f5ba0f64850b 100644
> --- a/drivers/char/tpm/tpm_svsm.c
> +++ b/drivers/char/tpm/tpm_svsm.c
> @@ -26,37 +26,31 @@ struct tpm_svsm_priv {
> };
>
> static int tpm_svsm_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
> - size_t len)
> + size_t cmd_len)
> {
> struct tpm_svsm_priv *priv = dev_get_drvdata(&chip->dev);
> int ret;
>
> - ret = svsm_vtpm_cmd_request_fill(priv->buffer, 0, buf, len);
> + ret = svsm_vtpm_cmd_request_fill(priv->buffer, 0, buf, cmd_len);
> if (ret)
> return ret;
>
> /*
> * The SVSM call uses the same buffer for the command and for the
> - * response, so after this call, the buffer will contain the response
> - * that can be used by .recv() op.
> + * response, so after this call, the buffer will contain the response.
> + *
> + * Note: we have to use an internal buffer because the device in SVSM
> + * expects the svsm_vtpm header + data to be physically contiguous.
> */
> - return snp_svsm_vtpm_send_command(priv->buffer);
> -}
> -
> -static int tpm_svsm_recv(struct tpm_chip *chip, u8 *buf, size_t len)
> -{
> - struct tpm_svsm_priv *priv = dev_get_drvdata(&chip->dev);
> + ret = snp_svsm_vtpm_send_command(priv->buffer);
> + if (ret)
> + return ret;
>
> - /*
> - * The internal buffer contains the response after we send the command
> - * to SVSM.
> - */
> - return svsm_vtpm_cmd_response_parse(priv->buffer, buf, len);
> + return svsm_vtpm_cmd_response_parse(priv->buffer, buf, bufsiz);
> }
>
> static struct tpm_class_ops tpm_chip_ops = {
> .flags = TPM_OPS_AUTO_STARTUP,
> - .recv = tpm_svsm_recv,
> .send = tpm_svsm_send,
> };
>
> @@ -85,6 +79,7 @@ static int __init tpm_svsm_probe(struct platform_device *pdev)
>
> dev_set_drvdata(&chip->dev, priv);
>
> + chip->flags |= TPM_CHIP_FLAG_SYNC;
> err = tpm2_probe(chip);
> if (err)
> return err;
> --
> 2.49.0
>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
next prev parent reply other threads:[~2025-06-25 16:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-20 13:08 [PATCH v6 0/4] tpm: add support for sync send() and use it in ftpm and svsm drivers Stefano Garzarella
2025-06-20 13:08 ` [PATCH v6 1/4] tpm: add bufsiz parameter in the .send callback Stefano Garzarella
2025-06-25 12:00 ` Jarkko Sakkinen
2025-06-20 13:08 ` [PATCH v6 2/4] tpm: support devices with synchronous send() Stefano Garzarella
2025-06-20 13:08 ` [PATCH v6 3/4] tpm/tpm_ftpm_tee: support TPM_CHIP_FLAG_SYNC Stefano Garzarella
2025-06-25 12:01 ` Jarkko Sakkinen
2025-06-20 13:08 ` [PATCH v6 4/4] tpm/tpm_svsm: " Stefano Garzarella
2025-06-25 12:02 ` Jarkko Sakkinen [this message]
2025-06-25 15:08 ` Jarkko Sakkinen
2025-06-25 16:42 ` Stefano Garzarella
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=aFvlaY0BNjaGxU1D@kernel.org \
--to=jarkko@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=alexandre.belloni@bootlin.com \
--cc=christophe.leroy@csgroup.eu \
--cc=claudiu.beznea@tuxon.dev \
--cc=jens.wiklander@linaro.org \
--cc=jgg@ziepe.ca \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=naveen@kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=npiggin@gmail.com \
--cc=peterhuewe@gmx.de \
--cc=sgarzare@redhat.com \
--cc=sumit.garg@kernel.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).