@@ -47,39 +47,18 @@ void efi_enable_reset_attack_mitigation(void)
47
47
48
48
#endif
49
49
50
- void efi_retrieve_tpm2_eventlog (void )
50
+ static void efi_retrieve_tcg2_eventlog (int version , efi_physical_addr_t log_location ,
51
+ efi_physical_addr_t log_last_entry ,
52
+ efi_bool_t truncated ,
53
+ struct efi_tcg2_final_events_table * final_events_table )
51
54
{
52
- efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID ;
53
55
efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID ;
54
56
efi_status_t status ;
55
- efi_physical_addr_t log_location = 0 , log_last_entry = 0 ;
56
57
struct linux_efi_tpm_eventlog * log_tbl = NULL ;
57
- struct efi_tcg2_final_events_table * final_events_table = NULL ;
58
58
unsigned long first_entry_addr , last_entry_addr ;
59
59
size_t log_size , last_entry_size ;
60
- efi_bool_t truncated ;
61
- int version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 ;
62
- efi_tcg2_protocol_t * tcg2_protocol = NULL ;
63
60
int final_events_size = 0 ;
64
61
65
- status = efi_bs_call (locate_protocol , & tcg2_guid , NULL ,
66
- (void * * )& tcg2_protocol );
67
- if (status != EFI_SUCCESS )
68
- return ;
69
-
70
- status = efi_call_proto (tcg2_protocol , get_event_log , version ,
71
- & log_location , & log_last_entry , & truncated );
72
-
73
- if (status != EFI_SUCCESS || !log_location ) {
74
- version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 ;
75
- status = efi_call_proto (tcg2_protocol , get_event_log , version ,
76
- & log_location , & log_last_entry ,
77
- & truncated );
78
- if (status != EFI_SUCCESS || !log_location )
79
- return ;
80
-
81
- }
82
-
83
62
first_entry_addr = (unsigned long ) log_location ;
84
63
85
64
/*
@@ -93,8 +72,10 @@ void efi_retrieve_tpm2_eventlog(void)
93
72
* get_event_log only returns the address of the last entry.
94
73
* We need to calculate its size to deduce the full size of
95
74
* the logs.
75
+ *
76
+ * CC Event log also uses TCG2 format, handle it same as TPM2.
96
77
*/
97
- if (version == EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 ) {
78
+ if (version > EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 ) {
98
79
/*
99
80
* The TCG2 log format has variable length entries,
100
81
* and the information to decode the hash algorithms
@@ -127,8 +108,6 @@ void efi_retrieve_tpm2_eventlog(void)
127
108
* Figure out whether any events have already been logged to the
128
109
* final events structure, and if so how much space they take up
129
110
*/
130
- if (version == EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 )
131
- final_events_table = get_efi_config_table (EFI_TCG2_FINAL_EVENTS_TABLE_GUID );
132
111
if (final_events_table && final_events_table -> nr_events ) {
133
112
struct tcg_pcr_event2_head * header ;
134
113
int offset ;
@@ -165,3 +144,50 @@ void efi_retrieve_tpm2_eventlog(void)
165
144
err_free :
166
145
efi_bs_call (free_pool , log_tbl );
167
146
}
147
+
148
+ void efi_retrieve_eventlog (void )
149
+ {
150
+ struct efi_tcg2_final_events_table * final_events_table = NULL ;
151
+ efi_physical_addr_t log_location = 0 , log_last_entry = 0 ;
152
+ efi_guid_t tpm2_guid = EFI_TCG2_PROTOCOL_GUID ;
153
+ int version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 ;
154
+ efi_tcg2_protocol_t * tpm2 = NULL ;
155
+ efi_bool_t truncated ;
156
+ efi_status_t status ;
157
+
158
+ status = efi_bs_call (locate_protocol , & tpm2_guid , NULL , (void * * )& tpm2 );
159
+ if (status == EFI_SUCCESS ) {
160
+ status = efi_call_proto (tpm2 , get_event_log , version , & log_location ,
161
+ & log_last_entry , & truncated );
162
+
163
+ if (status != EFI_SUCCESS || !log_location ) {
164
+ version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 ;
165
+ status = efi_call_proto (tpm2 , get_event_log , version ,
166
+ & log_location , & log_last_entry ,
167
+ & truncated );
168
+ } else {
169
+ final_events_table =
170
+ get_efi_config_table (EFI_TCG2_FINAL_EVENTS_TABLE_GUID );
171
+ }
172
+ } else {
173
+ efi_guid_t cc_guid = EFI_CC_MEASUREMENT_PROTOCOL_GUID ;
174
+ efi_cc_protocol_t * cc = NULL ;
175
+
176
+ status = efi_bs_call (locate_protocol , & cc_guid , NULL , (void * * )& cc );
177
+ if (status != EFI_SUCCESS )
178
+ return ;
179
+
180
+ version = EFI_CC_EVENT_LOG_FORMAT_TCG_2 ;
181
+ status = efi_call_proto (cc , get_event_log , version , & log_location ,
182
+ & log_last_entry , & truncated );
183
+
184
+ final_events_table =
185
+ get_efi_config_table (EFI_CC_FINAL_EVENTS_TABLE_GUID );
186
+ }
187
+
188
+ if (status != EFI_SUCCESS || !log_location )
189
+ return ;
190
+
191
+ efi_retrieve_tcg2_eventlog (version , log_location , log_last_entry ,
192
+ truncated , final_events_table );
193
+ }
0 commit comments