[PATCH 2/2] powerpc: Provide a fallback for old kernels without PTRACE_GETREGS
Denys Vlasenko
dvlasenk at redhat.com
Wed Jun 26 14:04:28 UTC 2013
On 06/26/2013 06:42 AM, Anton Blanchard wrote:
> Hi Denys,
>
>> Just to be sure that we only fall back if PTRACE_GETREGS op is
>> unknown, not in other cases (such as tracee killed under us) lets do
>> this:
>>
>> if (get_regs_error && errno == ????)
>>
>> Which errno is generated in this case?
>
> Makes sense. We get -EIO back if PTRACE_GETREGS is not available.
> Tested on SLES10 (2.6.16).
Applied both patches, thanks.
Can you take a look at the silly dance we do with ppc_result variable?
get_syscall_result():
ppc_result = ppc_regs.gpr[3];
if (ppc_regs.ccr & SO_MASK)
ppc_result = -ppc_result;
later, get_error():
if (check_errno && is_negated_errno(ppc_result)) {
tcp->u_rval = -1;
u_error = -ppc_result;
}
else {
tcp->u_rval = ppc_result;
}
>From this, looks like PPC does NOT use "if it's negative
and below max errno" logic - it has a dedicated error bit,
SO_MASK. But our code shoehorn it into that logic.
Shouldn't get_syscall_result() code bit just nixed,
and get_error() changed to this? -
if (ppc_regs.ccr & SO_MASK) {
tcp->u_rval = -1;
u_error = ppc_regs.gpr[3];
}
else {
tcp->u_rval = ppc_regs.gpr[3];
}
Next.
get_regs():
get_regs_error = ptrace(PTRACE_GETREGS, pid, NULL, (long) &ppc_regs);
if (get_regs_error && errno == EIO)
get_regs_error = powerpc_getregs_old(pid);
The fallback will be taken _every time_ on old kernels.
Meaning, we will try PTRACE_GETREGS pointlessly twice per syscall.
We should remember the first failure instead.
Care to fix and test these problems?
More information about the Strace-devel
mailing list