From: Stefano Garzarella <sgarzare@redhat.com>
To: Jarkko Sakkinen <jarkko@kernel.org>
Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org,
James Bottomley <James.Bottomley@HansenPartnership.com>,
Peter Huewe <peterhuewe@gmx.de>, Jason Gunthorpe <jgg@ziepe.ca>,
Stefano Garzarella <sgarzare@redhat.com>
Subject: [RFC PATCH 3/3] tpm/tpm_svsm: use send_recv() op
Date: Tue, 11 Mar 2025 11:01:30 +0100 [thread overview]
Message-ID: <20250311100130.42169-4-sgarzare@redhat.com> (raw)
In-Reply-To: <20250311100130.42169-1-sgarzare@redhat.com>
This driver does not support interrupts, and receiving the response is
synchronous with sending the command.
Let's simplify the driver by implementing the new send_recv() op.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
Note: this is based on "[PATCH v3 0/4] Enlightened vTPM support for SVSM
on SEV-SNP" series [1].
If we will merge this series before it, we can just ignore this patch
and I'll squash these changes in that series.
[1] https://lore.kernel.org/linux-integrity/20250311094225.35129-1-sgarzare@redhat.com/
---
drivers/char/tpm/tpm_svsm.c | 46 ++++++++-----------------------------
1 file changed, 9 insertions(+), 37 deletions(-)
diff --git a/drivers/char/tpm/tpm_svsm.c b/drivers/char/tpm/tpm_svsm.c
index 5540d0227eed..63208313f86e 100644
--- a/drivers/char/tpm/tpm_svsm.c
+++ b/drivers/char/tpm/tpm_svsm.c
@@ -25,60 +25,32 @@ struct tpm_svsm_priv {
u8 locality;
};
-static int tpm_svsm_send(struct tpm_chip *chip, u8 *buf, size_t len)
+static int tpm_svsm_send_recv(struct tpm_chip *chip, u8 *buf, size_t buf_len,
+ size_t cmd_len)
{
struct tpm_svsm_priv *priv = dev_get_drvdata(&chip->dev);
int ret;
ret = svsm_vtpm_fill_cmd_req((struct tpm_send_cmd_req *)priv->buffer,
- priv->locality, buf, len);
+ priv->locality, 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.
*/
- 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_parse_cmd_resp((struct tpm_send_cmd_resp *)priv->buffer,
- buf, len);
-}
-
-static void tpm_svsm_cancel(struct tpm_chip *chip)
-{
- /* not supported */
-}
-
-static u8 tpm_svsm_status(struct tpm_chip *chip)
-{
- return 0;
-}
-
-static bool tpm_svsm_req_canceled(struct tpm_chip *chip, u8 status)
-{
- return false;
+ buf, buf_len);
}
static struct tpm_class_ops tpm_chip_ops = {
.flags = TPM_OPS_AUTO_STARTUP,
- .recv = tpm_svsm_recv,
- .send = tpm_svsm_send,
- .cancel = tpm_svsm_cancel,
- .status = tpm_svsm_status,
- .req_complete_mask = 0,
- .req_complete_val = 0,
- .req_canceled = tpm_svsm_req_canceled,
+ .send_recv = tpm_svsm_send_recv,
};
static int __init tpm_svsm_probe(struct platform_device *pdev)
--
2.48.1
next prev parent reply other threads:[~2025-03-11 10:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 10:01 [RFC PATCH 0/3] tpm: add send_recv() op and use it in tpm_ftpm_tee and tpm_svsm drivers Stefano Garzarella
2025-03-11 10:01 ` [RFC PATCH 1/3] tpm: add send_recv() op in tpm_class_ops Stefano Garzarella
2025-03-11 10:01 ` [RFC PATCH 2/3] tpm/tpm_ftpm_tee: use send_recv() op Stefano Garzarella
2025-03-13 9:12 ` Sumit Garg
2025-03-13 12:59 ` Jens Wiklander
2025-03-18 10:55 ` Stefano Garzarella
2025-03-11 10:01 ` Stefano Garzarella [this message]
2025-03-19 19:58 ` [RFC PATCH 3/3] tpm/tpm_svsm: " Jason Gunthorpe
2025-03-20 11:15 ` 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=20250311100130.42169-4-sgarzare@redhat.com \
--to=sgarzare@redhat.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterhuewe@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