Re: [PATCH] ARM: UNWINDER_FRAME_POINTER implementation for Clang
From: Nick Desaulniers
Date: Wed Aug 21 2019 - 22:38:01 EST
On Wed, Aug 21, 2019 at 10:43 AM Nathan Huckleberry <nhuck@xxxxxxxxxx> wrote:
>
> On Tue, Aug 20, 2019 at 2:39 PM Nick Desaulniers
> <ndesaulniers@xxxxxxxxxx> wrote:
> >
> > On Tue, Aug 20, 2019 at 12:44 PM Nathan Huckleberry <nhuck@xxxxxxxxxx> wrote:
...snip...
> > > +tst r1, #0x10 @ 26 or 32-bit mode?
> > > +moveq mask, #0xfc000003
> >
> > Should we be using different masks for ARM vs THUMB as per the
> > reference implementation?
> The change that introduces the arm/thumb code looked like a script
> that was run over all arm in the kernel. Neither this code nor the
> reference solution is compatible with arm, so there's no need for the
> change.
Looks like you're referring to commit 8b592783a2e8 ("Thumb-2:
Implement the unified arch/arm/lib functions").
Currently, arch/arm/Kconfig.debug has:
57 config UNWINDER_FRAME_POINTER
58 bool "Frame pointer unwinder"
59 depends on !THUMB2_KERNEL && !CC_IS_CLANG
So it looks like UNWINDER_FRAME_POINTER and THUMB2_KERNEL are mutually
exclusive. Probably could send a patch cleaning that up. (ie.
removing the different masks; essentially removing the hunk from
arch/arm/lib/backtrace.S from 8b592783a2e8).
> > > +for_each_frame: tst frame, mask @ Check for address exceptions
> > > + bne no_frame
> > > +
> > > +/*
> > > + * sv_fp is the stack frame with the locals for the current considered
> > > + * function.
> > > + * sv_pc is the saved lr frame the frame above. This is a pointer to a
> > > + * code address within the current considered function, but
> > > + * it is not the function start. This value gets updated to be
> > > + * the function start later if it is possible.
> > > + */
> > > +1001: ldr sv_pc, [frame, #4] @ get saved 'pc'
> > > +1002: ldr sv_fp, [frame, #0] @ get saved fp
> >
> > The reference implementation applies the mask to sv_pc and sv_fp. I
> > assume we want to, too?
> The mask is already applied to both. See for_each_frame:
ah, under the finished_setup label.
--
Thanks,
~Nick Desaulniers