<br><font size=2><tt>Kumar Gala <galak@kernel.crashing.org> wrote
on 05/29/2007 03:19:42 PM:<br>
> On May 29, 2007, at 4:02 AM, Benjamin Herrenschmidt wrote:<br>
> > Hrm.. we do have a subtle difference in vrregs that I've missed..
I'll<br>
> > respin tomorrow. It looks like we don't store the VRSAVE register
<br>
> > at the<br>
> > same place on 32 and 64 bits... yuck. I need to double check
tomorrow.<br>
> <br>
> That's bad. We really should have VRSAVE in the same location
for <br>
> both. (wondering if GDB expects it a different locations on
32 vs 64- <br>
> bits.)</tt></font>
<br>
<br><font size=2><tt>It looks like GDB will expect VRSAVE at offset 33*16
(length 4 bytes)</tt></font>
<br><font size=2><tt>in the area returned by PTRACE_GETVRREGS, for both
32-bit and 64-bit</tt></font>
<br><font size=2><tt>applications:</tt></font>
<br>
<br><font size=2><tt>/* This oddity is because the Linux kernel defines
elf_vrregset_t as</tt></font>
<br><font size=2><tt> an array of 33 16 bytes long elements.
I.e. it leaves out vrsave.</tt></font>
<br><font size=2><tt> However the PTRACE_GETVRREGS and PTRACE_SETVRREGS
requests return</tt></font>
<br><font size=2><tt> the vrsave as an extra 4 bytes at the
end. I opted for creating a</tt></font>
<br><font size=2><tt> flat array of chars, so that it is easier
to manipulate for gdb.</tt></font>
<br>
<br><font size=2><tt> There are 32 vector registers 16 bytes
longs, plus a VSCR register</tt></font>
<br><font size=2><tt> which is only 4 bytes long, but is fetched
as a 16 bytes</tt></font>
<br><font size=2><tt> quantity. Up to here we have the elf_vrregset_t
structure.</tt></font>
<br><font size=2><tt> Appended to this there is space for the
VRSAVE register: 4 bytes.</tt></font>
<br><font size=2><tt> Even though this vrsave register is not
included in the regset</tt></font>
<br><font size=2><tt> typedef, it is handled by the ptrace
requests.</tt></font>
<br>
<br><font size=2><tt> Note that GNU/Linux doesn't support little
endian PPC hardware,</tt></font>
<br><font size=2><tt> therefore the offset at which the real
value of the VSCR register</tt></font>
<br><font size=2><tt> is located will be always 12 bytes.</tt></font>
<br>
<br><font size=2><tt> The layout is like this (where x is the
actual value of the vscr reg): */</tt></font>
<br>
<br><font size=2><tt>/* *INDENT-OFF* */</tt></font>
<br><font size=2><tt>/*</tt></font>
<br><font size=2><tt> |.|.|.|.|.....|.|.|.|.||.|.|.|x||.|</tt></font>
<br><font size=2><tt> <-------> <-------><-------><-></tt></font>
<br><font size=2><tt> VR0
VR31 VSCR VRSAVE</tt></font>
<br><font size=2><tt>*/</tt></font>
<br><font size=2><tt>/* *INDENT-ON* */</tt></font>
<br>
<br><font size=2><tt>#define SIZEOF_VRREGS 33*16+4</tt></font>
<br>
<br><font size=2><tt>typedef char gdb_vrregset_t[SIZEOF_VRREGS];</tt></font>
<br>
<br><font size=2 face="sans-serif"><br>
Mit freundlichen Gruessen / Best Regards<br>
<br>
Ulrich Weigand<br>
<br>
-- <br>
Dr. Ulrich Weigand | Phone: +49-7031/16-3727<br>
GNU compiler/toolchain for Linux on System z and Cell BE<br>
IBM Deutschland Entwicklung GmbH<br>
Vorsitzender des Aufsichtsrats: Martin Jetter | Geschäftsführung:
Herbert Kircher<br>
Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht
Stuttgart, HRB 243294</font>
<br>