This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix PTRACE_GETREGSET failure for compat inferiors on arm64
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Kees Cook <keescook at chromium dot org>
- Cc: gdb-patches at sourceware dot org, brian dot murray at canonical dot com, matthias dot klose at canonical dot com
- Date: Fri, 2 Dec 2016 22:49:52 +0000
- Subject: Re: [PATCH] Fix PTRACE_GETREGSET failure for compat inferiors on arm64
- Authentication-results: sourceware.org; auth=none
- References: <20161202214613.GA54717@beast>
On 16-12-02 13:46:13, Kees Cook wrote:
> When running a 32-bit ARM inferior on a 64-bit ARM host, only the hardware
> floating-point registers (NT_ARM_VFP) are available. If the inferior
> uses hard-float, do not request soft-float registers (NT_PRFPREG) and
> run the risk of failing with EINVAL. This is most noticeably exposed
"soft-float" is not accurate. FPA is coprocessor. Both VFP and FPA is
implemented in the combination of software and hardware. I'd like to
rewrite the commit log like this,
"When running a 32-bit ARM inferior with a 32-bit ARM GDB on 64-bit
AArch64 host, only VFP registers (NT_ARM_VFP) are available. The FPA
registers (NT_PRFPREG) is not available."
> when running "generate-core-file":
>
> (gdb) generate-core-file myprog.core
> Unable to fetch the floating point registers.: Invalid argument.
>
> ptrace(PTRACE_GETREGSET, 27642, NT_FPREGSET, 0xffcc67f0) = -1 EINVAL (Invalid argument)
>
> gdb/ChangeLog:
>
> 2016-12-02 Kees Cook <keescook@google.com>
You don't have FSF copyright assignment.
>
> * gdb/arm-linux-nat.c: Skip soft-float registers when using hard-float.
>
> ---
> gdb/arm-linux-nat.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
> index d11bdc6..2126cd7 100644
> --- a/gdb/arm-linux-nat.c
> +++ b/gdb/arm-linux-nat.c
> @@ -384,17 +384,19 @@ arm_linux_fetch_inferior_registers (struct target_ops *ops,
> if (-1 == regno)
> {
> fetch_regs (regcache);
> - fetch_fpregs (regcache);
We should only call fetch_fpregs if tdep->have_fpa_registers is true.
> if (tdep->have_wmmx_registers)
> fetch_wmmx_regs (regcache);
> if (tdep->vfp_register_count > 0)
> fetch_vfp_regs (regcache);
> + else
> + fetch_fpregs (regcache);
> }
> - else
> + else
> {
> if (regno < ARM_F0_REGNUM || regno == ARM_PS_REGNUM)
> fetch_regs (regcache);
> - else if (regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM)
> + else if (tdep->vfp_register_count == 0
> + && regno >= ARM_F0_REGNUM && regno <= ARM_FPS_REGNUM)
> fetch_fpregs (regcache);
Do we really need this change? If FPA registers are not available,
REGNO can't fall in this range (ARM_F0_REGNUM, ARM_FPS_REGNUM).
These two comments above also apply to store registers.
--
Yao