From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7D96C7EE2A for ; Wed, 25 Jun 2025 16:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6ErPyd7an14yCl0+kH7+xShDnNFRVdUpt63D6DRuGz4=; b=I2WnrnnvKQp4OIEIf/q7U07p/7 EJK8miHev+8AYfx3Dti23ZWrhrVgH9T5jqZK8pDEqAXJtufI8ZumV49eWq/JmXRWl9sRXG/ziqx6Z Gf+2oytKZTMh66EIyLDHFVdwOwpvO6/CYrMZV5y1nbYPJNTNgvvjjuPa+qsQL666Yq+6VvQVTxSrs 0nWBibcmiFhsRe0yUijaLMN0deAXFUD6O5BXMtoNXhGZnOlvjo8723BB35jNtXOZ4YsqjXJ+KOGyb apU7h9FneAjHbFm9GUsInM50L4kliyzLBy81Vd72Xy7L3xSsg6wBfnkeOtnI8g0H0gB061HFxmlV7 erm6bU6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uUT8l-00000009Kdb-3x5X; Wed, 25 Jun 2025 16:38:27 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uUOq6-00000008ZZt-2rc1 for linux-arm-kernel@lists.infradead.org; Wed, 25 Jun 2025 12:02:54 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 2160F611BD; Wed, 25 Jun 2025 12:02:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A936C4CEEA; Wed, 25 Jun 2025 12:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750852973; bh=mlZPeHhKRfK4QPugHv3jcEFJFQvdWnNs9NsJQp8STP8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ej94voEoj0IPEuwI8HfFWhG6IxvQc28nyxODnTWBqR5Piq4D+Cpi15LUKzLWStBO8 zjV4FMbheJC5F198UnVnPP98CyeSWC3MId1nxkjZ7PcssbcLhEicNqlBSXShcGUG5x CQAAU1Uc0QFaWNsMXvikE4gs4WydmFTQOpOXlJyRqiS/3C75FnEBn/uzXCIl/hvJDT pyNhvIFdWCS23sXWOFQqnEudEsFlDiNcwrvsg3FQvP5/G0kak91NUFq3hmHxIP8btu R6UMG6d+Xplq3rfzWYPMEL+uZpLl2TtSrC1lHWXB1WQDKxbZIlriv5gp/S2ad2dZ83 qtvlOcnajiMYQ== Date: Wed, 25 Jun 2025 15:02:49 +0300 From: Jarkko Sakkinen To: Stefano Garzarella Cc: linux-kernel@vger.kernel.org, Nicolas Ferre , Naveen N Rao , Sumit Garg , linux-integrity@vger.kernel.org, Peter Huewe , Jens Wiklander , James Bottomley , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Nicholas Piggin , Jason Gunthorpe , Michael Ellerman , Alexandre Belloni , Claudiu Beznea , Madhavan Srinivasan Subject: Re: [PATCH v6 4/4] tpm/tpm_svsm: support TPM_CHIP_FLAG_SYNC Message-ID: References: <20250620130810.99069-1-sgarzare@redhat.com> <20250620130810.99069-5-sgarzare@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250620130810.99069-5-sgarzare@redhat.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jun 20, 2025 at 03:08:10PM +0200, Stefano Garzarella wrote: > From: Stefano Garzarella > > 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 > --- > 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 BR, Jarkko