Hi Ilias,
On 2026-06-29T08:00:59, Ludwig Nussel <[email protected]> wrote:
> tpm: unify the tcg2 eventlog structures
>
> We currently have two structures describing the internal TCG EventLog
> buffers we keep in memory.
> The first one is 'struct event_log_buffer' and it carries all the
> necessary members to keep track of the information needed to implement
> the EFI TCG protocol.
>
> The second one is 'struct tcg2_event_log' which was introduced later,
> when some functions from the TCG protocol moved to U-Boots core, and is
> is used to measure binaries when booting with bootm, booti etc.
>
> The split led to some duplication -- e.g tcg2_measure_data() and
> measure_event() functions are very similar with the exception of
> extending the EventLog.
>
> Since the latter is a subset of the former, let's move all the members
> to a single struct and use that instead.
>
> Signed-off-by: Ilias Apalodimas <[email protected]>
> [...]
>
> include/tpm_tcg2.h | 15 ++++++++++++
> lib/efi_loader/efi_tcg2.c | 60
> +++++++++++++++--------------------------------
> 2 files changed, 34 insertions(+), 41 deletions(-)
> diff --git a/include/tpm_tcg2.h b/include/tpm_tcg2.h
> @@ -163,6 +163,15 @@ struct tcg_efi_spec_id_event {
> * @log_size: Log space available
> * @found: Boolean indicating if an existing log was discovered
> * @allocated: Boolean indicating that the log was allocated
> by u-boot
> + * @final_buffer: finalevent config table buffer. Only used for EFI
> + * @final_position: current position of 'final_buffer'. Only used for EFI
> + * @last_event_size: Size of the last event. Only used for EFI
> + * @get_event_called: true if GetEventLog has been invoked at least
> once.
> + * Only used for EFI
> + * @ebs_called: true if ExitBootServices has been invoked.
> + * Only used for EFI
> + * @truncated: true if the 'buffer' is truncated.
> + * Only used for EFI
A few small doc nits:
- finalevent should be final event
- @truncated refers to buffer but the renamed field is log
- @last_event_size: has a stray space before the tab (checkpatch will flag it)
> diff --git a/include/tpm_tcg2.h b/include/tpm_tcg2.h
> @@ -170,6 +179,12 @@ struct tcg_efi_spec_id_event {
> u32 log_size;
> bool found;
> bool allocated;
> + void *final_buffer;
> + u32 final_position;
> + u32 last_event_size;
Just to check: the previous EFI struct used size_t for
pos/final_pos/last_event_size, and these become u32 here. Fine for the
current CONFIG_TPM2_EVENT_LOG_SIZE range, but worth calling out in the
commit message since it is a silent narrowing on 64-bit builds.
Regards,
Simon