提交 5de15d42 编写于 作者: T Thomas Gleixner 提交者: Ingo Molnar

x86: clean up arch/x86/ia32/ptrace32.c

White space and coding style clenaup.
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 2da06b4e
......@@ -5,8 +5,8 @@
* Some parts copied from arch/i386/kernel/ptrace.c. See that file for earlier
* copyright.
*
* This allows to access 64bit processes too; but there is no way to see the extended
* register contents.
* This allows to access 64bit processes too; but there is no way to
* see the extended register contents.
*/
#include <linux/kernel.h>
......@@ -36,7 +36,8 @@
#define FLAG_MASK 0x54dd5UL
#define R32(l,q) \
case offsetof(struct user32, regs.l): stack[offsetof(struct pt_regs, q)/8] = val; break
case offsetof(struct user32, regs.l): \
stack[offsetof(struct pt_regs, q) / 8] = val; break
static int putreg32(struct task_struct *child, unsigned regno, u32 val)
{
......@@ -45,26 +46,31 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
switch (regno) {
case offsetof(struct user32, regs.fs):
if (val && (val & 3) != 3) return -EIO;
if (val && (val & 3) != 3)
return -EIO;
child->thread.fsindex = val & 0xffff;
break;
case offsetof(struct user32, regs.gs):
if (val && (val & 3) != 3) return -EIO;
if (val && (val & 3) != 3)
return -EIO;
child->thread.gsindex = val & 0xffff;
break;
case offsetof(struct user32, regs.ds):
if (val && (val & 3) != 3) return -EIO;
if (val && (val & 3) != 3)
return -EIO;
child->thread.ds = val & 0xffff;
break;
case offsetof(struct user32, regs.es):
child->thread.es = val & 0xffff;
break;
case offsetof(struct user32, regs.ss):
if ((val & 3) != 3) return -EIO;
if ((val & 3) != 3)
return -EIO;
stack[offsetof(struct pt_regs, ss)/8] = val & 0xffff;
break;
case offsetof(struct user32, regs.cs):
if ((val & 3) != 3) return -EIO;
if ((val & 3) != 3)
return -EIO;
stack[offsetof(struct pt_regs, cs)/8] = val & 0xffff;
break;
......@@ -81,6 +87,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
case offsetof(struct user32, regs.eflags): {
__u64 *flags = &stack[offsetof(struct pt_regs, eflags)/8];
val &= FLAG_MASK;
*flags = val | (*flags & ~FLAG_MASK);
break;
......@@ -114,7 +121,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
val &= ~DR_CONTROL_RESERVED;
/* See arch/i386/kernel/ptrace.c for an explanation of
* this awkward check.*/
for(i=0; i<4; i++)
for (i = 0; i < 4; i++)
if ((0x5454 >> ((val >> (16 + 4*i)) & 0xf)) & 1)
return -EIO;
child->thread.debugreg7 = val;
......@@ -128,7 +135,10 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
if (regno > sizeof(struct user32) || (regno & 3))
return -EIO;
/* Other dummy fields in the virtual user structure are ignored */
/*
* Other dummy fields in the virtual user structure
* are ignored
*/
break;
}
return 0;
......@@ -137,7 +147,8 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
#undef R32
#define R32(l,q) \
case offsetof(struct user32, regs.l): *val = stack[offsetof(struct pt_regs, q)/8]; break
case offsetof(struct user32, regs.l): \
*val = stack[offsetof(struct pt_regs, q)/8]; break
static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
{
......@@ -194,7 +205,10 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
if (regno > sizeof(struct user32) || (regno & 3))
return -EIO;
/* Other dummy fields in the virtual user structure are ignored */
/*
* Other dummy fields in the virtual user structure
* are ignored
*/
*val = 0;
break;
}
......@@ -205,10 +219,11 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
static long ptrace32_siginfo(unsigned request, u32 pid, u32 addr, u32 data)
{
int ret;
siginfo_t __user *si = compat_alloc_user_space(sizeof(siginfo_t));
compat_siginfo_t __user *si32 = compat_ptr(data);
siginfo_t ssi;
siginfo_t __user *si = compat_alloc_user_space(sizeof(siginfo_t));
int ret;
if (request == PTRACE_SETSIGINFO) {
memset(&ssi, 0, sizeof(siginfo_t));
ret = copy_siginfo_from_user32(&ssi, si32);
......@@ -287,7 +302,8 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
case PTRACE_PEEKDATA:
case PTRACE_PEEKTEXT:
ret = 0;
if (access_process_vm(child, addr, &val, sizeof(u32), 0)!=sizeof(u32))
if (access_process_vm(child, addr, &val, sizeof(u32), 0) !=
sizeof(u32))
ret = -EIO;
else
ret = put_user(val, (unsigned int __user *)datap);
......@@ -296,7 +312,8 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
case PTRACE_POKEDATA:
case PTRACE_POKETEXT:
ret = 0;
if (access_process_vm(child, addr, &data, sizeof(u32), 1)!=sizeof(u32))
if (access_process_vm(child, addr, &data, sizeof(u32), 1) !=
sizeof(u32))
ret = -EIO;
break;
......@@ -312,14 +329,15 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
case PTRACE_GETREGS: { /* Get all gp regs from the child. */
int i;
if (!access_ok(VERIFY_WRITE, datap, 16*4)) {
ret = -EIO;
break;
}
ret = 0;
for ( i = 0; i <= 16*4 ; i += sizeof(__u32) ) {
for (i = 0; i <= 16*4; i += sizeof(__u32)) {
getreg32(child, i, &val);
ret |= __put_user(val,(u32 __user *)datap);
ret |= __put_user(val, (u32 __user *)datap);
datap += sizeof(u32);
}
break;
......@@ -328,12 +346,13 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
case PTRACE_SETREGS: { /* Set all gp regs in the child. */
unsigned long tmp;
int i;
if (!access_ok(VERIFY_READ, datap, 16*4)) {
ret = -EIO;
break;
}
ret = 0;
for ( i = 0; i <= 16*4; i += sizeof(u32) ) {
for (i = 0; i <= 16*4; i += sizeof(u32)) {
ret |= __get_user(tmp, (u32 __user *)datap);
putreg32(child, i, tmp);
datap += sizeof(u32);
......@@ -362,6 +381,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
case PTRACE_GETFPXREGS: {
struct user32_fxsr_struct __user *u = datap;
init_fpu(child);
ret = -EIO;
if (!access_ok(VERIFY_WRITE, u, sizeof(*u)))
......@@ -375,12 +395,15 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
}
case PTRACE_SETFPXREGS: {
struct user32_fxsr_struct __user *u = datap;
unlazy_fpu(child);
ret = -EIO;
if (!access_ok(VERIFY_READ, u, sizeof(*u)))
break;
/* no checking to be bug-to-bug compatible with i386. */
/* but silence warning */
/*
* no checking to be bug-to-bug compatible with i386.
* but silence warning
*/
if (__copy_from_user(&child->thread.i387.fxsave, u, sizeof(*u)))
;
set_stopped_child_used_math(child);
......@@ -390,7 +413,8 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
}
case PTRACE_GETEVENTMSG:
ret = put_user(child->ptrace_message,(unsigned int __user *)compat_ptr(data));
ret = put_user(child->ptrace_message,
(unsigned int __user *)compat_ptr(data));
break;
default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册