// SPDX-License-Identifier: GPL-2.0-or-later /* * OpenRISC ptrace.c * * Linux architectural port borrowing liberally from similar works of * others. All original copyrights apply as per the original source * declaration. * * Modifications for the OpenRISC architecture: * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> * Copyright (C) 2005 Gyorgy Jeney <nog@bsemi.com> * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
*/
/* * Copy the thread state to a regset that can be interpreted by userspace. * * It doesn't matter what our internal pt_regs structure looks like. The * important thing is that we export a consistent view of the thread state * to userspace. As such, we need to make sure that the regset remains * ABI compatible as defined by the struct user_regs_struct: * * (Each item is a 32-bit word) * r0 = 0 (exported for clarity) * 31 GPRS r1-r31 * PC (Program counter) * SR (Supervision register)
*/ staticint genregs_get(struct task_struct *target, conststruct user_regset *regset, struct membuf to)
{ conststruct pt_regs *regs = task_pt_regs(target);
/* * Set the thread state from a regset passed in via ptrace
*/ staticint genregs_set(struct task_struct *target, conststruct user_regset *regset, unsignedint pos, unsignedint count, constvoid *kbuf, constvoid __user * ubuf)
{ struct pt_regs *regs = task_pt_regs(target); int ret;
/* ignore r0 */
user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, 4); /* r1 - r31 */
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
regs->gpr+1, 4, 4*32); /* PC */ if (!ret)
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
®s->pc, 4*32, 4*33); /* * Skip SR and padding... userspace isn't allowed to changes bits in * the Supervision register
*/ if (!ret)
user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 4*33, -1);
return ret;
}
#ifdef CONFIG_FPU /* * As OpenRISC shares GPRs and floating point registers we don't need to export * the floating point registers again. So here we only export the fpcsr special * purpose register.
*/ staticint fpregs_get(struct task_struct *target, conststruct user_regset *regset, struct membuf to)
{ return membuf_store(&to, target->thread.fpcsr);
}
/** * regs_query_register_offset() - query register offset from its name * @name: the name of a register * * regs_query_register_offset() returns the offset of a register in struct * pt_regs from its name. If the name is invalid, this returns -EINVAL;
*/ int regs_query_register_offset(constchar *name)
{ conststruct pt_regs_offset *roff;
for (roff = regoffset_table; roff->name != NULL; roff++) if (!strcmp(roff->name, name)) return roff->offset; return -EINVAL;
}
/** * regs_within_kernel_stack() - check the address in the stack * @regs: pt_regs which contains kernel stack pointer. * @addr: address which is checked. * * regs_within_kernel_stack() checks @addr is within the kernel stack page(s). * If @addr is within the kernel stack, it returns true. If not, returns false.
*/ staticbool regs_within_kernel_stack(struct pt_regs *regs, unsignedlong addr)
{ return (addr & ~(THREAD_SIZE - 1)) ==
(kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1));
}
/** * regs_get_kernel_stack_nth() - get Nth entry of the stack * @regs: pt_regs which contains kernel stack pointer. * @n: stack entry number. * * regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which * is specified by @regs. If the @n th entry is NOT in the kernel stack, * this returns 0.
*/ unsignedlong regs_get_kernel_stack_nth(struct pt_regs *regs, unsignedint n)
{ unsignedlong *addr = (unsignedlong *)kernel_stack_pointer(regs);
/* * Called by kernel/ptrace.c when detaching.. * * Make sure the single step bit is not set.
*/ void ptrace_disable(struct task_struct *child)
{
pr_debug("ptrace_disable(): TODO\n");
/* * Notification of system call entry/exit * - triggered by current->work.syscall_trace
*/
asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
{ long ret = 0;
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
ptrace_report_syscall_entry(regs)) /* * Tracing decided this syscall should not happen. * We'll return a bogus call number to get an ENOSYS * error, but leave the original number in <something>.
*/
ret = -1L;
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.