This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH V5 2/3] Add AVX512 register support to gdbserver.


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]