[PATCH 1/2] powerpc64/ftrace: Add a field in paca to disable ftrace in unsafe code paths

Nicholas Piggin npiggin at gmail.com
Tue Mar 20 11:05:59 AEDT 2018


On Tue, 20 Mar 2018 09:34:43 +1100
Michael Ellerman <mpe at ellerman.id.au> wrote:

> Nicholas Piggin <npiggin at gmail.com> writes:
> 
> > On Mon, 19 Mar 2018 14:43:00 +0530
> > "Naveen N. Rao" <naveen.n.rao at linux.vnet.ibm.com> wrote:
> >  
> >> We have some C code that we call into from real mode where we cannot
> >> take any exceptions. Though the C functions themselves are mostly safe,
> >> if these functions are traced, there is a possibility that we may take
> >> an exception. For instance, in certain conditions, the ftrace code uses
> >> WARN(), which uses a 'trap' to do its job.
> >> 
> >> For such scenarios, introduce a new field in paca 'ftrace_disabled',
> >> which is checked on ftrace entry before continuing. This field can then
> >> be set to a non-zero value to disable/pause ftrace, and reset to zero to
> >> resume ftrace.
> >> 
> >> Since KVM is the only user for this currently, we guard the
> >> ftrace/mcount checks within CONFIG_KVM. This can later be removed
> >> if/when there are other users.  
> >
> > Why not test HSTATE_IN_GUEST then? Add ftrace_disabled if non-KVM users
> > come along.  
> 
> We want to use it for the kexec down path, we've already had bugs there.
> 
> So please keep the separate flag and pull it out of #ifdef KVM.

Okay that's fine.

> If we're worried about space usage in the paca we can probably
> consolidate this and some other things into a flags word.

I'm not too concerned about some more u8 flags.

Thanks,
Nick


More information about the Linuxppc-dev mailing list