@@ -127,7 +127,7 @@ static struct irq_work mce_irq_work;
127
127
BLOCKING_NOTIFIER_HEAD (x86_mce_decoder_chain );
128
128
129
129
/* Do initial initialization of a struct mce */
130
- noinstr void mce_setup (struct mce * m )
130
+ void mce_setup (struct mce * m )
131
131
{
132
132
memset (m , 0 , sizeof (struct mce ));
133
133
m -> cpu = m -> extcpu = smp_processor_id ();
@@ -430,9 +430,15 @@ static noinstr void mce_wrmsrl(u32 msr, u64 v)
430
430
* check into our "mce" struct so that we can use it later to assess
431
431
* the severity of the problem as we read per-bank specific details.
432
432
*/
433
- static inline void mce_gather_info (struct mce * m , struct pt_regs * regs )
433
+ static noinstr void mce_gather_info (struct mce * m , struct pt_regs * regs )
434
434
{
435
+ /*
436
+ * Enable instrumentation around mce_setup() which calls external
437
+ * facilities.
438
+ */
439
+ instrumentation_begin ();
435
440
mce_setup (m );
441
+ instrumentation_end ();
436
442
437
443
m -> mcgstatus = mce_rdmsrl (MSR_IA32_MCG_STATUS );
438
444
if (regs ) {
@@ -1312,11 +1318,11 @@ static noinstr void unexpected_machine_check(struct pt_regs *regs)
1312
1318
}
1313
1319
1314
1320
/*
1315
- * The actual machine check handler. This only handles real
1316
- * exceptions when something got corrupted coming in through int 18.
1321
+ * The actual machine check handler. This only handles real exceptions when
1322
+ * something got corrupted coming in through int 18.
1317
1323
*
1318
- * This is executed in NMI context not subject to normal locking rules. This
1319
- * implies that most kernel services cannot be safely used. Don't even
1324
+ * This is executed in #MC context not subject to normal locking rules.
1325
+ * This implies that most kernel services cannot be safely used. Don't even
1320
1326
* think about putting a printk in there!
1321
1327
*
1322
1328
* On Intel systems this is entered on all CPUs in parallel through
@@ -1328,6 +1334,14 @@ static noinstr void unexpected_machine_check(struct pt_regs *regs)
1328
1334
* issues: if the machine check was due to a failure of the memory
1329
1335
* backing the user stack, tracing that reads the user stack will cause
1330
1336
* potentially infinite recursion.
1337
+ *
1338
+ * Currently, the #MC handler calls out to a number of external facilities
1339
+ * and, therefore, allows instrumentation around them. The optimal thing to
1340
+ * have would be to do the absolutely minimal work required in #MC context
1341
+ * and have instrumentation disabled only around that. Further processing can
1342
+ * then happen in process context where instrumentation is allowed. Achieving
1343
+ * that requires careful auditing and modifications. Until then, the code
1344
+ * allows instrumentation temporarily, where required. *
1331
1345
*/
1332
1346
noinstr void do_machine_check (struct pt_regs * regs )
1333
1347
{
0 commit comments