This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH V5 2/3] Add AVX512 register support to gdbserver.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Andreas Arnez <arnez at linux dot vnet dot ibm dot com>
- Cc: Michael Sturm <michael dot sturm at intel dot com>, palves at redhat dot com, eliz at gnu dot org, mark dot kettenis at xs4all dot nl, walfred dot tedeschi at intel dot com, gdb-patches at sourceware dot org
- Date: Sat, 13 Dec 2014 08:41:46 -0500
- Subject: Re: [PATCH V5 2/3] Add AVX512 register support to gdbserver.
- Authentication-results: sourceware.org; auth=none
- References: <1398258160-9070-1-git-send-email-michael dot sturm at intel dot com> <1398258160-9070-3-git-send-email-michael dot sturm at intel dot com> <87ppcgrh0o dot fsf at br87z6lw dot de dot ibm dot com>
> While building GDB I encountered a gcc warning (array subscript above
> array bounds) and tracked it down to the patch below.
Thanks!
> On Wed, Apr 23 2014, Michael Sturm wrote:
>
> > # Linux object files. This is so we don't have to repeat
> > diff --git a/gdb/gdbserver/i387-fp.c b/gdb/gdbserver/i387-fp.c
> > index e655f74..c2d0bdf 100644
> > --- a/gdb/gdbserver/i387-fp.c
> > +++ b/gdb/gdbserver/i387-fp.c
> > @@ -22,6 +22,11 @@
> >
> > static const int num_mpx_bnd_registers = 4;
> > static const int num_mpx_cfg_registers = 2;
> > +static const int num_avx512_k_registers = 8;
> > +static const int num_avx512_zmmh_low_registers = 16;
> > +static const int num_avx512_zmmh_high_registers = 16;
> > +static const int num_avx512_ymmh_registers = 16;
> > +static const int num_avx512_xmm_registers = 16;
> >
> > /* Note: These functions preserve the reserved bits in control registers.
> > However, gdbserver promptly throws away that information. */
> > @@ -120,6 +125,17 @@ struct i387_xsave {
> > /* Space for 2 MPX configuration registers of 64 bits
> > plus reserved space. */
> > unsigned char mpx_cfg_space[16];
> > +
> > + unsigned char reserved5[48];
> > +
> > + /* Space for 8 OpMask register values of 64 bits. */
> > + unsigned char k_space[64];
> > +
> > + /* Space for 16 256-bit zmm0-15. */
> > + unsigned char zmmh_low_space[512];
> > +
> > + /* Space for 16 512-bit zmm16-31 values. */
> > + unsigned char zmmh_high_space[1024];
> > };
> >
> > [...]
> > +
> > + /* Check if any of ZMM16H-ZMM31H registers are changed. */
> > + if ((x86_xcr0 & I386_XSTATE_ZMM))
> > + {
> > + int zmm16h_regnum = find_regno (regcache->tdesc, "zmm16h");
> > +
> > + for (i = 0; i < num_avx512_zmmh_high_registers; i++)
> > + {
> > + collect_register (regcache, i + zmm16h_regnum, raw);
> > + p = ((char *) &fp->zmmh_low_space[0]) + 32 + i * 64;
> ^^^^^^^^^^^^^^
> Should this really mean 'zmm_high_space'?
>
> > + if (memcmp (raw, p, 32) != 0)
>
> The warning occurs for this memcmp().
Based on the comments in "struct i387_xsave", I think you are right!
Michael and/or Pedro, can anyone confirm, please?
Thank you,
--
Joel