]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - drivers/char/tpm/tpm_eventlog.h
Merge tag 'media/v4.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[mirror_ubuntu-focal-kernel.git] / drivers / char / tpm / tpm_eventlog.h
1
2 #ifndef __TPM_EVENTLOG_H__
3 #define __TPM_EVENTLOG_H__
4
5 #include <crypto/hash_info.h>
6
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' */
10 #define TPM2_ACTIVE_PCR_BANKS 3
11
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
18 enum bios_platform_class {
19 BIOS_CLIENT = 0x00,
20 BIOS_SERVER = 0x01,
21 };
22
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
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
117 #if defined(CONFIG_ACPI)
118 int tpm_read_log_acpi(struct tpm_chip *chip);
119 #else
120 static inline int tpm_read_log_acpi(struct tpm_chip *chip)
121 {
122 return -ENODEV;
123 }
124 #endif
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);
136
137 #endif