Re: [PATCH v4 05/27] x86: Replace ist_enter() with nmi_enter()

From: Andy Lutomirski
Date: Fri Feb 21 2020 - 14:05:52 EST


On Fri, Feb 21, 2020 at 5:50 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> A few exceptions (like #DB and #BP) can happen at any location in the
> code, this then means that tracers should treat events from these
> exceptions as NMI-like. We could be holding locks with interrupts
> disabled for instance.
>
> Similarly, #MC is an actual NMI-like exception.
>

> -dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
> +dotraplinkage notrace void do_int3(struct pt_regs *regs, long error_code)
> {
> if (poke_int3_handler(regs))
> return;
>
> - /*
> - * Use ist_enter despite the fact that we don't use an IST stack.
> - * We can be called from a kprobe in non-CONTEXT_KERNEL kernel
> - * mode or even during context tracking state changes.
> - *
> - * This means that we can't schedule. That's okay.
> - */
> - ist_enter(regs);
> + nmi_enter();

I agree with the change, but some commentary might be nice. Maybe
copy from here:

https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/commit/?h=x86/idtentry&id=061eaa900b4f63601ab6381ab431fcef8dfd84be