Thread (8 messages) 8 messages, 2 authors, 2009-04-06

Re: [PATCH] Fix ptrace compat wrapper for fpu register access

From: Andreas Schwab <hidden>
Date: 2009-03-30 11:11:56

Michael Neuling [off-list ref] writes:
quoted
@@ -263,7 +263,9 @@ long compat_arch_ptrace(struct task_stru
 			ret = ptrace_put_reg(child, numReg, freg);
 		} else {
 			flush_fp_to_thread(child);
-			((unsigned int *)child->thread.regs)[index] = data;
+			((unsigned int *)child->thread.fpr)
+				[TS_FPRWIDTH * (numReg - PT_FPR0) * 2 +
+				 index % 2] = data;
I think the indexing here should be the same as PEEKUSR_3264.  This
looks better but all this magic indexing makes me want to vomit.
How about this instead:
@@ -241,6 +241,7 @@ long compat_arch_ptrace(struct task_stru
 	case PPC_PTRACE_POKEUSR_3264: {
 		u32 index;
 		u32 numReg;
+		u32 *tmp;
 
 		ret = -EIO;
 		/* Determine which register the user wants */
@@ -263,7 +264,8 @@ long compat_arch_ptrace(struct task_stru
 			ret = ptrace_put_reg(child, numReg, freg);
 		} else {
 			flush_fp_to_thread(child);
-			((unsigned int *)child->thread.regs)[index] = data;
+			tmp = (u32 *)child->thread.fpr[numReg - PT_FPR0];
+			tmp[index % 2] = data;
 			ret = 0;
 		}
 		break;
Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help