public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Qunqin Zhao <zhaoqunqin@loongson.cn>
Cc: Stefano Garzarella <sgarzare@redhat.com>,
	lee@kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net,
	peterhuewe@gmx.de, linux-kernel@vger.kernel.org,
	loongarch@lists.linux.dev, linux-crypto@vger.kernel.org,
	jgg@ziepe.ca, linux-integrity@vger.kernel.org,
	pmenzel@molgen.mpg.de, Yinggang Gu <guyinggang@loongson.cn>,
	Huacai Chen <chenhuacai@loongson.cn>
Subject: Re: [PATCH v9 4/5] tpm: Add a driver for Loongson TPM device
Date: Thu, 8 May 2025 22:57:58 +0300	[thread overview]
Message-ID: <aB0MxkdKVLso4jZD@kernel.org> (raw)
In-Reply-To: <0b148f09-d20d-b6be-d31b-6c8a553658c9@loongson.cn>

On Wed, May 07, 2025 at 09:33:32AM +0800, Qunqin Zhao wrote:
> 
> 在 2025/5/6 下午10:13, Stefano Garzarella 写道:
> > On Tue, May 06, 2025 at 11:19:46AM +0800, Qunqin Zhao wrote:
> > > Loongson Security Engine supports random number generation, hash,
> > > symmetric encryption and asymmetric encryption. Based on these
> > > encryption functions, TPM2 have been implemented in the Loongson
> > > Security Engine firmware. This driver is responsible for copying data
> > > into the memory visible to the firmware and receiving data from the
> > > firmware.
> > > 
> > > Co-developed-by: Yinggang Gu <guyinggang@loongson.cn>
> > > Signed-off-by: Yinggang Gu <guyinggang@loongson.cn>
> > > Signed-off-by: Qunqin Zhao <zhaoqunqin@loongson.cn>
> > > Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> > > Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
> > > ---
> > > v9: "tpm_loongson_driver" --> "tpm_loongson"
> > >    "depends on CRYPTO_DEV_LOONGSON_SE" --> "depends on MFD_LOONGSON_SE"
> > > 
> ...
> > > +static int tpm_loongson_recv(struct tpm_chip *chip, u8 *buf, size_t
> > > count)
> > > +{
> > > +    struct loongson_se_engine *tpm_engine =
> > > dev_get_drvdata(&chip->dev);
> > > +    struct tpm_loongson_cmd *cmd_ret = tpm_engine->command_ret;
> > > +
> > > +    memcpy(buf, tpm_engine->data_buffer, cmd_ret->data_len);
> > 
> > Should we limit the memcpy to `count`?
> > 
> > I mean, can happen that `count` is less than `cmd_ret->data_len`?
> 
> Hi, Stefan, thanks for your comment.
> 
> Firmware ensures "cmd_ret->data_len" will be less than TPM_BUFSIZE,  so this
> would never happen.

It still must have check-and-fail, as we don't live in a belief system
:-) It helps to mitigate collateral damage of possible firmware bugs
(and thus -EIO is the appropriate error code).

> 
> BR, Qunqin.
> 
> > 
> > Thanks,
> > Stefano
> 

BR, Jarkko

  parent reply	other threads:[~2025-05-08 19:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06  3:19 [PATCH v9 0/5] Add Loongson Security Engine chip driver Qunqin Zhao
2025-05-06  3:19 ` [PATCH v9 1/5] mfd: Add support for Loongson Security Engine chip controller Qunqin Zhao
2025-05-22 13:46   ` Lee Jones
2025-05-26  2:26     ` Qunqin Zhao
2025-05-06  3:19 ` [PATCH v9 2/5] crypto: loongson - add Loongson RNG driver support Qunqin Zhao
2025-05-19  5:57   ` Herbert Xu
2025-05-19  8:13     ` Qunqin Zhao
2025-05-19  8:22       ` Herbert Xu
2025-05-19  8:49         ` Qunqin Zhao
2025-05-19  8:52           ` Herbert Xu
2025-05-19 12:54         ` liulongfang
2025-05-06  3:19 ` [PATCH v9 3/5] MAINTAINERS: Add entry for Loongson crypto driver Qunqin Zhao
2025-05-06  3:19 ` [PATCH v9 4/5] tpm: Add a driver for Loongson TPM device Qunqin Zhao
2025-05-06 14:13   ` Stefano Garzarella
2025-05-07  1:33     ` Qunqin Zhao
2025-05-07  9:32       ` Stefano Garzarella
2025-05-08 19:57       ` Jarkko Sakkinen [this message]
2025-05-08 19:56     ` Jarkko Sakkinen
2025-05-13  7:20   ` Qunqin Zhao
2025-05-11  9:34 ` [PATCH v9 0/5] Add Loongson Security Engine chip driver Huacai Chen
2025-05-13  7:12   ` Qunqin Zhao

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=aB0MxkdKVLso4jZD@kernel.org \
    --to=jarkko@kernel.org \
    --cc=chenhuacai@loongson.cn \
    --cc=davem@davemloft.net \
    --cc=guyinggang@loongson.cn \
    --cc=herbert@gondor.apana.org.au \
    --cc=jgg@ziepe.ca \
    --cc=lee@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=peterhuewe@gmx.de \
    --cc=pmenzel@molgen.mpg.de \
    --cc=sgarzare@redhat.com \
    --cc=zhaoqunqin@loongson.cn \
    /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