From: Jarkko Sakkinen <jarkko@kernel.org>
To: Ross Philipson <ross.philipson@gmail.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
linux-integrity@vger.kernel.org, linux-crypto@vger.kernel.org,
linux-efi@vger.kernel.org, dpsmith@apertussolutions.com,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
hpa@zytor.com, dave.hansen@linux.intel.com, ardb@kernel.org,
mjg59@srcf.ucam.org, James.Bottomley@hansenpartnership.com,
peterhuewe@gmx.de, luto@amacapital.net,
herbert@gondor.apana.org.au, davem@davemloft.net, corbet@lwn.net,
kanth.ghatraju@oracle.com, daniel.kiper@oracle.com,
andrew.cooper3@citrix.com, trenchboot-devel@googlegroups.com
Subject: Re: [PATCH v2 10/10] tpm-buf: Add TPM buffer support header for standalone reuse
Date: Sat, 11 Jul 2026 21:18:30 +0300 [thread overview]
Message-ID: <alKI9mUBTOCjPbbG@kernel.org> (raw)
In-Reply-To: <20260711160110.267780-11-ross.philipson@gmail.com>
On Sat, Jul 11, 2026 at 09:01:10AM -0700, Ross Philipson wrote:
> Extract all the functions and definitions for TPM buffer handling
> and separate them into their own header.
>
> Signed-off-by: Ross Philipson <ross.philipson@gmail.com>
> ---
> drivers/char/tpm/tpm-buf.c | 3 +-
> include/linux/tpm.h | 34 +--------------------
> include/linux/tpm_buf.h | 60 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 63 insertions(+), 34 deletions(-)
> create mode 100644 include/linux/tpm_buf.h
>
> diff --git a/drivers/char/tpm/tpm-buf.c b/drivers/char/tpm/tpm-buf.c
> index 1e5c11c312a8..233e81d3f149 100644
> --- a/drivers/char/tpm/tpm-buf.c
> +++ b/drivers/char/tpm/tpm-buf.c
> @@ -4,7 +4,8 @@
> */
>
> #include <linux/module.h>
> -#include <linux/tpm.h>
> +#include <linux/tpm_command.h>
> +#include <linux/tpm_buf.h>
>
> static void __tpm_buf_size_invariant(struct tpm_buf *buf, u16 buf_size)
> {
> diff --git a/include/linux/tpm.h b/include/linux/tpm.h
> index 598dd53a10d8..0db277af45c3 100644
> --- a/include/linux/tpm.h
> +++ b/include/linux/tpm.h
> @@ -26,6 +26,7 @@
> #include <crypto/aes.h>
>
> #include <linux/tpm_command.h>
> +#include <linux/tpm_buf.h>
>
> struct tpm_chip;
> struct trusted_key_payload;
> @@ -200,44 +201,11 @@ enum tpm_chip_flags {
>
> #define to_tpm_chip(d) container_of(d, struct tpm_chip, dev)
>
> -enum tpm_buf_flags {
> - /* TPM2B format: */
> - TPM_BUF_TPM2B = BIT(0),
> - /* The buffer is in invalid and unusable state: */
> - TPM_BUF_INVALID = BIT(1),
> -};
> -
> -/*
> - * A buffer for constructing and parsing TPM commands, responses and sized
> - * (TPM2B) buffers.
> - */
> -struct tpm_buf {
> - u8 flags;
> - u16 length;
> - u16 capacity;
> - u8 handles;
> - u8 data[];
> -};
> -
> struct tpm2_hash {
> unsigned int crypto_id;
> unsigned int tpm_id;
> };
>
> -void tpm_buf_init(struct tpm_buf *buf, u16 buf_size);
> -void tpm_buf_init_sized(struct tpm_buf *buf, u16 buf_size);
> -void tpm_buf_reset(struct tpm_buf *buf, u16 tag, u32 ordinal);
> -void tpm_buf_reset_sized(struct tpm_buf *buf);
> -u16 tpm_buf_length(struct tpm_buf *buf);
> -void tpm_buf_append(struct tpm_buf *buf, const u8 *new_data, u16 new_length);
> -void tpm_buf_append_u8(struct tpm_buf *buf, const u8 value);
> -void tpm_buf_append_u16(struct tpm_buf *buf, const u16 value);
> -void tpm_buf_append_u32(struct tpm_buf *buf, const u32 value);
> -u8 tpm_buf_read_u8(struct tpm_buf *buf, off_t *offset);
> -u16 tpm_buf_read_u16(struct tpm_buf *buf, off_t *offset);
> -u32 tpm_buf_read_u32(struct tpm_buf *buf, off_t *offset);
> -void tpm_buf_append_handle(struct tpm_buf *buf, u32 handle);
> -
> /*
> * Check if TPM device is in the firmware upgrade mode.
> */
> diff --git a/include/linux/tpm_buf.h b/include/linux/tpm_buf.h
> new file mode 100644
> index 000000000000..f8c105d8b8bf
> --- /dev/null
> +++ b/include/linux/tpm_buf.h
> @@ -0,0 +1,60 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Following copyright information was take from the original file
> + * <include/linux/tpm.h> where the definitions were moved from:
> + *
> + * Copyright (C) 2004,2007,2008 IBM Corporation
> + *
> + * Authors:
> + * Leendert van Doorn <leendert@watson.ibm.com>
> + * Dave Safford <safford@watson.ibm.com>
> + * Reiner Sailer <sailer@watson.ibm.com>
> + * Kylene Hall <kjhall@us.ibm.com>
> + * Debora Velarde <dvelarde@us.ibm.com>
> + *
> + * Maintained by: <tpmdd_devel@lists.sourceforge.net>
> + *
> + * Device driver for TCG/TCPA TPM (trusted platform module).
> + * Specifications at www.trustedcomputinggroup.org
> + */
> +
> +#ifndef __LINUX_TPM_BUF_H__
> +#define __LINUX_TPM_BUF_H__
> +
> +#include <linux/types.h>
> +#include <linux/bits.h>
> +
> +enum tpm_buf_flags {
> + /* TPM2B format: */
> + TPM_BUF_TPM2B = BIT(0),
> + /* The buffer is in invalid and unusable state: */
> + TPM_BUF_INVALID = BIT(1),
> +};
> +
> +/*
> + * A buffer for constructing and parsing TPM commands, responses and sized
> + * (TPM2B) buffers.
> + */
> +struct tpm_buf {
> + u8 flags;
> + u8 handles;
> + u16 length;
> + u16 capacity;
> + u8 data[];
> +};
> +
> +void tpm_buf_init(struct tpm_buf *buf, u16 buf_size);
> +void tpm_buf_init_sized(struct tpm_buf *buf, u16 buf_size);
> +void tpm_buf_reset(struct tpm_buf *buf, u16 tag, u32 ordinal);
> +void tpm_buf_reset_sized(struct tpm_buf *buf);
> +u16 tpm_buf_length(struct tpm_buf *buf);
> +void tpm_buf_append(struct tpm_buf *buf, const u8 *new_data, u16 new_length);
> +void tpm_buf_append_u8(struct tpm_buf *buf, const u8 value);
> +void tpm_buf_append_u16(struct tpm_buf *buf, const u16 value);
> +void tpm_buf_append_u32(struct tpm_buf *buf, const u32 value);
> +u8 tpm_buf_read_u8(struct tpm_buf *buf, off_t *offset);
> +u16 tpm_buf_read_u16(struct tpm_buf *buf, off_t *offset);
> +u32 tpm_buf_read_u32(struct tpm_buf *buf, off_t *offset);
> +void tpm_buf_append_handle(struct tpm_buf *buf, u32 handle);
> +
> +#endif
> --
> 2.55.0
>
I would probably ack them all as I've seen these many times and
there's not much anything new. Just waiting for additional
feedback before applying them.
BR, Jarkko
prev parent reply other threads:[~2026-07-11 18:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 16:01 [PATCH v2 00/10] tpm: Reorganize public headers and extract tpm-buf for standalone reuse Ross Philipson
2026-07-11 16:01 ` [PATCH v2 01/10] tpm: Initial step to reorganize TPM public headers Ross Philipson
2026-07-11 16:01 ` [PATCH v2 02/10] tpm: Move TPM1 specific definitions to the command header Ross Philipson
2026-07-11 16:01 ` [PATCH v2 03/10] tpm: Move TPM2 " Ross Philipson
2026-07-11 16:01 ` [PATCH v2 04/10] tpm: Move TPM common base " Ross Philipson
2026-07-11 16:01 ` [PATCH v2 05/10] tpm: Move platform specific definitions to the new PTP header Ross Philipson
2026-07-11 16:01 ` [PATCH v2 06/10] tpm: Remove main TPM header from TPM event log header Ross Philipson
2026-07-11 16:01 ` [PATCH v2 07/10] tpm-buf: Merge TPM_BUF_BOUNDARY_ERROR and TPM_BUF_OVERFLOW Ross Philipson
2026-07-11 16:01 ` [PATCH v2 08/10] tpm-buf: Remove chip parameter from tpm_buf_append_handle() Ross Philipson
2026-07-11 16:01 ` [PATCH v2 09/10] tpm-buf: Memory-safe allocations Ross Philipson
2026-07-11 18:15 ` Jarkko Sakkinen
2026-07-11 16:01 ` [PATCH v2 10/10] tpm-buf: Add TPM buffer support header for standalone reuse Ross Philipson
2026-07-11 18:18 ` Jarkko Sakkinen [this message]
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=alKI9mUBTOCjPbbG@kernel.org \
--to=jarkko@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=andrew.cooper3@citrix.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=daniel.kiper@oracle.com \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=dpsmith@apertussolutions.com \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=kanth.ghatraju@oracle.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=mjg59@srcf.ucam.org \
--cc=peterhuewe@gmx.de \
--cc=ross.philipson@gmail.com \
--cc=tglx@linutronix.de \
--cc=trenchboot-devel@googlegroups.com \
--cc=x86@kernel.org \
/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