RE: [RFC PATCH] x86, entry: Switch stacks on a paranoid entry from userspace
From: Luck, Tony
Date: Tue Nov 11 2014 - 17:01:09 EST
So here is the flow:
1) A machine check happens - it is (currently) broadcast to all logical cpus on all sockets
2) First cpu to execute "order = atomic_inc_return(&mce_callin);" in mce_start() gets to be the "monarch" and directs things during the handler.
3) Every cpu gets to scan all the machine check banks to see what happened. If the error was a fatal one we are going to panic - this isn't the interesting case.
4) There are two kinds of recoverable error
4a) Ones not in execution context (SRAO = Software Recoverable Action Optional) - these also aren't very interesting - save the address in a NMI safe ring buffer to process later
4b) In execution context (SRAR = Software Recoverable Action Required) - this is where we need to do some real work to convert from the physical address logged to the list of affected processes.
Now when we get to step 4b - we need to let all the other processors return from the machine check handler (they may have been interrupted in kernel context and could hold locks that we need).
We also need to clear the MSR MCG_STATUS (on each logical cpu) to indicate we are done with this machine check.
Andy - with your RFC patch - can we just make the bottom end of do_machine_check() look like this:
/* collected everything we need from banks - re-enable machine check on all cpus */
mce_wrmsrl(MSR_IA32_MCG_STATUS, 0);
if (we are *not* the thread with the SRAR error)
return;
/* do all the things that were previously in mce_notify_process() here */
}
and if we do this - what happens if we get another machine check while we are in the "do all the things" bit?
-Tony
N§²æ¸yú²X¬¶ÇvØ)Þ{.nÇ·¥{±êX§¶¡Ü}©²ÆzÚj:+v¨¾«êZ+Êzf£¢·h§~Ûÿû®w¥¢¸?¨è&¢)ßfùy§m
á«a¶Úÿ0¶ìå