Skip to contentSkip to conversation

efi/tpm: Fix the issue where the CC platforms event log header can't be correctly identified

PATCH Superseded [email protected] 2 participants 3 messages Jul 12, 2025

Subsystems (3)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 efi/tpm: Fix the issue where the CC platforms event log header can't be correctly identified

From: Ge Yang <[email protected]>

Since commit d228814b1913 ("efi/libstub: Add get_event_log() support for CC platforms") reuses TPM2 support code for the CC platforms, when launching a TDX virtual machine with coco measurement enabled, the following error log is generated:

[Firmware Bug]: Failed to parse event in TPM Final Events Log

Call Trace:
efi_config_parse_tables()
  efi_tpm_eventlog_init()
    tpm2_calc_event_log_size()
      __calc_tpm2_event_size()

The pcr_idx value in the Intel TDX log header is 1, causing the function __calc_tpm2_event_size() to fail to recognize the log header, ultimately leading to the "Failed to parse event in TPM Final Events Log" error.

According to UEFI Specification 2.10, Section 38.4.1: For TDX, TPM PCR 0 maps to MRTD, so the log header uses TPM PCR 1 instead. To successfully parse the TDX event log header, the check for a pcr_idx value of 0 must be skipped. There's no danger of this causing problems because we check for the TCG_SPECID_SIG signature as the next thing.

Fixes d228814b1913 ("efi/libstub: Add get_event_log() support for CC platforms")

---
V5:
- remove the pcr_index check without adding any replacement checks suggested by James and Sathyanarayanan

V4:
- remove cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT) suggested by Ard

V3:
- fix build error

V2:
- limit the fix for CC only suggested by Jarkko and Sathyanarayanan

 include/linux/tpm_eventlog.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/tpm_eventlog.h +1 -2
index 891368e..05c0ae5 100644
@@ -202,8 +202,7 @@ static __always_inline u32 __calc_tpm2_event_size(struct tcg_pcr_event2_head *ev
 	event_type = event->event_type;
 
 	/* Verify that it's the log header */
-	if (event_header->pcr_idx != 0 ||
-	    event_header->event_type != NO_ACTION ||
+	if (event_header->event_type != NO_ACTION ||
 	    memcmp(event_header->digest, zero_digest, sizeof(zero_digest))) {
 		size = 0;
 		goto out;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 15 lines · On Sat, 2025-07-12 at 10:55 +0800, [email protected] wrote:

From: Ge Yang <[email protected]>

Since commit d228814b1913 ("efi/libstub: Add get_event_log() support for CC platforms") reuses TPM2 support code for the CC platforms, when launching a TDX virtual machine with coco measurement enabled, the following error log is generated:

[Firmware Bug]: Failed to parse event in TPM Final Events Log

Call Trace:

efi_config_parse_tables()
  efi_tpm_eventlog_init()
    tpm2_calc_event_log_size()
      __calc_tpm2_event_size()

Quoted 7 lines

The pcr_idx value in the Intel TDX log header is 1, causing the function __calc_tpm2_event_size() to fail to recognize the log header, ultimately leading to the "Failed to parse event in TPM Final Events Log" error.

According to UEFI Specification 2.10, Section 38.4.1: For TDX, TPM PCR 0 maps to MRTD, so the log header uses TPM PCR 1 instead.

This isn't a justification ... Intel just screwed up. Whatever the UEFI spec says about PCR mapping, the log spec the TCG produces requires the header event to have a pcrIndex of 0 and, since it isn't recorded in a PCR, it doesn't matter what the mapping is.

Just say Intel misread the spec and wrongly sets pcrIndex to 1 in the header and since they did this, we fear others might, so we're relaxing the header check.

Regards,

James

author
#2 lore raw
Quoted 24 lines · James Bottomley
Quoted 15 lines · On Sat, 2025-07-12 at 10:55 +0800, [email protected] wrote:

From: Ge Yang <[email protected]>

Since commit d228814b1913 ("efi/libstub: Add get_event_log() support for CC platforms") reuses TPM2 support code for the CC platforms, when launching a TDX virtual machine with coco measurement enabled, the following error log is generated:

[Firmware Bug]: Failed to parse event in TPM Final Events Log

Call Trace:

efi_config_parse_tables()
  efi_tpm_eventlog_init()
    tpm2_calc_event_log_size()
      __calc_tpm2_event_size()

Quoted 7 lines

The pcr_idx value in the Intel TDX log header is 1, causing the function __calc_tpm2_event_size() to fail to recognize the log header, ultimately leading to the "Failed to parse event in TPM Final Events Log" error.

According to UEFI Specification 2.10, Section 38.4.1: For TDX, TPM PCR 0 maps to MRTD, so the log header uses TPM PCR 1 instead.

Quoted 9 lines

This isn't a justification ... Intel just screwed up. Whatever the UEFI spec says about PCR mapping, the log spec the TCG produces requires the header event to have a pcrIndex of 0 and, since it isn't recorded in a PCR, it doesn't matter what the mapping is.

Just say Intel misread the spec and wrongly sets pcrIndex to 1 in the header and since they did this, we fear others might, so we're relaxing the header check.

OK, thanks.

Quoted 3 lines

Regards,

James