/* ptrace.c: Sparc process tracing support.
*
* Copyright (C) 1996, 2008 David S. Miller (davem@davemloft.net)
* Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
*
* Based upon code written by Ross Biro, Linus Torvalds, Bob Manson,
* and David Mosberger.
*
* Added Linux support -miguel (weird, eh?, the original code was meant
* to emulate SunOS).
*/
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <linux/ptrace.h>
#include <linux/user.h>
#include <linux/smp.h>
#include <linux/smp_lock.h>
#include <linux/security.h>
#include <linux/seccomp.h>
#include <linux/audit.h>
#include <linux/signal.h>
#include <linux/regset.h>
#include <linux/compat.h>
#include <linux/elf.h>
#include <asm/asi.h>
#include <asm/pgtable.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <asm/psrcompat.h>
#include <asm/visasm.h>
#include <asm/spitfire.h>
#include <asm/page.h>
#include <asm/cpudata.h>
/* Returning from ptrace is a bit tricky because the syscall return
* low level code assumes any value returned which is negative and
* is a valid errno will mean setting the condition codes to indicate
* an error return. This doesn't work, so we have this hook.
*/
static inline void pt_error_return(struct pt_regs *regs, unsigned long error)
{
regs->u_regs[UREG_I0] = error;
regs->tstate |= (TSTATE_ICARRY | TSTATE_XCARRY);
regs->tpc = regs->tnpc;
regs->tnpc += 4;
}
static inline void pt_succ_return(struct pt_regs *regs, unsigned long value)
{
regs->u_regs[UREG_I0] = value;
regs->tstate &= ~(TSTATE_ICARRY | TSTATE_XCARRY);
regs->tpc = regs->tnpc;
regs->tnpc += 4;
}
static inline void
pt_succ_return_linux(struct pt_regs *regs, unsigned long value, void __user *addr)
{
if (test_thread_flag(TIF_32BIT)) {
if (put_user(value, (unsigned int __user *) addr)) {
pt_error_return(regs, EFAULT);
return;
}
} else {
if (put_user(value, (long __user *) addr)) {
pt_error_return(regs, EFAULT);
return;
}
}
regs->u_regs[UREG_I0] = 0;
regs->tstate &= ~(TSTATE_ICARRY | TSTATE_XCARRY);
regs->tpc = regs->tnpc;
regs->tnpc += 4;
}
static void
pt_os_succ_return (struct pt_regs *regs, unsigned long val, void __user *addr)
{
if (current->personality == PER_SUNOS)
pt_succ_return (regs, val);
else
pt_succ_return_linux (regs, val, addr);
}
/* #define ALLOW_INIT_TRACING */
/*
* Called by kernel/ptrace.c when detaching..
*
* Make sure single step bits etc are not set.
*/
void ptrace_disable(struct task_struct *child)
{
/* nothing to do */
}
/* To get the necessary page struct, access_process_vm() first calls
* get_user_pages(). This has done a flush_dcache_page() on the
* accessed page. Then our caller (copy_{to,from}_user_page()) did
* to memcpy to read/write the data from that page.
*
* Now, the only thing we have to do is:
* 1) flush the D-cache if it's possible than an illegal alias
* has been created
* 2) flush the I-cache if this is pre-cheetah and we di