@@ -263,24 +263,36 @@ static bool is_copy_from_user(struct pt_regs *regs)
263
263
* distinguish an exception taken in user from from one
264
264
* taken in the kernel.
265
265
*/
266
- static int error_context (struct mce * m , struct pt_regs * regs )
266
+ static noinstr int error_context (struct mce * m , struct pt_regs * regs )
267
267
{
268
+ int fixup_type ;
269
+ bool copy_user ;
270
+
268
271
if ((m -> cs & 3 ) == 3 )
269
272
return IN_USER ;
273
+
270
274
if (!mc_recoverable (m -> mcgstatus ))
271
275
return IN_KERNEL ;
272
276
273
- switch (ex_get_fixup_type (m -> ip )) {
277
+ /* Allow instrumentation around external facilities usage. */
278
+ instrumentation_begin ();
279
+ fixup_type = ex_get_fixup_type (m -> ip );
280
+ copy_user = is_copy_from_user (regs );
281
+ instrumentation_end ();
282
+
283
+ switch (fixup_type ) {
274
284
case EX_TYPE_UACCESS :
275
285
case EX_TYPE_COPY :
276
- if (!regs || !is_copy_from_user ( regs ) )
286
+ if (!regs || !copy_user )
277
287
return IN_KERNEL ;
278
288
m -> kflags |= MCE_IN_KERNEL_COPYIN ;
279
289
fallthrough ;
290
+
280
291
case EX_TYPE_FAULT_MCE_SAFE :
281
292
case EX_TYPE_DEFAULT_MCE_SAFE :
282
293
m -> kflags |= MCE_IN_KERNEL_RECOV ;
283
294
return IN_KERNEL_RECOV ;
295
+
284
296
default :
285
297
return IN_KERNEL ;
286
298
}
@@ -315,8 +327,8 @@ static int mce_severity_amd_smca(struct mce *m, enum context err_ctx)
315
327
* See AMD Error Scope Hierarchy table in a newer BKDG. For example
316
328
* 49125_15h_Models_30h-3Fh_BKDG.pdf, section "RAS Features"
317
329
*/
318
- static int mce_severity_amd (struct mce * m , struct pt_regs * regs , int tolerant ,
319
- char * * msg , bool is_excp )
330
+ static noinstr int mce_severity_amd (struct mce * m , struct pt_regs * regs , int tolerant ,
331
+ char * * msg , bool is_excp )
320
332
{
321
333
enum context ctx = error_context (m , regs );
322
334
@@ -368,8 +380,8 @@ static int mce_severity_amd(struct mce *m, struct pt_regs *regs, int tolerant,
368
380
return MCE_KEEP_SEVERITY ;
369
381
}
370
382
371
- static int mce_severity_intel (struct mce * m , struct pt_regs * regs ,
372
- int tolerant , char * * msg , bool is_excp )
383
+ static noinstr int mce_severity_intel (struct mce * m , struct pt_regs * regs ,
384
+ int tolerant , char * * msg , bool is_excp )
373
385
{
374
386
enum exception excp = (is_excp ? EXCP_CONTEXT : NO_EXCP );
375
387
enum context ctx = error_context (m , regs );
@@ -405,8 +417,8 @@ static int mce_severity_intel(struct mce *m, struct pt_regs *regs,
405
417
}
406
418
}
407
419
408
- int mce_severity (struct mce * m , struct pt_regs * regs , int tolerant , char * * msg ,
409
- bool is_excp )
420
+ int noinstr mce_severity (struct mce * m , struct pt_regs * regs , int tolerant , char * * msg ,
421
+ bool is_excp )
410
422
{
411
423
if (boot_cpu_data .x86_vendor == X86_VENDOR_AMD ||
412
424
boot_cpu_data .x86_vendor == X86_VENDOR_HYGON )
0 commit comments