lkml.org 
[lkml]   [2020]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch V4 part 2 10/18] x86/entry/64: Check IF in __preempt_enable_notrace() thunk
On Fri, 8 May 2020 17:10:09 -0700
Andy Lutomirski <luto@kernel.org> wrote:

> On Tue, May 5, 2020 at 7:14 AM Thomas Gleixner <tglx@linutronix.de> wrote:
> >
> > The preempt_enable_notrace() ASM thunk is called from tracing, entry code
> > RCU and other places which are already in or going to be in the noinstr
> > section which protects sensitve code from being instrumented.
>
> This text and $SUBJECT agree that you're talking about
> preempt_enable_notrace(), but:
>
> > + THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace, check_if=1
>
> You actually seem to be changing preempt_schedule_notrace().
>
> The actual code in question has this comment:
>
> /**
> * preempt_schedule_notrace - preempt_schedule called by tracing
> *
> * The tracing infrastructure uses preempt_enable_notrace to prevent
> * recursion and tracing preempt enabling caused by the tracing
> * infrastructure itself. But as tracing can happen in areas coming
> * from userspace or just about to enter userspace, a preempt enable
> * can occur before user_exit() is called. This will cause the scheduler
> * to be called when the system is still in usermode.
> *
> * To prevent this, the preempt_enable_notrace will use this function
> * instead of preempt_schedule() to exit user context if needed before
> * calling the scheduler.
> */
>
> Which is no longer really applicable to x86 -- in the state that this
> comment nonsensically refers to as "userspace", x86 *always* has IRQs
> off, which means that preempt_enable() will not schedule.
>
> So I'm guessing that the issue you're solving is that we have
> redundant preempt disable/enable pairs somewhere in the bowels of
> tracing code that is called with IRQs off, and objtool is now
> complaining. Could the actual code in question be fixed to assert
> that IRQs are off instead of disabling preemption? If not, can you
> fix the $SUBJECT and changelog and perhaps add a comment to the code
> as to *why* you're checking IF? Otherwise some intrepid programmer is
> going to notice it down the road, wonder if it's optimizing anything
> useful at all, and get rid of it.

The commit that added that code is this:

29bb9e5a75684106a37593ad75ec75ff8312731b

And it may not be applicable anymore, especially after Thomas's
patches. I'll go and stare at that some more. A lot has changed since
2013 ;-)

-- Steve

\
 
 \ /
  Last update: 2020-05-12 03:48    [W:0.163 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site