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

From: Andreas Schwab <[email-masked]>
Date: Mon, 30 Mar 2009 13:11:51 +0200

Michael Neuling <[email-masked]> writes:

>> @@ -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, [email-masked]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."