Re: [patch 4/8] x86/entry: Move irq tracing on syscall entry to C-code

From: Thomas Gleixner
Date: Sat Feb 29 2020 - 09:44:33 EST


Thomas Gleixner <tglx@xxxxxxxxxxxxx> writes:
> Andy Lutomirski <luto@xxxxxxxxxxxxxx> writes:
>>> On Feb 26, 2020, at 12:17 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>>> ïOn Tue, Feb 25, 2020 at 09:43:46PM -0800, Andy Lutomirski wrote:
>>>> Your earlier patches suggest quite strongly that tracing isn't safe
>>>> until enter_from_user_mode(). But trace_hardirqs_off() calls
>>>> trace_irq_disable_rcuidle(), which looks [0] like a tracepoint.
>>>>
>>>> Did you perhaps mean to do this *after* enter_from_user_mode()?
>>>
>>> aside from the fact that enter_from_user_mode() itself also has a
>>> tracepoint, the crucial detail is that we must not trace/kprobe the
>>> function calling this.
>>>
>>> Specifically for #PF, because we need read_cr2() before this. See later
>>> patches.
>>
>> Indeed. Iâm fine with this patch, but I still donât understand what
>> the changelog is about.
>
> Yeah, the changelog is not really helpful. Let me fix that.
>
>> And Iâm still rather baffled by most of the notrace annotations in the
>> series.
>
> As discussed on IRC, this might be too broad, but then I rather have the
> actual C-entry points neither traceable nor probable in general and
> relax this by calling functions which can be traced and probed.
>
> My rationale for this decision was that enter_from_user_mode() is marked
> notrace/noprobe as well, so I kept the protection scope the same as we
> had in the ASM maze which is marked noprobe already.

I have second thoughts vs. tracing in this context.

While the tracer itself seems to handle this correctly, what about
things like BPF programs which can be attached to tracepoints and
function trace entries?

Is that really safe _before_ context tracking has updated RCU state?

Thanks,

tglx