Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 1 | |
| 2 | #ifndef __TPM_EVENTLOG_H__ |
| 3 | #define __TPM_EVENTLOG_H__ |
| 4 | |
Nayna Jain | 4d23cc3 | 2017-01-23 02:26:27 -0500 | [diff] [blame^] | 5 | #include <crypto/hash_info.h> |
| 6 | |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 7 | #define TCG_EVENT_NAME_LEN_MAX 255 |
| 8 | #define MAX_TEXT_EVENT 1000 /* Max event string length */ |
| 9 | #define ACPI_TCPA_SIG "TCPA" /* 0x41504354 /'TCPA' */ |
Nayna Jain | 4d23cc3 | 2017-01-23 02:26:27 -0500 | [diff] [blame^] | 10 | #define TPM2_ACTIVE_PCR_BANKS 3 |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 11 | |
Hon Ching \(Vicky\) Lo | 0cc698a | 2015-06-17 18:17:08 -0400 | [diff] [blame] | 12 | #ifdef CONFIG_PPC64 |
| 13 | #define do_endian_conversion(x) be32_to_cpu(x) |
| 14 | #else |
| 15 | #define do_endian_conversion(x) x |
| 16 | #endif |
| 17 | |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 18 | enum bios_platform_class { |
| 19 | BIOS_CLIENT = 0x00, |
| 20 | BIOS_SERVER = 0x01, |
| 21 | }; |
| 22 | |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 23 | struct tcpa_event { |
| 24 | u32 pcr_index; |
| 25 | u32 event_type; |
| 26 | u8 pcr_value[20]; /* SHA1 */ |
| 27 | u32 event_size; |
| 28 | u8 event_data[0]; |
| 29 | }; |
| 30 | |
| 31 | enum tcpa_event_types { |
| 32 | PREBOOT = 0, |
| 33 | POST_CODE, |
| 34 | UNUSED, |
| 35 | NO_ACTION, |
| 36 | SEPARATOR, |
| 37 | ACTION, |
| 38 | EVENT_TAG, |
| 39 | SCRTM_CONTENTS, |
| 40 | SCRTM_VERSION, |
| 41 | CPU_MICROCODE, |
| 42 | PLATFORM_CONFIG_FLAGS, |
| 43 | TABLE_OF_DEVICES, |
| 44 | COMPACT_HASH, |
| 45 | IPL, |
| 46 | IPL_PARTITION_DATA, |
| 47 | NONHOST_CODE, |
| 48 | NONHOST_CONFIG, |
| 49 | NONHOST_INFO, |
| 50 | }; |
| 51 | |
| 52 | struct tcpa_pc_event { |
| 53 | u32 event_id; |
| 54 | u32 event_size; |
| 55 | u8 event_data[0]; |
| 56 | }; |
| 57 | |
| 58 | enum tcpa_pc_event_ids { |
| 59 | SMBIOS = 1, |
| 60 | BIS_CERT, |
| 61 | POST_BIOS_ROM, |
| 62 | ESCD, |
| 63 | CMOS, |
| 64 | NVRAM, |
| 65 | OPTION_ROM_EXEC, |
| 66 | OPTION_ROM_CONFIG, |
| 67 | OPTION_ROM_MICROCODE = 10, |
| 68 | S_CRTM_VERSION, |
| 69 | S_CRTM_CONTENTS, |
| 70 | POST_CONTENTS, |
| 71 | HOST_TABLE_OF_DEVICES, |
| 72 | }; |
| 73 | |
Nayna Jain | 4d23cc3 | 2017-01-23 02:26:27 -0500 | [diff] [blame^] | 74 | /* http://www.trustedcomputinggroup.org/tcg-efi-protocol-specification/ */ |
| 75 | |
| 76 | struct tcg_efi_specid_event_algs { |
| 77 | u16 alg_id; |
| 78 | u16 digest_size; |
| 79 | } __packed; |
| 80 | |
| 81 | struct tcg_efi_specid_event { |
| 82 | u8 signature[16]; |
| 83 | u32 platform_class; |
| 84 | u8 spec_version_minor; |
| 85 | u8 spec_version_major; |
| 86 | u8 spec_errata; |
| 87 | u8 uintnsize; |
| 88 | u32 num_algs; |
| 89 | struct tcg_efi_specid_event_algs digest_sizes[TPM2_ACTIVE_PCR_BANKS]; |
| 90 | u8 vendor_info_size; |
| 91 | u8 vendor_info[0]; |
| 92 | } __packed; |
| 93 | |
| 94 | struct tcg_pcr_event { |
| 95 | u32 pcr_idx; |
| 96 | u32 event_type; |
| 97 | u8 digest[20]; |
| 98 | u32 event_size; |
| 99 | u8 event[0]; |
| 100 | } __packed; |
| 101 | |
| 102 | struct tcg_event_field { |
| 103 | u32 event_size; |
| 104 | u8 event[0]; |
| 105 | } __packed; |
| 106 | |
| 107 | struct tcg_pcr_event2 { |
| 108 | u32 pcr_idx; |
| 109 | u32 event_type; |
| 110 | u32 count; |
| 111 | struct tpm2_digest digests[TPM2_ACTIVE_PCR_BANKS]; |
| 112 | struct tcg_event_field event; |
| 113 | } __packed; |
| 114 | |
| 115 | extern const struct seq_operations tpm2_binary_b_measurements_seqops; |
| 116 | |
Nayna Jain | 02ae1382 | 2016-11-14 05:00:54 -0500 | [diff] [blame] | 117 | #if defined(CONFIG_ACPI) |
| 118 | int tpm_read_log_acpi(struct tpm_chip *chip); |
Ashley Lai | c5df392 | 2012-08-14 18:35:32 -0500 | [diff] [blame] | 119 | #else |
Nayna Jain | 02ae1382 | 2016-11-14 05:00:54 -0500 | [diff] [blame] | 120 | static inline int tpm_read_log_acpi(struct tpm_chip *chip) |
Ashley Lai | c5df392 | 2012-08-14 18:35:32 -0500 | [diff] [blame] | 121 | { |
Nayna Jain | 02ae1382 | 2016-11-14 05:00:54 -0500 | [diff] [blame] | 122 | return -ENODEV; |
Ashley Lai | c5df392 | 2012-08-14 18:35:32 -0500 | [diff] [blame] | 123 | } |
| 124 | #endif |
Nayna Jain | 02ae1382 | 2016-11-14 05:00:54 -0500 | [diff] [blame] | 125 | #if defined(CONFIG_OF) |
| 126 | int tpm_read_log_of(struct tpm_chip *chip); |
| 127 | #else |
| 128 | static inline int tpm_read_log_of(struct tpm_chip *chip) |
| 129 | { |
| 130 | return -ENODEV; |
| 131 | } |
| 132 | #endif |
| 133 | |
| 134 | int tpm_bios_log_setup(struct tpm_chip *chip); |
| 135 | void tpm_bios_log_teardown(struct tpm_chip *chip); |
Ashley Lai | c5df392 | 2012-08-14 18:35:32 -0500 | [diff] [blame] | 136 | |
Kent Yoder | e5dcd87 | 2012-07-11 10:08:12 -0500 | [diff] [blame] | 137 | #endif |