/* Read the word at location addr in the USER area. For ptraced
processes, the kernel saves all regs on a syscall. */ case PTRACE_PEEKUSR: if ((addr & (sizeof(unsignedlong)-1)) ||
addr >= sizeof(struct pt_regs)) break;
tmp = *(unsignedlong *) ((char *) task_regs(child) + addr);
ret = put_user(tmp, datap); break;
/* Write the word at location addr in the USER area. This will need tochangewhenthekernelnolongersavesallregsonasyscall. FIXME.Thereisaproblematthemomentinthatr3-r18areonly savediftheprocessisptracedonsyscallentry,andeventhen thosevaluesareoverwrittenbyactualregistervaluesonsyscall
exit. */ case PTRACE_POKEUSR: /* Some register values written here may be ignored in *entry.S:syscall_restore_rfi;e.g.iaoqiswrittenwith *r31/r31+4,andnotwiththevaluesinpt_regs.
*/ if (addr == PT_PSW) { /* Allow writing to Nullify, Divide-step-correction, *andcarry/borrowbits. *BEWARE,ifyousetN,andthensinglestep,itwon't *stoponthenullifiedinstruction.
*/
data &= USER_PSW_BITS;
task_regs(child)->gr[0] &= ~USER_PSW_BITS;
task_regs(child)->gr[0] |= data;
ret = 0; break;
}
case PTRACE_GETREGS: /* Get all gp regs from the child. */ return copy_regset_to_user(child,
task_user_regset_view(current),
REGSET_GENERAL, 0, user_regs_struct_size,
datap);
case PTRACE_SETREGS: /* Set all gp regs in the child. */ return copy_regset_from_user(child,
task_user_regset_view(current),
REGSET_GENERAL, 0, user_regs_struct_size,
datap);
case PTRACE_GETFPREGS: /* Get the child FPU state. */ return copy_regset_to_user(child,
task_user_regset_view(current),
REGSET_FP, 0, sizeof(struct user_fp_struct),
datap);
case PTRACE_SETFPREGS: /* Set the child FPU state. */ return copy_regset_from_user(child,
task_user_regset_view(current),
REGSET_FP, 0, sizeof(struct user_fp_struct),
datap);
default:
ret = ptrace_request(child, request, addr, data); break;
}
return ret;
}
#ifdef CONFIG_COMPAT
/* This function is needed to translate 32 bit pt_regs offsets in to *64bitpt_regsoffsets.Forexample,a32bitgdbundera64bitkernel *willrequestoffset12ifitwantsgr3,butthelower32bitsof *the64bitkernelsviewofgr3willbeatoffset28(3*8+4). *Thiscodereliesona32bitpt_regsbeingcomprisedof32bitvalues *exceptforthefpregisterswhich(a)are64bits,and(b)follow *thegrregistersatthestartofpt_regs.The32bitpt_regsshould *behalfthesizeofthe64bitpt_regs,plus32*4toallowforfr[] *being64bitinbothcases.
*/
/* Write the word at location addr in the USER area. This will need tochangewhenthekernelnolongersavesallregsonasyscall. FIXME.Thereisaproblematthemomentinthatr3-r18areonly savediftheprocessisptracedonsyscallentry,andeventhen thosevaluesareoverwrittenbyactualregistervaluesonsyscall
exit. */ case PTRACE_POKEUSR: /* Some register values written here may be ignored in *entry.S:syscall_restore_rfi;e.g.iaoqiswrittenwith *r31/r31+4,andnotwiththevaluesinpt_regs.
*/ if (addr == PT_PSW) { /* Since PT_PSW==0, it is valid for 32 bit processes *under64bitkernelsaswell.
*/
ret = arch_ptrace(child, request, addr, data);
} else { if (addr & (sizeof(compat_uint_t)-1)) break;
addr = translate_usr_offset(addr); if (addr >= sizeof(struct pt_regs)) break; if (addr == PT_IAOQ0+4 || addr == PT_IAOQ1+4) {
data |= PRIV_USER; /* ensure userspace privilege */
} if (addr >= PT_FR0 && addr <= PT_FR31 + 4) { /* Special case, fp regs are 64 bits anyway */
*(__u32 *) ((char *) task_regs(child) + addr) = data;
ret = 0;
} elseif ((addr >= PT_GR1+4 && addr <= PT_GR31+4) ||
addr == PT_IAOQ0+4 || addr == PT_IAOQ1+4 ||
addr == PT_SAR+4) { /* Zero the top 32 bits */
*(__u32 *) ((char *) task_regs(child) + addr - 4) = 0;
*(__u32 *) ((char *) task_regs(child) + addr) = data;
ret = 0;
}
} break; case PTRACE_GETREGS: case PTRACE_SETREGS: case PTRACE_GETFPREGS: case PTRACE_SETFPREGS: return arch_ptrace(child, request, addr, data);
default:
ret = compat_ptrace_request(child, request, addr, data); break;
}
return ret;
} #endif
long do_syscall_trace_enter(struct pt_regs *regs)
{ if (test_thread_flag(TIF_SYSCALL_TRACE)) { int rc = ptrace_report_syscall_entry(regs);
staticunsignedlong get_reg(struct pt_regs *regs, int num)
{ switch (num) { case RI(gr[0]) ... RI(gr[31]): return regs->gr[num - RI(gr[0])]; case RI(sr[0]) ... RI(sr[7]): return regs->sr[num - RI(sr[0])]; case RI(iasq[0]): return regs->iasq[0]; case RI(iasq[1]): return regs->iasq[1]; case RI(iaoq[0]): return regs->iaoq[0]; case RI(iaoq[1]): return regs->iaoq[1]; case RI(sar): return regs->sar; case RI(iir): return regs->iir; case RI(isr): return regs->isr; case RI(ior): return regs->ior; case RI(ipsw): return regs->ipsw; case RI(cr27): return regs->cr27; case RI(cr0): return mfctl(0); case RI(cr24): return mfctl(24); case RI(cr25): return mfctl(25); case RI(cr26): return mfctl(26); case RI(cr28): return mfctl(28); case RI(cr29): return mfctl(29); case RI(cr30): return mfctl(30); case RI(cr31): return mfctl(31); case RI(cr8): return mfctl(8); case RI(cr9): return mfctl(9); case RI(cr12): return mfctl(12); case RI(cr13): return mfctl(13); case RI(cr10): return mfctl(10); case RI(cr15): return mfctl(15); default: return0;
}
}
staticvoid set_reg(struct pt_regs *regs, int num, unsignedlong val)
{ switch (num) { case RI(gr[0]): /* *PSWisingr[0]. *AllowwritingtoNullify,Divide-step-correction, *andcarry/borrowbits. *BEWARE,ifyousetN,andthensinglestep,itwon't *stoponthenullifiedinstruction.
*/
val &= USER_PSW_BITS;
regs->gr[0] &= ~USER_PSW_BITS;
regs->gr[0] |= val; return; case RI(gr[1]) ... RI(gr[31]):
regs->gr[num - RI(gr[0])] = val; return; case RI(iaoq[0]): case RI(iaoq[1]): /* set 2 lowest bits to ensure userspace privilege: */
regs->iaoq[num - RI(iaoq[0])] = val | PRIV_USER; return; case RI(sar): regs->sar = val; return; default: return; #if0 /* do not allow to change any of the following registers (yet) */ case RI(sr[0]) ... RI(sr[7]): return regs->sr[num - RI(sr[0])]; case RI(iasq[0]): return regs->iasq[0]; case RI(iasq[1]): return regs->iasq[1]; case RI(iir): return regs->iir; case RI(isr): return regs->isr; case RI(ior): return regs->ior; case RI(ipsw): return regs->ipsw; case RI(cr27): return regs->cr27; case cr0, cr24, cr25, cr26, cr27, cr28, cr29, cr30, cr31; case cr8, cr9, cr12, cr13, cr10, cr15; #endif
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.