aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/ia32/ptrace32.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-01-30 07:30:52 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:30:52 -0500
commitd0f081758260e9221729cabbc3aba63d89b8c8d4 (patch)
tree2dad42c69f33a875f984cf7397e6a9385c5f6c46 /arch/x86/ia32/ptrace32.c
parent962ff3804d31a4d090bbcbd3d06a4b63e3a5b5fd (diff)
x86: x86-64 ia32 ptrace debugreg cleanup
This cleans up the ia32 compat ptrace code to use shared code from native ptrace for the implementation guts of debug register access. 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/ptrace32.c')
-rw-r--r--arch/x86/ia32/ptrace32.c63
1 files changed, 8 insertions, 55 deletions
diff --git a/arch/x86/ia32/ptrace32.c b/arch/x86/ia32/ptrace32.c
index 5dee33417313..5ababea1307a 100644
--- a/arch/x86/ia32/ptrace32.c
+++ b/arch/x86/ia32/ptrace32.c
@@ -41,7 +41,6 @@
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 int i;
45 __u64 *stack = (__u64 *)task_pt_regs(child); 44 __u64 *stack = (__u64 *)task_pt_regs(child);
46 45
47 switch (regno) { 46 switch (regno) {
@@ -102,43 +101,10 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
102 break; 101 break;
103 } 102 }
104 103
105 case offsetof(struct user32, u_debugreg[4]): 104 case offsetof(struct user32, u_debugreg[0]) ...
106 case offsetof(struct user32, u_debugreg[5]): 105 offsetof(struct user32, u_debugreg[7]):
107 return -EIO; 106 regno -= offsetof(struct user32, u_debugreg[0]);
108 107 return ptrace_set_debugreg(child, regno / 4, val);
109 case offsetof(struct user32, u_debugreg[0]):
110 child->thread.debugreg0 = val;
111 break;
112
113 case offsetof(struct user32, u_debugreg[1]):
114 child->thread.debugreg1 = val;
115 break;
116
117 case offsetof(struct user32, u_debugreg[2]):
118 child->thread.debugreg2 = val;
119 break;
120
121 case offsetof(struct user32, u_debugreg[3]):
122 child->thread.debugreg3 = val;
123 break;
124
125 case offsetof(struct user32, u_debugreg[6]):
126 child->thread.debugreg6 = val;
127 break;
128
129 case offsetof(struct user32, u_debugreg[7]):
130 val &= ~DR_CONTROL_RESERVED;
131 /* See arch/i386/kernel/ptrace.c for an explanation of
132 * this awkward check.*/
133 for (i = 0; i < 4; i++)
134 if ((0x5454 >> ((val >> (16 + 4*i)) & 0xf)) & 1)
135 return -EIO;
136 child->thread.debugreg7 = val;
137 if (val)
138 set_tsk_thread_flag(child, TIF_DEBUG);
139 else
140 clear_tsk_thread_flag(child, TIF_DEBUG);
141 break;
142 108
143 default: 109 default:
144 if (regno > sizeof(struct user32) || (regno & 3)) 110 if (regno > sizeof(struct user32) || (regno & 3))
@@ -199,23 +165,10 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
199 *val &= ~X86_EFLAGS_TF; 165 *val &= ~X86_EFLAGS_TF;
200 break; 166 break;
201 167
202 case offsetof(struct user32, u_debugreg[0]): 168 case offsetof(struct user32, u_debugreg[0]) ...
203 *val = child->thread.debugreg0; 169 offsetof(struct user32, u_debugreg[7]):
204 break; 170 regno -= offsetof(struct user32, u_debugreg[0]);
205 case offsetof(struct user32, u_debugreg[1]): 171 *val = ptrace_get_debugreg(child, regno / 4);
206 *val = child->thread.debugreg1;
207 break;
208 case offsetof(struct user32, u_debugreg[2]):
209 *val = child->thread.debugreg2;
210 break;
211 case offsetof(struct user32, u_debugreg[3]):
212 *val = child->thread.debugreg3;
213 break;
214 case offsetof(struct user32, u_debugreg[6]):
215 *val = child->thread.debugreg6;
216 break;
217 case offsetof(struct user32, u_debugreg[7]):
218 *val = child->thread.debugreg7;
219 break; 172 break;
220 173
221 default: 174 default: