Blame SOURCES/0026-Remove-call-to-TPM2-get_event_log.patch

d1e1c8
From cf3f99c3b1e11c8c83938784975331db5efb410f Mon Sep 17 00:00:00 2001
d1e1c8
From: Matthew Garrett <mjg59@google.com>
d1e1c8
Date: Tue, 11 Dec 2018 15:25:44 -0800
d1e1c8
Subject: [PATCH 26/62] Remove call to TPM2 get_event_log()
d1e1c8
d1e1c8
Calling the TPM2 get_event_log causes the firmware to start logging
d1e1c8
events to the final events table, but implementations may also continue
d1e1c8
logging to the boot services event log. Any OS that wishes to
d1e1c8
reconstruct the full PCR state must already look at both the final
d1e1c8
events log and the boot services event log, so if this call is made
d1e1c8
anywhere other than immediately before ExitBootServices() then the OS
d1e1c8
must deduplicate events that occur in both, complicating things
d1e1c8
immensely.
d1e1c8
d1e1c8
Linux already has support for copying up the boot services event log
d1e1c8
across the ExitBootServices() boundary, so there's no reason to make
d1e1c8
this call. Remove it.
d1e1c8
d1e1c8
Signed-off-by: Matthew Garrett <mjg59@google.com>
d1e1c8
Upstream-commit-id: fd7c3bd920b
d1e1c8
---
d1e1c8
 tpm.c | 46 ----------------------------------------------
d1e1c8
 1 file changed, 46 deletions(-)
d1e1c8
d1e1c8
diff --git a/tpm.c b/tpm.c
d1e1c8
index 674e69b715f..f07362c70bb 100644
d1e1c8
--- a/tpm.c
d1e1c8
+++ b/tpm.c
d1e1c8
@@ -70,41 +70,6 @@ static BOOLEAN tpm2_present(EFI_TCG2_BOOT_SERVICE_CAPABILITY *caps,
d1e1c8
 	return FALSE;
d1e1c8
 }
d1e1c8
 
d1e1c8
-static inline EFI_TCG2_EVENT_LOG_BITMAP
d1e1c8
-tpm2_get_supported_logs(efi_tpm2_protocol_t *tpm,
d1e1c8
-			EFI_TCG2_BOOT_SERVICE_CAPABILITY *caps,
d1e1c8
-			BOOLEAN old_caps)
d1e1c8
-{
d1e1c8
-	if (old_caps)
d1e1c8
-		return ((TREE_BOOT_SERVICE_CAPABILITY *)caps)->SupportedEventLogs;
d1e1c8
-
d1e1c8
-	return caps->SupportedEventLogs;
d1e1c8
-}
d1e1c8
-
d1e1c8
-/*
d1e1c8
- * According to TCG EFI Protocol Specification for TPM 2.0 family,
d1e1c8
- * all events generated after the invocation of EFI_TCG2_GET_EVENT_LOG
d1e1c8
- * shall be stored in an instance of an EFI_CONFIGURATION_TABLE aka
d1e1c8
- * EFI TCG 2.0 final events table. Hence, it is necessary to trigger the
d1e1c8
- * internal switch through calling get_event_log() in order to allow
d1e1c8
- * to retrieve the logs from OS runtime.
d1e1c8
- */
d1e1c8
-static EFI_STATUS trigger_tcg2_final_events_table(efi_tpm2_protocol_t *tpm2,
d1e1c8
-						  EFI_TCG2_EVENT_LOG_BITMAP supported_logs)
d1e1c8
-{
d1e1c8
-	EFI_TCG2_EVENT_LOG_FORMAT log_fmt;
d1e1c8
-	EFI_PHYSICAL_ADDRESS start;
d1e1c8
-	EFI_PHYSICAL_ADDRESS end;
d1e1c8
-	BOOLEAN truncated;
d1e1c8
-
d1e1c8
-	if (supported_logs & EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)
d1e1c8
-		log_fmt = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2;
d1e1c8
-	else
d1e1c8
-		log_fmt = EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
d1e1c8
-
d1e1c8
-	return tpm2->get_event_log(tpm2, log_fmt, &start, &end, &truncated);
d1e1c8
-}
d1e1c8
-
d1e1c8
 static EFI_STATUS tpm_locate_protocol(efi_tpm_protocol_t **tpm,
d1e1c8
 				      efi_tpm2_protocol_t **tpm2,
d1e1c8
 				      BOOLEAN *old_caps_p,
d1e1c8
@@ -166,17 +131,6 @@ static EFI_STATUS tpm_log_event_raw(EFI_PHYSICAL_ADDRESS buf, UINTN size,
d1e1c8
 #endif
d1e1c8
 	} else if (tpm2) {
d1e1c8
 		EFI_TCG2_EVENT *event;
d1e1c8
-		EFI_TCG2_EVENT_LOG_BITMAP supported_logs;
d1e1c8
-
d1e1c8
-		supported_logs = tpm2_get_supported_logs(tpm2, &caps, old_caps);
d1e1c8
-
d1e1c8
-		efi_status = trigger_tcg2_final_events_table(tpm2,
d1e1c8
-							     supported_logs);
d1e1c8
-		if (EFI_ERROR(efi_status)) {
d1e1c8
-			perror(L"Unable to trigger tcg2 final events table: %r\n",
d1e1c8
-			       efi_status);
d1e1c8
-			return efi_status;
d1e1c8
-		}
d1e1c8
 
d1e1c8
 		event = AllocatePool(sizeof(*event) + logsize);
d1e1c8
 		if (!event) {
d1e1c8
-- 
d1e1c8
2.26.2
d1e1c8