summaryrefslogtreecommitdiff
path: root/tpm.c
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javierm@redhat.com>2017-06-15 15:16:05 +0200
committerPeter Jones <pjones@redhat.com>2017-06-15 11:30:22 -0400
commit0baa915056b6dc3dbea51c045e1e3ef8a0d86a08 (patch)
treee14ae9fe2b5d482ff48402ea50cae51ab689c308 /tpm.c
parent9c40fb7c0570430e28c8e5bc34223d6e3a59a929 (diff)
downloadefi-boot-shim-0baa915056b6dc3dbea51c045e1e3ef8a0d86a08.tar.gz
efi-boot-shim-0baa915056b6dc3dbea51c045e1e3ef8a0d86a08.zip
shim/tpm: Take out GetCapability() call from tpm2_present() logic
The EFI_TCG2_PROTOCOL.GetCapability() function is used to learn if a TPM2 chip is present. But the protocol capability information is also needed for other reasons, for example to determine what event log formats are supported by the firmware. Take out the GetCapability() call from the tpm2_present() logic and reduce that function to just checking if a TPM2 chip is available or not, so the capabilities can later be used to determine the supported TPM log formats. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Diffstat (limited to 'tpm.c')
-rw-r--r--tpm.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/tpm.c b/tpm.c
index 99486b10..2ca58454 100644
--- a/tpm.c
+++ b/tpm.c
@@ -35,29 +35,41 @@ static BOOLEAN tpm_present(efi_tpm_protocol_t *tpm)
return TRUE;
}
-static BOOLEAN tpm2_present(efi_tpm2_protocol_t *tpm)
+static EFI_STATUS tpm2_get_caps(efi_tpm2_protocol_t *tpm,
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY *caps,
+ BOOLEAN *old_caps)
{
EFI_STATUS status;
- EFI_TCG2_BOOT_SERVICE_CAPABILITY caps;
- TREE_BOOT_SERVICE_CAPABILITY *caps_1_0;
- caps.Size = (UINT8)sizeof(caps);
+ caps->Size = (UINT8)sizeof(*caps);
- status = uefi_call_wrapper(tpm->get_capability, 2, tpm, &caps);
+ status = uefi_call_wrapper(tpm->get_capability, 2, tpm, caps);
if (status != EFI_SUCCESS)
- return FALSE;
+ return status;
+
+ if (caps->StructureVersion.Major == 1 &&
+ caps->StructureVersion.Minor == 0)
+ *old_caps = TRUE;
- if (caps.StructureVersion.Major == 1 &&
- caps.StructureVersion.Minor == 0) {
- caps_1_0 = (TREE_BOOT_SERVICE_CAPABILITY *)&caps;
+ return EFI_SUCCESS;
+}
+
+static BOOLEAN tpm2_present(efi_tpm2_protocol_t *tpm,
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY *caps,
+ BOOLEAN old_caps)
+{
+ TREE_BOOT_SERVICE_CAPABILITY *caps_1_0;
+
+ if (old_caps) {
+ caps_1_0 = (TREE_BOOT_SERVICE_CAPABILITY *)caps;
if (caps_1_0->TrEEPresentFlag)
return TRUE;
- } else {
- if (caps.TPMPresentFlag)
- return TRUE;
}
+ if (caps->TPMPresentFlag)
+ return TRUE;
+
return FALSE;
}
@@ -90,9 +102,15 @@ EFI_STATUS tpm_log_event(EFI_PHYSICAL_ADDRESS buf, UINTN size, UINT8 pcr,
status = LibLocateProtocol(&tpm2_guid, (VOID **)&tpm2);
/* TPM 2.0 */
if (status == EFI_SUCCESS) {
+ BOOLEAN old_caps;
EFI_TCG2_EVENT *event;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY caps;
+
+ status = tpm2_get_caps(tpm2, &caps, &old_caps);
+ if (status != EFI_SUCCESS)
+ return EFI_SUCCESS;
- if (!tpm2_present(tpm2))
+ if (!tpm2_present(tpm2, &caps, old_caps))
return EFI_SUCCESS;
status = trigger_tcg2_final_events_table(tpm2);