在 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 <guyingg...@loongson.cn>
Signed-off-by: Yinggang Gu <guyingg...@loongson.cn>
Signed-off-by: Qunqin Zhao <zhaoqun...@loongson.cn>
Reviewed-by: Huacai Chen <chenhua...@loongson.cn>
Reviewed-by: Jarkko Sakkinen <jar...@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.
BR, Qunqin.
Thanks,
Stefano