@@ -184,180 +184,6 @@ static bool bad_spectre_microcode(struct cpuinfo_x86 *c)
184
184
return false;
185
185
}
186
186
187
- int intel_cpu_collect_info (struct ucode_cpu_info * uci )
188
- {
189
- unsigned int val [2 ];
190
- unsigned int family , model ;
191
- struct cpu_signature csig = { 0 };
192
- unsigned int eax , ebx , ecx , edx ;
193
-
194
- memset (uci , 0 , sizeof (* uci ));
195
-
196
- eax = 0x00000001 ;
197
- ecx = 0 ;
198
- native_cpuid (& eax , & ebx , & ecx , & edx );
199
- csig .sig = eax ;
200
-
201
- family = x86_family (eax );
202
- model = x86_model (eax );
203
-
204
- if (model >= 5 || family > 6 ) {
205
- /* get processor flags from MSR 0x17 */
206
- native_rdmsr (MSR_IA32_PLATFORM_ID , val [0 ], val [1 ]);
207
- csig .pf = 1 << ((val [1 ] >> 18 ) & 7 );
208
- }
209
-
210
- csig .rev = intel_get_microcode_revision ();
211
-
212
- uci -> cpu_sig = csig ;
213
-
214
- return 0 ;
215
- }
216
- EXPORT_SYMBOL_GPL (intel_cpu_collect_info );
217
-
218
- /*
219
- * Returns 1 if update has been found, 0 otherwise.
220
- */
221
- int intel_find_matching_signature (void * mc , unsigned int csig , int cpf )
222
- {
223
- struct microcode_header_intel * mc_hdr = mc ;
224
- struct extended_sigtable * ext_hdr ;
225
- struct extended_signature * ext_sig ;
226
- int i ;
227
-
228
- if (intel_cpu_signatures_match (csig , cpf , mc_hdr -> sig , mc_hdr -> pf ))
229
- return 1 ;
230
-
231
- /* Look for ext. headers: */
232
- if (get_totalsize (mc_hdr ) <= get_datasize (mc_hdr ) + MC_HEADER_SIZE )
233
- return 0 ;
234
-
235
- ext_hdr = mc + get_datasize (mc_hdr ) + MC_HEADER_SIZE ;
236
- ext_sig = (void * )ext_hdr + EXT_HEADER_SIZE ;
237
-
238
- for (i = 0 ; i < ext_hdr -> count ; i ++ ) {
239
- if (intel_cpu_signatures_match (csig , cpf , ext_sig -> sig , ext_sig -> pf ))
240
- return 1 ;
241
- ext_sig ++ ;
242
- }
243
- return 0 ;
244
- }
245
- EXPORT_SYMBOL_GPL (intel_find_matching_signature );
246
-
247
- /**
248
- * intel_microcode_sanity_check() - Sanity check microcode file.
249
- * @mc: Pointer to the microcode file contents.
250
- * @print_err: Display failure reason if true, silent if false.
251
- * @hdr_type: Type of file, i.e. normal microcode file or In Field Scan file.
252
- * Validate if the microcode header type matches with the type
253
- * specified here.
254
- *
255
- * Validate certain header fields and verify if computed checksum matches
256
- * with the one specified in the header.
257
- *
258
- * Return: 0 if the file passes all the checks, -EINVAL if any of the checks
259
- * fail.
260
- */
261
- int intel_microcode_sanity_check (void * mc , bool print_err , int hdr_type )
262
- {
263
- unsigned long total_size , data_size , ext_table_size ;
264
- struct microcode_header_intel * mc_header = mc ;
265
- struct extended_sigtable * ext_header = NULL ;
266
- u32 sum , orig_sum , ext_sigcount = 0 , i ;
267
- struct extended_signature * ext_sig ;
268
-
269
- total_size = get_totalsize (mc_header );
270
- data_size = get_datasize (mc_header );
271
-
272
- if (data_size + MC_HEADER_SIZE > total_size ) {
273
- if (print_err )
274
- pr_err ("Error: bad microcode data file size.\n" );
275
- return - EINVAL ;
276
- }
277
-
278
- if (mc_header -> ldrver != 1 || mc_header -> hdrver != hdr_type ) {
279
- if (print_err )
280
- pr_err ("Error: invalid/unknown microcode update format. Header type %d\n" ,
281
- mc_header -> hdrver );
282
- return - EINVAL ;
283
- }
284
-
285
- ext_table_size = total_size - (MC_HEADER_SIZE + data_size );
286
- if (ext_table_size ) {
287
- u32 ext_table_sum = 0 ;
288
- u32 * ext_tablep ;
289
-
290
- if (ext_table_size < EXT_HEADER_SIZE ||
291
- ((ext_table_size - EXT_HEADER_SIZE ) % EXT_SIGNATURE_SIZE )) {
292
- if (print_err )
293
- pr_err ("Error: truncated extended signature table.\n" );
294
- return - EINVAL ;
295
- }
296
-
297
- ext_header = mc + MC_HEADER_SIZE + data_size ;
298
- if (ext_table_size != exttable_size (ext_header )) {
299
- if (print_err )
300
- pr_err ("Error: extended signature table size mismatch.\n" );
301
- return - EFAULT ;
302
- }
303
-
304
- ext_sigcount = ext_header -> count ;
305
-
306
- /*
307
- * Check extended table checksum: the sum of all dwords that
308
- * comprise a valid table must be 0.
309
- */
310
- ext_tablep = (u32 * )ext_header ;
311
-
312
- i = ext_table_size / sizeof (u32 );
313
- while (i -- )
314
- ext_table_sum += ext_tablep [i ];
315
-
316
- if (ext_table_sum ) {
317
- if (print_err )
318
- pr_warn ("Bad extended signature table checksum, aborting.\n" );
319
- return - EINVAL ;
320
- }
321
- }
322
-
323
- /*
324
- * Calculate the checksum of update data and header. The checksum of
325
- * valid update data and header including the extended signature table
326
- * must be 0.
327
- */
328
- orig_sum = 0 ;
329
- i = (MC_HEADER_SIZE + data_size ) / sizeof (u32 );
330
- while (i -- )
331
- orig_sum += ((u32 * )mc )[i ];
332
-
333
- if (orig_sum ) {
334
- if (print_err )
335
- pr_err ("Bad microcode data checksum, aborting.\n" );
336
- return - EINVAL ;
337
- }
338
-
339
- if (!ext_table_size )
340
- return 0 ;
341
-
342
- /*
343
- * Check extended signature checksum: 0 => valid.
344
- */
345
- for (i = 0 ; i < ext_sigcount ; i ++ ) {
346
- ext_sig = (void * )ext_header + EXT_HEADER_SIZE +
347
- EXT_SIGNATURE_SIZE * i ;
348
-
349
- sum = (mc_header -> sig + mc_header -> pf + mc_header -> cksum ) -
350
- (ext_sig -> sig + ext_sig -> pf + ext_sig -> cksum );
351
- if (sum ) {
352
- if (print_err )
353
- pr_err ("Bad extended signature checksum, aborting.\n" );
354
- return - EINVAL ;
355
- }
356
- }
357
- return 0 ;
358
- }
359
- EXPORT_SYMBOL_GPL (intel_microcode_sanity_check );
360
-
361
187
static void early_init_intel (struct cpuinfo_x86 * c )
362
188
{
363
189
u64 misc_enable ;
0 commit comments