[PATCH] Add PTRACE_{GET|SET}VRREGS

Anton Blanchard anton at samba.org
Thu Sep 1 20:09:11 EST 2005


Hi Rob,

> The ptrace get and set methods for VMX/Altivec registers present in the 
> ppc tree were missing for ppc64.  This patch adds the 32-bit and 64-bit 
> methods.

Nice work. A couple of suggestions:

1. You need to call flush_altivec_to_thread(child) before reading or
writing the altivec state.

2. It looks like vrsave will be read/written incorrectly:

/*
 * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go.
 * The transfer totals 34 quadword.  Quadwords 0-31 contain the
 * corresponding vector registers.  Quadword 32 contains the vscr as the
 * last word (offset 12) within that quadword.  Quadword 33 contains the
 * vrsave as the first word (offset 0) within the quadword.
 *
 * This definition of the VMX state is compatible with the current PPC32
 * ptrace interface.  This allows signal handling and ptrace to use the
 * same
 * structures.  This also simplifies the implementation of a bi-arch
 * (combined (32- and 64-bit) gdb.
 */

vrsave is a 64bit field in the ppc64 task struct (its only 32bit on
ppc32). It might be safer to read all three parts separately, such as:

       unsigned long regsize;

       /* copy AltiVec registers VR[0] .. VR[31] */
       regsize = 32 * sizeof(vector128);
       if (copy_from_user(task->thread.vr, data, regsize))
               return -EFAULT;
       data += (regsize / sizeof(unsigned long));

       /* copy VSCR */
       regsize = 1 * sizeof(vector128);
       if (copy_from_user(&task->thread.vscr, data, regsize))
               return -EFAULT;
       data += (regsize / sizeof(unsigned long));

       /* copy VRSAVE */
       if (get_user(task->thread.vrsave, (u32 __user *)data))
               return -EFAULT;

In this case we only grab 32bits of vrsave.

Anton



More information about the Linuxppc64-dev mailing list