Re: [PATCH v3 03/22] x86: Replace ist_enter() with nmi_enter()

From: Peter Zijlstra
Date: Thu Feb 20 2020 - 07:11:39 EST


On Thu, Feb 20, 2020 at 11:54:39AM +0100, Borislav Petkov wrote:
> On Wed, Feb 19, 2020 at 03:47:27PM +0100, Peter Zijlstra wrote:
> > @@ -1220,7 +1220,7 @@ static void mce_kill_me_maybe(struct cal
> > * MCE broadcast. However some CPUs might be broken beyond repair,
> > * so be always careful when synchronizing with others.
> > */
> > -void do_machine_check(struct pt_regs *regs, long error_code)
> > +notrace void do_machine_check(struct pt_regs *regs, long error_code)
>
> Is there a convention where the notrace marker should come in the
> function signature? I see all possible combinations while grepping...

Same place as inline I think.

> > {
> > DECLARE_BITMAP(valid_banks, MAX_NR_BANKS);
> > DECLARE_BITMAP(toclear, MAX_NR_BANKS);
> > @@ -1254,10 +1254,10 @@ void do_machine_check(struct pt_regs *re
> > */
> > int lmce = 1;
> >
> > - if (__mc_check_crashing_cpu(cpu))
> > - return;
> > + nmi_enter();
> >
> > - ist_enter(regs);
> > + if (__mc_check_crashing_cpu(cpu))
> > + goto out;
> >
> > this_cpu_inc(mce_exception_count);
> >
>
> Should that __mc_check_crashing_cpu() happen before nmi_enter? The
> function is doing only a bunch of checks and clearing MSRs for bystander
> CPUs...

You'll note the lack of notrace on that function, and we must not call
into tracers before nmi_enter().

AFAICT there really is no benefit to trying to lift it before
nmi_enter().