Skip to content

Conversation

@SergiiDmytruk
Copy link
Member

At the moment this is to use CI for checking that commits don't break anything.

ref: prot-1808

@SergiiDmytruk SergiiDmytruk force-pushed the all-tpm-banks branch 5 times, most recently from ccbfdc8 to 85106d0 Compare December 16, 2025 14:42
@SergiiDmytruk SergiiDmytruk marked this pull request as ready for review December 18, 2025 12:31
@SergiiDmytruk SergiiDmytruk assigned mkopec and filipleple and unassigned mkopec and filipleple Dec 18, 2025

int i, j;
struct tpm_digest digests[ENABLED_TPM_ALGS_NUM + 1];
for (i = 0, j = 0; i < ENABLED_TPM_ALGS_NUM; ++i) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergiiDmytruk is it intended that j is not incremented in this loop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, of course not, thanks for catching this. Turns out CONFIG_VBOOT_NO_TPM is set for some Protectli boards, so vboot doesn't extend any PCRs making this harder to notice in manual tests.

https://github.com/Dasharo/coreboot/compare/5c23cb0c62e5820a865d6f710d9c1515e2edf5a2..69aee15ab38c6f4dec05d62b97e059bd0441cef0#diff-50f6d62bb2106e7c65381f5d4f6fa87699065c636d827c69e0e63739e6eb2b23R66

/* Extending the same data to all banks. It either gets truncated, fits
perfectly or is padded with zeroes. */
digests[j].hash = buffer;
digests[j].hash_type = algo;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do want to use algo, defined before this loop, not alg defined and used inside this loop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return TPM_CB_HASH_ERROR;
}

digests[j].hash = digest;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly, *according to LLM*:

The function computes multiple digests by iterating algorithms, but it finalizes each digest into the same stack buffer uint8_t digest[TPM_PCR_MAX_LEN] and then stores digests[j].hash = digest. All entries end up pointing to the same memory and therefore all banks will extend with the last computed digest, with truncation effects for smaller algorithms. This breaks both PCR values and event log correctness when more than one bank is active.

I'm not sure if this is the case, feel free to disregard

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LLM is actually right in this case. This affects only FMAP measurement, which I did notice (it's the first measurement) but incorrectly attributed this weirdness to vboot extending the same value regardless of the digest type and didn't check the code.

https://github.com/Dasharo/coreboot/compare/5c23cb0c62e5820a865d6f710d9c1515e2edf5a2..69aee15ab38c6f4dec05d62b97e059bd0441cef0#diff-154fbdfb0b02f8a77b8f64a02671aaf370e8b5a17383722e9e852e78ccf3d9bd

Out of vendorcode/eltan/security/mboot/mboot.c to not duplicate the
implementation.

Upstream-Status: Pending
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
No functional changes are intended, merely changing interface and how
places that make use of it.  A few places got extra error checks, but
their conditions shouldn't be satisfied at this point.

Upstream-Status: Pending
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
The marshaling code was already there.  This change only increases
maximum number of hashes and initializes `tpm2_pcr_extend_cmd` with all
digests that were passed in.

Upstream-Status: Pending
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
* Update vendor data to drop entry size and maximum count and add offset
  to the first unused byte and total number of available bytes.  This
  bumps its major version because the update breaks compatibility.
* Represent log table as two structures, tpm_2_log_table and
  tpm_2_log_bottom, separate by a list of digests in the header.
* Remove tpm_2_log_entry.
* Add functions to store and parse log entries and use them instead of
  array operations.
* cbmem tool doesn't need an update because it already parses the log as
  an agile format rather than an array of entries of the same size.

Change-Id: I13cebe2a40c220375cc14124ef9b13ea7ee0207f
Upstream-Status: Pending
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Get rid of the large if-else statement in
intel_cbnt_inject_ibg_measurements() by moving code from branches into
separate functions.

Upstream-Status: Pending
Change-Id: I892c56d37abac1b43c68ac761d428c3560007246
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Updates the code to support hashing for more than one digest algorithm
when that's available, the code should work as before at this point.

Change-Id: I4e0ea97946e6c8cafbc21a6418b8cb5e7d087df0
Upstream-Status: Pending
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Updates the code to support hashing for more than one digest algorithm
when that's available, the code should work as before at this point.

Change-Id: I243531e699d927896278df2822e80c69db2715dd
Upstream-Status: Pending
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Updates the code to support hashing for more than one digest algorithm
when that's available, the code should work as before at this point.

Change-Id: I6a89d8d430986bda7ee77053ca3768a292e1b53b
Upstream-Status: Pending
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
All of the client has already been updated to permit use of multiple
banks, but at most one was ever enabled.  TPM 2 log was also updated to
permit handling of multiple digests, but similarly only one was in use.

From now on, it's possible to configure more than one digest (only SHA1
and SHA256 are selected by default).  This changes previous TSPI API of
`tpm_log_alg()` (single hash) to `tpm_log_alg_active(enum
vb2_hash_algorithm)` coupled with `enabled_tpm_algs` array (multiple
hashes).

The bulk of the code here is for dealing with the set of banks of TPM:
 - querying it from the device to know what digests should be used
 - synchronizing set of digests in the log with the actual set of active
   banks
The latter is needed in case TPM is initialized in ramstage while
measurements are accumulated starting from the bootblock.  An
alternative was to require initializing TPM in the bootblock, but
bootblock may not have enough space for the extra code required for
TPM, hence a different approach was taken: take all supported hashes
before TPM is initialized, trim unnecessary digests after the
initialization.

Change-Id: Ia326b22869c4983fc4e02e150461e7a9ff94dc4e
Upstream-Status: Pending
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
@SergiiDmytruk SergiiDmytruk force-pushed the all-tpm-banks branch 2 times, most recently from 5c23cb0 to 69aee15 Compare December 19, 2025 22:45
Copy link
Member Author

@SergiiDmytruk SergiiDmytruk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code and reran tests on VP4650. Also checked that build with CONFIG_VBOOT_NO_TPM=n produces correct PCR values.


int i, j;
struct tpm_digest digests[ENABLED_TPM_ALGS_NUM + 1];
for (i = 0, j = 0; i < ENABLED_TPM_ALGS_NUM; ++i) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, of course not, thanks for catching this. Turns out CONFIG_VBOOT_NO_TPM is set for some Protectli boards, so vboot doesn't extend any PCRs making this harder to notice in manual tests.

https://github.com/Dasharo/coreboot/compare/5c23cb0c62e5820a865d6f710d9c1515e2edf5a2..69aee15ab38c6f4dec05d62b97e059bd0441cef0#diff-50f6d62bb2106e7c65381f5d4f6fa87699065c636d827c69e0e63739e6eb2b23R66

/* Extending the same data to all banks. It either gets truncated, fits
perfectly or is padded with zeroes. */
digests[j].hash = buffer;
digests[j].hash_type = algo;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return TPM_CB_HASH_ERROR;
}

digests[j].hash = digest;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LLM is actually right in this case. This affects only FMAP measurement, which I did notice (it's the first measurement) but incorrectly attributed this weirdness to vboot extending the same value regardless of the digest type and didn't check the code.

https://github.com/Dasharo/coreboot/compare/5c23cb0c62e5820a865d6f710d9c1515e2edf5a2..69aee15ab38c6f4dec05d62b97e059bd0441cef0#diff-154fbdfb0b02f8a77b8f64a02671aaf370e8b5a17383722e9e852e78ccf3d9bd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants