Re: [RFC] #MC mess

From: Andy Lutomirski
Date: Tue Feb 18 2020 - 19:16:13 EST


On Tue, Feb 18, 2020 at 9:31 AM Borislav Petkov <bp@xxxxxxxxx> wrote:
>
> Ok,
>
> so Peter raised this question on IRC today, that the #MC handler needs
> to disable all kinds of tracing/kprobing and etc exceptions happening
> while handling an #MC. And I guess we can talk about supporting some
> exceptions but #MC is usually nasty enough to not care about tracing
> when former happens.
>

It's worth noting that MCE is utterly, terminally screwed under high
load. In particular:

Step 1: NMI (due to perf).

immediately thereafter (before any of the entry asm runs)

Step 2: MCE (due to recoverable memory failure or remote CPU MCE)

Step 3: MCE does its thing and does IRET

Step 4: NMI

We are toast.

Tony, etc, can you ask your Intel contacts who care about this kind of
thing to stop twiddling their thumbs and FIX IT? The easy fix is
utterly trivial. Add a new instruction IRET_NON_NMI. It does
*exactly* the same thing as IRET except that it does not unmask NMIs.
(It also doesn't unmask NMIs if it faults.) No fancy design work.
Future improvements can still happen on top of this.

(One other improvement that may or may not have happened: the CPU
should be configurable so that it never even sends #MC unless it
literally cannot continue executing without OS help. No remote MCE
triggering #MC, no notifications of corrected errors, no nothing. If
the CPU *cannot* continue execution in its current context, for
example because a load could not be satisfied, send #MC. If a cache
line cannot be written back, then *which* CPU should get the MCE is an
interesting question.)

If Intel cares about memory failure recovery, then this design problem
needs to be fixed. Without a fix, we're just duct taping little holes
and ignoring the giant gaping hole in front of our faces.