Re: [patch V2 07/17] x86/entry/64: Remove redundant interrupt disable

From: Andy Lutomirski
Date: Thu Oct 24 2019 - 12:18:44 EST


On Wed, Oct 23, 2019 at 4:52 PM Thomas Gleixner <tglx@xxxxxxxxxxxxx> wrote:
>
> On Wed, 23 Oct 2019, Josh Poimboeuf wrote:
>
> > On Wed, Oct 23, 2019 at 02:27:12PM +0200, Thomas Gleixner wrote:
> > > Now that the trap handlers return with interrupts disabled, the
> > > unconditional disabling of interrupts in the low level entry code can be
> > > removed along with the trace calls.
> > >
> > > Add debug checks where appropriate.
> >
> > This seems a little scary. Does anybody other than Andy actually run
> > with CONFIG_DEBUG_ENTRY?
>
> I do.
>
> > What happens if somebody accidentally leaves irqs enabled? How do we
> > know you found all the leaks?
>
> For the DO_ERROR() ones that's trivial:
>
> #define DO_ERROR(trapnr, signr, sicode, addr, str, name) \
> dotraplinkage void do_##name(struct pt_regs *regs, long error_code) \
> { \
> do_error_trap(regs, error_code, str, trapnr, signr, sicode, addr); \
> + lockdep_assert_irqs_disabled(); \
> }
>
> DO_ERROR(X86_TRAP_DE, SIGFPE, FPE_INTDIV, IP, "divide error", divide_error)
>
> Now for the rest we surely could do:
>
> dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
> {
> __do_bounds(regs, error_code);
> lockdep_assert_irqs_disabled();
> }
>
> and move the existing body into a static function so independent of any
> (future) return path there the lockdep assert will be invoked.
>

If we do this, can we macro-ize it:

DEFINE_IDTENTRY_HANDLER(do_bounds)
{
...
}

If you do this, please don't worry about the weird ones that take cr2
as a third argument. Once your series lands, I will send a follow-up
to get rid of it. It's 2/3 written already.