[PATCH] xtensa: fix register access using PTRACE_GETREGS API

Max Filippov jcmvbkbc at gmail.com
Mon Mar 28 19:06:36 UTC 2022


On Mon, Mar 28, 2022 at 4:37 AM Dmitry V. Levin <ldv at altlinux.org> wrote:
>
> On Sun, Mar 27, 2022 at 08:50:08PM -0700, Max Filippov wrote:
> > The commit 2429c69961e2 ("xtensa: switch to PTRACE_GETREGS API") changed
> > the way xtensa registers are accessed, but the change is only correct
> > in case when the xtensa_regs.windowbase is 0 (i.e. the current register
> > window starts at the physical registr 0). In other cases decoded syscall
> > arguments are bogus. This issue is currently observed on noMMU xtensa
> > linux because it uses PTRACE_GETREGS API, while configurations with MMU
> > default to using ptrace_get_syscall_info.
>
> Since strace cannot perform fork-based runtime tests on noMMU systems,
> wouldn't it be a good idea to change the default and assume that
> PTRACE_GET_SYSCALL_INFO works there?

I guess so, but somehow I failed at my first attempt. I'll have another look.

> [...]
> > +static unsigned int xtensa_probe_naregs(struct tcb *tcp)
> > +{
> > +     struct user_pt_regs tmp = xtensa_regs;
> > +     unsigned int n = 8;
> > +
> > +     do {
> > +             n *= 2;
> > +             xtensa_regs.windowbase = n / 4;
> > +     } while (set_regs(tcp->pid) == 0);
>
> I think there should be a way out if set_regs fails, so that this function
> wouldn't hang e.g. when tcp->pid disappears.

This loop ends when set_regs fails, but I agree that n shouldn't grow
bigger than xtensa_regs.a array. I'll send v2 with that change.

-- 
Thanks.
-- Max


More information about the Strace-devel mailing list