aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2009-04-05 16:59:39 -0400
committerPaul Mackerras <paulus@samba.org>2009-04-07 01:19:00 -0400
commitbc826666e4252f78d2b144af3b7d699ff5efce0a (patch)
tree0055ba76c78f91d7039f8918f80c2979850f6415 /arch/powerpc/kernel
parentc7d07fdd5af084bbd0a7921f9b07037b9bc8829d (diff)
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: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/ptrace32.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/ptrace32.c b/arch/powerpc/kernel/ptrace32.c
index 197d49c790ad..297632cba047 100644
--- a/arch/powerpc/kernel/ptrace32.c
+++ b/arch/powerpc/kernel/ptrace32.c
@@ -67,7 +67,8 @@ static long compat_ptrace_old(struct task_struct *child, long request,
67/* Macros to workout the correct index for the FPR in the thread struct */ 67/* Macros to workout the correct index for the FPR in the thread struct */
68#define FPRNUMBER(i) (((i) - PT_FPR0) >> 1) 68#define FPRNUMBER(i) (((i) - PT_FPR0) >> 1)
69#define FPRHALF(i) (((i) - PT_FPR0) & 1) 69#define FPRHALF(i) (((i) - PT_FPR0) & 1)
70#define FPRINDEX(i) TS_FPRWIDTH * FPRNUMBER(i) + FPRHALF(i) 70#define FPRINDEX(i) TS_FPRWIDTH * FPRNUMBER(i) * 2 + FPRHALF(i)
71#define FPRINDEX_3264(i) (TS_FPRWIDTH * ((i) - PT_FPR0))
71 72
72long compat_arch_ptrace(struct task_struct *child, compat_long_t request, 73long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
73 compat_ulong_t caddr, compat_ulong_t cdata) 74 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 CHECK_FULL_REGS(child->thread.regs); 169 CHECK_FULL_REGS(child->thread.regs);
169 if (numReg >= PT_FPR0) { 170 if (numReg >= PT_FPR0) {
170 flush_fp_to_thread(child); 171 flush_fp_to_thread(child);
171 tmp = ((unsigned long int *)child->thread.fpr) 172 /* get 64 bit FPR */
172 [FPRINDEX(numReg)]; 173 tmp = ((u64 *)child->thread.fpr)
174 [FPRINDEX_3264(numReg)];
173 } else { /* register within PT_REGS struct */ 175 } else { /* register within PT_REGS struct */
174 tmp = ptrace_get_reg(child, numReg); 176 tmp = ptrace_get_reg(child, numReg);
175 } 177 }
@@ -262,8 +264,13 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
262 freg = (freg & 0xfffffffful) | (data << 32); 264 freg = (freg & 0xfffffffful) | (data << 32);
263 ret = ptrace_put_reg(child, numReg, freg); 265 ret = ptrace_put_reg(child, numReg, freg);
264 } else { 266 } else {
267 u64 *tmp;
265 flush_fp_to_thread(child); 268 flush_fp_to_thread(child);
266 ((unsigned int *)child->thread.regs)[index] = data; 269 /* get 64 bit FPR ... */
270 tmp = &(((u64 *)child->thread.fpr)
271 [FPRINDEX_3264(numReg)]);
272 /* ... write the 32 bit part we want */
273 ((u32 *)tmp)[index % 2] = data;
267 ret = 0; 274 ret = 0;
268 } 275 }
269 break; 276 break;