[PATCH] xtensa: fix register access using PTRACE_GETREGS API
Dmitry V. Levin
ldv at altlinux.org
Mon Mar 28 11:37:42 UTC 2022
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?
[...]
> +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.
--
ldv
More information about the Strace-devel
mailing list