Commit bc826666 authored by Michael Neuling's avatar Michael Neuling Committed by Paul Mackerras

powerpc: Fix ptrace compat wrapper for FPU register access

The ptrace compat wrapper mishandles access to the fpu registers.  The
PTRACE_PEEKUSR and PTRACE_POKEUSR requests miscalculate the index into
the fpr array due to the broken FPINDEX macro.  The
PPC_PTRACE_PEEKUSR_3264 request needs to use the same formula that the
native ptrace interface uses when operating on the register number (as
opposed to the 4-byte offset).  The PPC_PTRACE_POKEUSR_3264 request
didn't take TS_FPRWIDTH into account.
Signed-off-by: default avatarAndreas Schwab <schwab@linux-m68k.org>
Signed-off-by: default avatarMichael Neuling <mikey@neuling.org>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent c7d07fdd
...@@ -67,7 +67,8 @@ static long compat_ptrace_old(struct task_struct *child, long request, ...@@ -67,7 +67,8 @@ static long compat_ptrace_old(struct task_struct *child, long request,
/* Macros to workout the correct index for the FPR in the thread struct */ /* Macros to workout the correct index for the FPR in the thread struct */
#define FPRNUMBER(i) (((i) - PT_FPR0) >> 1) #define FPRNUMBER(i) (((i) - PT_FPR0) >> 1)
#define FPRHALF(i) (((i) - PT_FPR0) & 1) #define FPRHALF(i) (((i) - PT_FPR0) & 1)
#define FPRINDEX(i) TS_FPRWIDTH * FPRNUMBER(i) + FPRHALF(i) #define FPRINDEX(i) TS_FPRWIDTH * FPRNUMBER(i) * 2 + FPRHALF(i)
#define FPRINDEX_3264(i) (TS_FPRWIDTH * ((i) - PT_FPR0))
long compat_arch_ptrace(struct task_struct *child, compat_long_t request, long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
compat_ulong_t caddr, compat_ulong_t cdata) compat_ulong_t caddr, compat_ulong_t cdata)
...@@ -168,8 +169,9 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, ...@@ -168,8 +169,9 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
CHECK_FULL_REGS(child->thread.regs); CHECK_FULL_REGS(child->thread.regs);
if (numReg >= PT_FPR0) { if (numReg >= PT_FPR0) {
flush_fp_to_thread(child); flush_fp_to_thread(child);
tmp = ((unsigned long int *)child->thread.fpr) /* get 64 bit FPR */
[FPRINDEX(numReg)]; tmp = ((u64 *)child->thread.fpr)
[FPRINDEX_3264(numReg)];
} else { /* register within PT_REGS struct */ } else { /* register within PT_REGS struct */
tmp = ptrace_get_reg(child, numReg); tmp = ptrace_get_reg(child, numReg);
} }
...@@ -262,8 +264,13 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, ...@@ -262,8 +264,13 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
freg = (freg & 0xfffffffful) | (data << 32); freg = (freg & 0xfffffffful) | (data << 32);
ret = ptrace_put_reg(child, numReg, freg); ret = ptrace_put_reg(child, numReg, freg);
} else { } else {
u64 *tmp;
flush_fp_to_thread(child); flush_fp_to_thread(child);
((unsigned int *)child->thread.regs)[index] = data; /* get 64 bit FPR ... */
tmp = &(((u64 *)child->thread.fpr)
[FPRINDEX_3264(numReg)]);
/* ... write the 32 bit part we want */
((u32 *)tmp)[index % 2] = data;
ret = 0; ret = 0;
} }
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment