aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/ia32
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-01-30 07:30:57 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:30:57 -0500
commitff14c6164bd532a6dc9025c07d3b562f839f00a9 (patch)
tree41c752b7cd0e8c9cfa9013887409dd3fbf140617 /arch/x86/ia32
parent35d0991ffa544945d2e1992169c097286b7c0bfb (diff)
x86: x86-64 ia32 ptrace pt_regs cleanup
This cleans up the getreg32/putreg32 functions to use struct pt_regs in a straightforward fashion, instead of equivalent ugly pointer arithmetic. Signed-off-by: Roland McGrath <roland@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/ia32')
-rw-r--r--arch/x86/ia32/ptrace32.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/arch/x86/ia32/ptrace32.c b/arch/x86/ia32/ptrace32.c
index 1e382e3bd882..c52d0664c67f 100644
--- a/arch/x86/ia32/ptrace32.c
+++ b/arch/x86/ia32/ptrace32.c
@@ -37,11 +37,11 @@
37 37
38#define R32(l,q) \ 38#define R32(l,q) \
39 case offsetof(struct user32, regs.l): \ 39 case offsetof(struct user32, regs.l): \
40 stack[offsetof(struct pt_regs, q) / 8] = val; break 40 regs->q = val; break;
41 41
42static int putreg32(struct task_struct *child, unsigned regno, u32 val) 42static int putreg32(struct task_struct *child, unsigned regno, u32 val)
43{ 43{
44 __u64 *stack = (__u64 *)task_pt_regs(child); 44 struct pt_regs *regs = task_pt_regs(child);
45 45
46 switch (regno) { 46 switch (regno) {
47 case offsetof(struct user32, regs.fs): 47 case offsetof(struct user32, regs.fs):
@@ -65,12 +65,12 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
65 case offsetof(struct user32, regs.ss): 65 case offsetof(struct user32, regs.ss):
66 if ((val & 3) != 3) 66 if ((val & 3) != 3)
67 return -EIO; 67 return -EIO;
68 stack[offsetof(struct pt_regs, ss)/8] = val & 0xffff; 68 regs->ss = val & 0xffff;
69 break; 69 break;
70 case offsetof(struct user32, regs.cs): 70 case offsetof(struct user32, regs.cs):
71 if ((val & 3) != 3) 71 if ((val & 3) != 3)
72 return -EIO; 72 return -EIO;
73 stack[offsetof(struct pt_regs, cs)/8] = val & 0xffff; 73 regs->cs = val & 0xffff;
74 break; 74 break;
75 75
76 R32(ebx, bx); 76 R32(ebx, bx);
@@ -84,9 +84,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
84 R32(eip, ip); 84 R32(eip, ip);
85 R32(esp, sp); 85 R32(esp, sp);
86 86
87 case offsetof(struct user32, regs.eflags): { 87 case offsetof(struct user32, regs.eflags):
88 __u64 *flags = &stack[offsetof(struct pt_regs, flags)/8];
89
90 val &= FLAG_MASK; 88 val &= FLAG_MASK;
91 /* 89 /*
92 * If the user value contains TF, mark that 90 * If the user value contains TF, mark that
@@ -97,9 +95,8 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
97 clear_tsk_thread_flag(child, TIF_FORCED_TF); 95 clear_tsk_thread_flag(child, TIF_FORCED_TF);
98 else if (test_tsk_thread_flag(child, TIF_FORCED_TF)) 96 else if (test_tsk_thread_flag(child, TIF_FORCED_TF))
99 val |= X86_EFLAGS_TF; 97 val |= X86_EFLAGS_TF;
100 *flags = val | (*flags & ~FLAG_MASK); 98 regs->flags = val | (regs->flags & ~FLAG_MASK);
101 break; 99 break;
102 }
103 100
104 case offsetof(struct user32, u_debugreg[0]) ... 101 case offsetof(struct user32, u_debugreg[0]) ...
105 offsetof(struct user32, u_debugreg[7]): 102 offsetof(struct user32, u_debugreg[7]):
@@ -123,11 +120,11 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
123 120
124#define R32(l,q) \ 121#define R32(l,q) \
125 case offsetof(struct user32, regs.l): \ 122 case offsetof(struct user32, regs.l): \
126 *val = stack[offsetof(struct pt_regs, q)/8]; break 123 *val = regs->q; break
127 124
128static int getreg32(struct task_struct *child, unsigned regno, u32 *val) 125static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
129{ 126{
130 __u64 *stack = (__u64 *)task_pt_regs(child); 127 struct pt_regs *regs = task_pt_regs(child);
131 128
132 switch (regno) { 129 switch (regno) {
133 case offsetof(struct user32, regs.fs): 130 case offsetof(struct user32, regs.fs):
@@ -160,7 +157,7 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
160 /* 157 /*
161 * If the debugger set TF, hide it from the readout. 158 * If the debugger set TF, hide it from the readout.
162 */ 159 */
163 *val = stack[offsetof(struct pt_regs, flags)/8]; 160 *val = regs->flags;
164 if (test_tsk_thread_flag(child, TIF_FORCED_TF)) 161 if (test_tsk_thread_flag(child, TIF_FORCED_TF))
165 *val &= ~X86_EFLAGS_TF; 162 *val &= ~X86_EFLAGS_TF;
166 break; 163 break;