| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "shared-forward.h" |
| 5 |
#include "tpm2-util.h" /* IWYU pragma: keep */ |
| 6 |
|
| 7 |
/* Definitions as per "TCG PC Client Specific Platform Firmware Profile Specification" |
| 8 |
* (https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firmware-profile-specification/), |
| 9 |
* section 10.4.1 "Event Types" (at least in version 1.05 Revision 23 of the spec) */ |
| 10 |
#ifndef EV_PREBOOT_CERT |
| 11 |
#define EV_PREBOOT_CERT UINT32_C(0x00000000) |
| 12 |
#define EV_POST_CODE UINT32_C(0x00000001) |
| 13 |
#define EV_NO_ACTION UINT32_C(0x00000003) |
| 14 |
#define EV_SEPARATOR UINT32_C(0x00000004) |
| 15 |
#define EV_ACTION UINT32_C(0x00000005) |
| 16 |
#define EV_EVENT_TAG UINT32_C(0x00000006) |
| 17 |
#define EV_S_CRTM_CONTENTS UINT32_C(0x00000007) |
| 18 |
#define EV_S_CRTM_VERSION UINT32_C(0x00000008) |
| 19 |
#define EV_CPU_MICROCODE UINT32_C(0x00000009) |
| 20 |
#define EV_PLATFORM_CONFIG_FLAGS UINT32_C(0x0000000a) |
| 21 |
#define EV_TABLE_OF_DEVICES UINT32_C(0x0000000b) |
| 22 |
#define EV_COMPACT_HASH UINT32_C(0x0000000c) |
| 23 |
#define EV_IPL UINT32_C(0x0000000d) |
| 24 |
#define EV_IPL_PARTITION_DATA UINT32_C(0x0000000e) |
| 25 |
#define EV_NONHOST_CODE UINT32_C(0x0000000f) |
| 26 |
#define EV_NONHOST_CONFIG UINT32_C(0x00000010) |
| 27 |
#define EV_NONHOST_INFO UINT32_C(0x00000011) |
| 28 |
#define EV_OMIT_BOOT_DEVICE_EVENTS UINT32_C(0x00000012) |
| 29 |
#define EV_EFI_EVENT_BASE UINT32_C(0x80000000) |
| 30 |
#define EV_EFI_VARIABLE_DRIVER_CONFIG UINT32_C(0x80000001) |
| 31 |
#define EV_EFI_VARIABLE_BOOT UINT32_C(0x80000002) |
| 32 |
#define EV_EFI_BOOT_SERVICES_APPLICATION UINT32_C(0x80000003) |
| 33 |
#define EV_EFI_BOOT_SERVICES_DRIVER UINT32_C(0x80000004) |
| 34 |
#define EV_EFI_RUNTIME_SERVICES_DRIVER UINT32_C(0x80000005) |
| 35 |
#define EV_EFI_GPT_EVENT UINT32_C(0x80000006) |
| 36 |
#define EV_EFI_ACTION UINT32_C(0x80000007) |
| 37 |
#define EV_EFI_PLATFORM_FIRMWARE_BLOB UINT32_C(0x80000008) |
| 38 |
#define EV_EFI_HANDOFF_TABLES UINT32_C(0x80000009) |
| 39 |
#define EV_EFI_PLATFORM_FIRMWARE_BLOB2 UINT32_C(0x8000000A) |
| 40 |
#define EV_EFI_HANDOFF_TABLES2 UINT32_C(0x8000000B) |
| 41 |
#define EV_EFI_VARIABLE_BOOT2 UINT32_C(0x8000000C) |
| 42 |
#define EV_EFI_HCRTM_EVENT UINT32_C(0x80000010) |
| 43 |
#define EV_EFI_VARIABLE_AUTHORITY UINT32_C(0x800000E0) |
| 44 |
#define EV_EFI_SPDM_FIRMWARE_BLOB UINT32_C(0x800000E1) |
| 45 |
#define EV_EFI_SPDM_FIRMWARE_CONFIG UINT32_C(0x800000E2) |
| 46 |
#endif |
| 47 |
|
| 48 |
/* Defined in drivers/firmware/efi/libstub/efistub.h in the Linux kernel sources */ |
| 49 |
#ifndef INITRD_EVENT_TAG_ID |
| 50 |
#define INITRD_EVENT_TAG_ID UINT32_C(0x8F3B22EC) |
| 51 |
#endif |
| 52 |
|
| 53 |
#ifndef LOAD_OPTIONS_EVENT_TAG_ID |
| 54 |
#define LOAD_OPTIONS_EVENT_TAG_ID UINT32_C(0x8F3B22ED) |
| 55 |
#endif |
| 56 |
|
| 57 |
DECLARE_STRING_TABLE_LOOKUP_TO_STRING(tpm2_log_event_type, uint32_t); |
| 58 |
|
| 59 |
#if HAVE_TPM2 |
| 60 |
|
| 61 |
/* UEFI event log data structures */ |
| 62 |
typedef struct _packed_ TCG_PCClientPCREvent { |
| 63 |
uint32_t pcrIndex; |
| 64 |
uint32_t eventType; |
| 65 |
uint8_t digest[20]; |
| 66 |
uint32_t eventDataSize; |
| 67 |
uint32_t event[]; |
| 68 |
} TCG_PCClientPCREvent; |
| 69 |
|
| 70 |
typedef struct _packed_ packed_TPMT_HA { |
| 71 |
uint16_t hashAlg; |
| 72 |
TPMU_HA digest; |
| 73 |
} packed_TPMT_HA; |
| 74 |
|
| 75 |
typedef struct _packed_ packed_TPML_DIGEST_VALUES { |
| 76 |
uint32_t count; |
| 77 |
packed_TPMT_HA digests[]; |
| 78 |
} packed_TPML_DIGEST_VALUES; |
| 79 |
|
| 80 |
typedef struct _packed_ TCG_PCR_EVENT2 { |
| 81 |
uint32_t pcrIndex; |
| 82 |
uint32_t eventType; |
| 83 |
packed_TPML_DIGEST_VALUES digests; |
| 84 |
/* … */ |
| 85 |
} TCG_PCR_EVENT2; |
| 86 |
|
| 87 |
typedef struct _packed_ TCG_EfiSpecIdEventAlgorithmSize { |
| 88 |
uint16_t algorithmId; |
| 89 |
uint16_t digestSize; |
| 90 |
} TCG_EfiSpecIdEventAlgorithmSize; |
| 91 |
|
| 92 |
typedef struct _packed_ tdTCG_EfiSpecIdEvent { |
| 93 |
uint8_t signature[16]; |
| 94 |
uint32_t platformClass; |
| 95 |
uint8_t specVersionMinor; |
| 96 |
uint8_t specVersionMajor; |
| 97 |
uint8_t specErrata; |
| 98 |
uint8_t uintnSize; |
| 99 |
uint32_t numberOfAlgorithms; |
| 100 |
TCG_EfiSpecIdEventAlgorithmSize digestSizes[]; |
| 101 |
/* … */ |
| 102 |
} TCG_EfiSpecIDEvent; |
| 103 |
|
| 104 |
typedef struct _packed_ UEFI_VARIABLE_DATA { |
| 105 |
uint8_t variableName[16]; |
| 106 |
uint64_t unicodeNameLength; |
| 107 |
uint64_t variableDataLength; |
| 108 |
char16_t unicodeName[]; |
| 109 |
/* … */ |
| 110 |
} UEFI_VARIABLE_DATA; |
| 111 |
|
| 112 |
typedef struct _packed_ TCG_PCClientTaggedEvent{ |
| 113 |
uint32_t taggedEventID; |
| 114 |
uint32_t taggedEventDataSize; |
| 115 |
uint8_t taggedEventData[]; |
| 116 |
} TCG_PCClientTaggedEvent; |
| 117 |
|
| 118 |
typedef struct _packed_ packed_EFI_DEVICE_PATH { |
| 119 |
uint8_t type; |
| 120 |
uint8_t subType; |
| 121 |
uint16_t length; |
| 122 |
uint8_t path[]; |
| 123 |
} packed_EFI_DEVICE_PATH; |
| 124 |
|
| 125 |
typedef struct _packed_ UEFI_IMAGE_LOAD_EVENT { |
| 126 |
uint64_t imageLocationInMemory; |
| 127 |
uint64_t imageLengthInMemory; |
| 128 |
uint64_t imageLinkTimeAddress; |
| 129 |
uint64_t lengthOfDevicePath; |
| 130 |
packed_EFI_DEVICE_PATH devicePath[]; |
| 131 |
} UEFI_IMAGE_LOAD_EVENT; |
| 132 |
|
| 133 |
typedef struct _packed_ UEFI_PLATFORM_FIRMWARE_BLOB { |
| 134 |
uint64_t blobBase; |
| 135 |
uint64_t blobLength; |
| 136 |
} UEFI_PLATFORM_FIRMWARE_BLOB; |
| 137 |
|
| 138 |
#endif |