mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arun Menon <armenon@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Peter Huewe <peterhuewe@gmx.de>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	linux-integrity@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca>,
	Arun Menon <armenon@redhat.com>
Subject: [PATCH v6 4/7] tpm: tis_i2c: Use local 4KB buffer to limit memory usage
Date: Sat, 31 Oct 2026 01:36:46 +0530	[thread overview]
Message-ID: <20261030200649.357508-5-armenon@redhat.com> (raw)
In-Reply-To: <20261030200649.357508-1-armenon@redhat.com>

From: Arun Menon <armenon@redhat.com>

The global increase of TPM_BUFSIZE to 8KB is necessary to support
Post-Quantum Cryptography (PQC) payloads. However, applying this increase
to the tpm_tis_i2c driver is unnecessary and wasteful due to physical
transport limitations as pointed out in [1]

This commit introduces a local buffer limit that is used in the i2c
driver.

[1] https://sashiko.dev/#/patchset/20260324071803.324774-1-armenon%40redhat.com?patch=8319

Signed-off-by: Arun Menon <armenon@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Link: https://lore.kernel.org/r/20261029181541.99505-5-armenon@redhat.com
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
 drivers/char/tpm/tpm_tis_i2c.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis_i2c.c b/drivers/char/tpm/tpm_tis_i2c.c
index 8bcbc84815fd..36f56ee75cd4 100644
--- a/drivers/char/tpm/tpm_tis_i2c.c
+++ b/drivers/char/tpm/tpm_tis_i2c.c
@@ -61,6 +61,7 @@ struct tpm_tis_i2c_reset_timings {
 	unsigned int assert_us;
 	unsigned int deassert_us;
 };
+#define TPM_I2C_BUFSIZE 4096
 
 struct tpm_tis_i2c_phy {
 	struct tpm_tis_data priv;
@@ -240,7 +241,7 @@ static int tpm_tis_i2c_write_bytes(struct tpm_tis_data *data, u32 addr, u16 len,
 	int ret;
 	u16 wrote = 0;
 
-	if (len > TPM_BUFSIZE - 1)
+	if (len > TPM_I2C_BUFSIZE - 1)
 		return -EIO;
 
 	phy->io_buf[0] = reg;
@@ -349,7 +350,7 @@ static int tpm_tis_i2c_probe(struct i2c_client *dev)
 	if (!phy)
 		return -ENOMEM;
 
-	phy->io_buf = devm_kzalloc(&dev->dev, TPM_BUFSIZE, GFP_KERNEL);
+	phy->io_buf = devm_kzalloc(&dev->dev, TPM_I2C_BUFSIZE, GFP_KERNEL);
 	if (!phy->io_buf)
 		return -ENOMEM;
 
-- 
2.56.0


  parent reply	other threads:[~2026-10-30 20:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 20:06 [PATCH v6 0/7] tpm_crb: Add command and response buffer chunking support Arun Menon
2026-10-30 20:06 ` [PATCH v6 1/7] tpm_crb: Add register definitions of TPM CRB chunking fields Arun Menon
2026-10-30 20:06 ` [PATCH v6 2/7] tpm_crb: Split start method into a separate header Arun Menon
2026-10-30 20:06 ` [PATCH v6 3/7] tpm_crb: Add start_cmd parameter to tpm_crb_start wrapper Arun Menon
2026-10-30 20:06 ` Arun Menon [this message]
2026-10-30 20:06 ` [PATCH v6 5/7] tpm: Increase TPM_BUFSIZE to 8KB for chunking support Arun Menon
2026-10-30 20:06 ` [PATCH v6 6/7] tpm_crb: Factor crb_send()/crb_recv() bodies into helpers Arun Menon
2026-10-30 20:06 ` [PATCH v6 7/7] tpm_crb: Implement command and response chunking logic Arun Menon
2026-10-30 21:24 ` [PATCH v6 0/7] tpm_crb: Add command and response buffer chunking support Jarkko Sakkinen

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=20261030200649.357508-5-armenon@redhat.com \
    --to=armenon@redhat.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

all inboxes | Powered by JetHome®