Re: [PATCH v3 6/6] x86/entry/64: Remove TRACE_IRQS_*_DEBUG

From: Andy Lutomirski
Date: Thu Jul 11 2019 - 10:46:11 EST


On Thu, Jul 11, 2019 at 4:51 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> Since INT3/#BP no longer runs on an IST, this workaround is no longer
> required.
>
> Tested by running lockdep+ftrace as described in the initial commit:
>
> 5963e317b1e9 ("ftrace/x86: Do not change stacks in DEBUG when calling lockdep")
>
> Reviewed-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

I would definitely like to see this happen, but there are all kinds of
possibly nasties here. Ideally we'd like get rid of IST for #DB, but
we can't due to the MOV SS mess. There are a few relevant cases we
care about:

#DB from user mode -> anything that hits in C code: irrelevant --
we've exited the IST stack already.

#DB from user mode -> NMI/MCE in the asm -> #DB: The NMI code tries to
get this right. The MCE code does not.

#DB from kernel mode -> NMI/MCE -> #DB: same as above.

MOV SS -> #DB from entry -> #DB again: ugh. We get some protection
from shift_ist.

IMO we would ideally just clear DR7 in sensitive contexts. Or extend
the debug_stack_set_zero(), etc hack.

All that being said, the actual _DEBUG macros shouldn't matter here, I
think. But I'd like to sleep on it. So not-yet-acked-by me.