Re: [patch V6 07/37] x86/entry: Provide helpers for execute on irqstack

From: Andy Lutomirski
Date: Wed May 20 2020 - 11:09:22 EST


On Wed, May 20, 2020 at 5:35 AM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> Andy Lutomirski <luto@xxxxxxxxxx> writes:
> > On Mon, May 18, 2020 at 4:53 PM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
> >>
> >> Andy Lutomirski <luto@xxxxxxxxxx> writes:
> >> > Actually, I revoke my ack. Can you make one of two changes:
> >> >
> >> > Option A: Add an assertion to run_on_irqstack to verify that irq_count
> >> > was -1 at the beginning? I suppose this also means you could just
> >> > explicitly write 0 instead of adding and subtracting.
> >> >
> >> > Option B: Make run_on_irqstack() just call the function on the current
> >> > stack if we're already on the irq stack.
> >> >
> >> > Right now, it's too easy to mess up and not verify the right
> >> > precondition before calling run_on_irqstack().
> >> >
> >> > If you choose A, perhaps add a helper to do the if(irq_needs_irqstack)
> >> > dance so that users can just do:
> >> >
> >> > run_on_irqstack_if_needed(...);
> >> >
> >> > instead of checking everything themselves.
> >>
> >> I'll have a look tomorrow morning with brain awake.
> >
> > Also, reading more of the series, I suspect that asm_call_on_stack is
> > logically in the wrong section or that the noinstr stuff is otherwise
> > not quite right. I think that objtool should not accept
> > run_on_irqstack() from noinstr code. See followups on patch 10.
>
> It's in entry.text which is non-instrumentable as well.

Hmm. I suppose we can chalk this up to the noinstr checking not being
entirely perfect.