aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/ia32
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-01-30 07:30:58 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:30:58 -0500
commitd277fb89dfb042deba04a8e765718cc8b3825e85 (patch)
treea42aa151708c71094a856ffefc7f6cf566228328 /arch/x86/ia32
parent5fd4d16bd59a9fc84ca94c4fce4abc23fe219108 (diff)
x86: x86-64 ia32 ptrace get/putreg32 current task
This generalizes the getreg32 and putreg32 functions so they can be used on the current task, as well as on a task stopped in TASK_TRACED and switched off. This lays the groundwork to share this code for all kinds of user-mode machine state access, not just ptrace. 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.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/x86/ia32/ptrace32.c b/arch/x86/ia32/ptrace32.c
index c52d0664c67f..d5663e295330 100644
--- a/arch/x86/ia32/ptrace32.c
+++ b/arch/x86/ia32/ptrace32.c
@@ -48,19 +48,27 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
48 if (val && (val & 3) != 3) 48 if (val && (val & 3) != 3)
49 return -EIO; 49 return -EIO;
50 child->thread.fsindex = val & 0xffff; 50 child->thread.fsindex = val & 0xffff;
51 if (child == current)
52 loadsegment(fs, child->thread.fsindex);
51 break; 53 break;
52 case offsetof(struct user32, regs.gs): 54 case offsetof(struct user32, regs.gs):
53 if (val && (val & 3) != 3) 55 if (val && (val & 3) != 3)
54 return -EIO; 56 return -EIO;
55 child->thread.gsindex = val & 0xffff; 57 child->thread.gsindex = val & 0xffff;
58 if (child == current)
59 load_gs_index(child->thread.gsindex);
56 break; 60 break;
57 case offsetof(struct user32, regs.ds): 61 case offsetof(struct user32, regs.ds):
58 if (val && (val & 3) != 3) 62 if (val && (val & 3) != 3)
59 return -EIO; 63 return -EIO;
60 child->thread.ds = val & 0xffff; 64 child->thread.ds = val & 0xffff;
65 if (child == current)
66 loadsegment(ds, child->thread.ds);
61 break; 67 break;
62 case offsetof(struct user32, regs.es): 68 case offsetof(struct user32, regs.es):
63 child->thread.es = val & 0xffff; 69 child->thread.es = val & 0xffff;
70 if (child == current)
71 loadsegment(es, child->thread.ds);
64 break; 72 break;
65 case offsetof(struct user32, regs.ss): 73 case offsetof(struct user32, regs.ss):
66 if ((val & 3) != 3) 74 if ((val & 3) != 3)
@@ -129,15 +137,23 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
129 switch (regno) { 137 switch (regno) {
130 case offsetof(struct user32, regs.fs): 138 case offsetof(struct user32, regs.fs):
131 *val = child->thread.fsindex; 139 *val = child->thread.fsindex;
140 if (child == current)
141 asm("movl %%fs,%0" : "=r" (*val));
132 break; 142 break;
133 case offsetof(struct user32, regs.gs): 143 case offsetof(struct user32, regs.gs):
134 *val = child->thread.gsindex; 144 *val = child->thread.gsindex;
145 if (child == current)
146 asm("movl %%gs,%0" : "=r" (*val));
135 break; 147 break;
136 case offsetof(struct user32, regs.ds): 148 case offsetof(struct user32, regs.ds):
137 *val = child->thread.ds; 149 *val = child->thread.ds;
150 if (child == current)
151 asm("movl %%ds,%0" : "=r" (*val));
138 break; 152 break;
139 case offsetof(struct user32, regs.es): 153 case offsetof(struct user32, regs.es):
140 *val = child->thread.es; 154 *val = child->thread.es;
155 if (child == current)
156 asm("movl %%es,%0" : "=r" (*val));
141 break; 157 break;
142 158
143 R32(cs, cs); 159 R32(cs, cs);