xtensa: clean up xtensa/kernel/ptrace.c
- make locally-used functions static; - drop meaningless comments and commented out code; - fix code style and alignment. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
This commit is contained in:
Родитель
d9c7710db9
Коммит
1b47a683a0
|
@ -1,4 +1,3 @@
|
||||||
// TODO some minor issues
|
|
||||||
/*
|
/*
|
||||||
* This file is subject to the terms and conditions of the GNU General Public
|
* This file is subject to the terms and conditions of the GNU General Public
|
||||||
* License. See the file "COPYING" in the main directory of this archive
|
* License. See the file "COPYING" in the main directory of this archive
|
||||||
|
@ -24,13 +23,13 @@
|
||||||
#include <linux/security.h>
|
#include <linux/security.h>
|
||||||
#include <linux/signal.h>
|
#include <linux/signal.h>
|
||||||
#include <linux/smp.h>
|
#include <linux/smp.h>
|
||||||
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
#include <asm/coprocessor.h>
|
#include <asm/coprocessor.h>
|
||||||
#include <asm/elf.h>
|
#include <asm/elf.h>
|
||||||
#include <asm/page.h>
|
#include <asm/page.h>
|
||||||
#include <asm/pgtable.h>
|
#include <asm/pgtable.h>
|
||||||
#include <asm/ptrace.h>
|
#include <asm/ptrace.h>
|
||||||
#include <linux/uaccess.h>
|
|
||||||
|
|
||||||
|
|
||||||
void user_enable_single_step(struct task_struct *child)
|
void user_enable_single_step(struct task_struct *child)
|
||||||
|
@ -52,7 +51,7 @@ void ptrace_disable(struct task_struct *child)
|
||||||
/* Nothing to do.. */
|
/* Nothing to do.. */
|
||||||
}
|
}
|
||||||
|
|
||||||
int ptrace_getregs(struct task_struct *child, void __user *uregs)
|
static int ptrace_getregs(struct task_struct *child, void __user *uregs)
|
||||||
{
|
{
|
||||||
struct pt_regs *regs = task_pt_regs(child);
|
struct pt_regs *regs = task_pt_regs(child);
|
||||||
xtensa_gregset_t __user *gregset = uregs;
|
xtensa_gregset_t __user *gregset = uregs;
|
||||||
|
@ -73,12 +72,12 @@ int ptrace_getregs(struct task_struct *child, void __user *uregs)
|
||||||
|
|
||||||
for (i = 0; i < XCHAL_NUM_AREGS; i++)
|
for (i = 0; i < XCHAL_NUM_AREGS; i++)
|
||||||
__put_user(regs->areg[i],
|
__put_user(regs->areg[i],
|
||||||
gregset->a + ((wb * 4 + i) % XCHAL_NUM_AREGS));
|
gregset->a + ((wb * 4 + i) % XCHAL_NUM_AREGS));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ptrace_setregs(struct task_struct *child, void __user *uregs)
|
static int ptrace_setregs(struct task_struct *child, void __user *uregs)
|
||||||
{
|
{
|
||||||
struct pt_regs *regs = task_pt_regs(child);
|
struct pt_regs *regs = task_pt_regs(child);
|
||||||
xtensa_gregset_t *gregset = uregs;
|
xtensa_gregset_t *gregset = uregs;
|
||||||
|
@ -107,7 +106,7 @@ int ptrace_setregs(struct task_struct *child, void __user *uregs)
|
||||||
unsigned long rotws, wmask;
|
unsigned long rotws, wmask;
|
||||||
|
|
||||||
rotws = (((ws | (ws << WSBITS)) >> wb) &
|
rotws = (((ws | (ws << WSBITS)) >> wb) &
|
||||||
((1 << WSBITS) - 1)) & ~1;
|
((1 << WSBITS) - 1)) & ~1;
|
||||||
wmask = ((rotws ? WSBITS + 1 - ffs(rotws) : 0) << 4) |
|
wmask = ((rotws ? WSBITS + 1 - ffs(rotws) : 0) << 4) |
|
||||||
(rotws & 0xF) | 1;
|
(rotws & 0xF) | 1;
|
||||||
regs->windowbase = wb;
|
regs->windowbase = wb;
|
||||||
|
@ -115,19 +114,19 @@ int ptrace_setregs(struct task_struct *child, void __user *uregs)
|
||||||
regs->wmask = wmask;
|
regs->wmask = wmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wb != 0 && __copy_from_user(regs->areg + XCHAL_NUM_AREGS - wb * 4,
|
if (wb != 0 && __copy_from_user(regs->areg + XCHAL_NUM_AREGS - wb * 4,
|
||||||
gregset->a, wb * 16))
|
gregset->a, wb * 16))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if (__copy_from_user(regs->areg, gregset->a + wb * 4,
|
if (__copy_from_user(regs->areg, gregset->a + wb * 4,
|
||||||
(WSBITS - wb) * 16))
|
(WSBITS - wb) * 16))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ptrace_getxregs(struct task_struct *child, void __user *uregs)
|
static int ptrace_getxregs(struct task_struct *child, void __user *uregs)
|
||||||
{
|
{
|
||||||
struct pt_regs *regs = task_pt_regs(child);
|
struct pt_regs *regs = task_pt_regs(child);
|
||||||
struct thread_info *ti = task_thread_info(child);
|
struct thread_info *ti = task_thread_info(child);
|
||||||
|
@ -151,7 +150,7 @@ int ptrace_getxregs(struct task_struct *child, void __user *uregs)
|
||||||
return ret ? -EFAULT : 0;
|
return ret ? -EFAULT : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ptrace_setxregs(struct task_struct *child, void __user *uregs)
|
static int ptrace_setxregs(struct task_struct *child, void __user *uregs)
|
||||||
{
|
{
|
||||||
struct thread_info *ti = task_thread_info(child);
|
struct thread_info *ti = task_thread_info(child);
|
||||||
struct pt_regs *regs = task_pt_regs(child);
|
struct pt_regs *regs = task_pt_regs(child);
|
||||||
|
@ -177,7 +176,8 @@ int ptrace_setxregs(struct task_struct *child, void __user *uregs)
|
||||||
return ret ? -EFAULT : 0;
|
return ret ? -EFAULT : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ptrace_peekusr(struct task_struct *child, long regno, long __user *ret)
|
static int ptrace_peekusr(struct task_struct *child, long regno,
|
||||||
|
long __user *ret)
|
||||||
{
|
{
|
||||||
struct pt_regs *regs;
|
struct pt_regs *regs;
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
|
@ -186,86 +186,87 @@ int ptrace_peekusr(struct task_struct *child, long regno, long __user *ret)
|
||||||
tmp = 0; /* Default return value. */
|
tmp = 0; /* Default return value. */
|
||||||
|
|
||||||
switch(regno) {
|
switch(regno) {
|
||||||
|
case REG_AR_BASE ... REG_AR_BASE + XCHAL_NUM_AREGS - 1:
|
||||||
|
tmp = regs->areg[regno - REG_AR_BASE];
|
||||||
|
break;
|
||||||
|
|
||||||
case REG_AR_BASE ... REG_AR_BASE + XCHAL_NUM_AREGS - 1:
|
case REG_A_BASE ... REG_A_BASE + 15:
|
||||||
tmp = regs->areg[regno - REG_AR_BASE];
|
tmp = regs->areg[regno - REG_A_BASE];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REG_A_BASE ... REG_A_BASE + 15:
|
case REG_PC:
|
||||||
tmp = regs->areg[regno - REG_A_BASE];
|
tmp = regs->pc;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REG_PC:
|
case REG_PS:
|
||||||
tmp = regs->pc;
|
/* Note: PS.EXCM is not set while user task is running;
|
||||||
break;
|
* its being set in regs is for exception handling
|
||||||
|
* convenience.
|
||||||
|
*/
|
||||||
|
tmp = (regs->ps & ~(1 << PS_EXCM_BIT));
|
||||||
|
break;
|
||||||
|
|
||||||
case REG_PS:
|
case REG_WB:
|
||||||
/* Note: PS.EXCM is not set while user task is running;
|
break; /* tmp = 0 */
|
||||||
* its being set in regs is for exception handling
|
|
||||||
* convenience. */
|
|
||||||
tmp = (regs->ps & ~(1 << PS_EXCM_BIT));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case REG_WB:
|
case REG_WS:
|
||||||
break; /* tmp = 0 */
|
|
||||||
|
|
||||||
case REG_WS:
|
|
||||||
{
|
{
|
||||||
unsigned long wb = regs->windowbase;
|
unsigned long wb = regs->windowbase;
|
||||||
unsigned long ws = regs->windowstart;
|
unsigned long ws = regs->windowstart;
|
||||||
tmp = ((ws>>wb) | (ws<<(WSBITS-wb))) & ((1<<WSBITS)-1);
|
tmp = ((ws >> wb) | (ws << (WSBITS - wb))) &
|
||||||
|
((1 << WSBITS) - 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case REG_LBEG:
|
case REG_LBEG:
|
||||||
tmp = regs->lbeg;
|
tmp = regs->lbeg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REG_LEND:
|
case REG_LEND:
|
||||||
tmp = regs->lend;
|
tmp = regs->lend;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REG_LCOUNT:
|
case REG_LCOUNT:
|
||||||
tmp = regs->lcount;
|
tmp = regs->lcount;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REG_SAR:
|
case REG_SAR:
|
||||||
tmp = regs->sar;
|
tmp = regs->sar;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSCALL_NR:
|
case SYSCALL_NR:
|
||||||
tmp = regs->syscall;
|
tmp = regs->syscall;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
return put_user(tmp, ret);
|
return put_user(tmp, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ptrace_pokeusr(struct task_struct *child, long regno, long val)
|
static int ptrace_pokeusr(struct task_struct *child, long regno, long val)
|
||||||
{
|
{
|
||||||
struct pt_regs *regs;
|
struct pt_regs *regs;
|
||||||
regs = task_pt_regs(child);
|
regs = task_pt_regs(child);
|
||||||
|
|
||||||
switch (regno) {
|
switch (regno) {
|
||||||
case REG_AR_BASE ... REG_AR_BASE + XCHAL_NUM_AREGS - 1:
|
case REG_AR_BASE ... REG_AR_BASE + XCHAL_NUM_AREGS - 1:
|
||||||
regs->areg[regno - REG_AR_BASE] = val;
|
regs->areg[regno - REG_AR_BASE] = val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REG_A_BASE ... REG_A_BASE + 15:
|
case REG_A_BASE ... REG_A_BASE + 15:
|
||||||
regs->areg[regno - REG_A_BASE] = val;
|
regs->areg[regno - REG_A_BASE] = val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REG_PC:
|
case REG_PC:
|
||||||
regs->pc = val;
|
regs->pc = val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYSCALL_NR:
|
case SYSCALL_NR:
|
||||||
regs->syscall = val;
|
regs->syscall = val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -473,7 +474,8 @@ void do_syscall_trace(void)
|
||||||
* The 0x80 provides a way for the tracing parent to distinguish
|
* The 0x80 provides a way for the tracing parent to distinguish
|
||||||
* between a syscall stop and SIGTRAP delivery
|
* between a syscall stop and SIGTRAP delivery
|
||||||
*/
|
*/
|
||||||
ptrace_notify(SIGTRAP|((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
|
ptrace_notify(SIGTRAP |
|
||||||
|
((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this isn't the same as continuing with a signal, but it will do
|
* this isn't the same as continuing with a signal, but it will do
|
||||||
|
@ -488,18 +490,14 @@ void do_syscall_trace(void)
|
||||||
|
|
||||||
void do_syscall_trace_enter(struct pt_regs *regs)
|
void do_syscall_trace_enter(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
if (test_thread_flag(TIF_SYSCALL_TRACE)
|
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
|
||||||
&& (current->ptrace & PT_PTRACED))
|
(current->ptrace & PT_PTRACED))
|
||||||
do_syscall_trace();
|
do_syscall_trace();
|
||||||
|
|
||||||
#if 0
|
|
||||||
audit_syscall_entry(...);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_syscall_trace_leave(struct pt_regs *regs)
|
void do_syscall_trace_leave(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
if ((test_thread_flag(TIF_SYSCALL_TRACE))
|
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
|
||||||
&& (current->ptrace & PT_PTRACED))
|
(current->ptrace & PT_PTRACED))
|
||||||
do_syscall_trace();
|
do_syscall_trace();
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче