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