aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/ptrace.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-02-09 08:17:40 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-09 18:41:58 -0500
commitd9a89a26e02ef9ed03f74a755a8b4d8f3a066622 (patch)
tree35f3713bca4e6b815f6b9db92dc9d812ec7213ff /arch/x86/kernel/ptrace.c
parentf0d96110f9fd98a1a22e03b8adba69508843d910 (diff)
x86: add %gs accessors for x86_32
Impact: cleanup On x86_32, %gs is handled lazily. It's not saved and restored on kernel entry/exit but only when necessary which usually is during task switch but there are few other places. Currently, it's done by calling savesegment() and loadsegment() explicitly. Define get_user_gs(), set_user_gs() and task_user_gs() and use them instead. While at it, clean up register access macros in signal.c. This cleans up code a bit and will help future changes. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/ptrace.c')
-rw-r--r--arch/x86/kernel/ptrace.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 0a5df5f82fb9..508b6b57d0c3 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -90,9 +90,10 @@ static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
90 if (offset != offsetof(struct user_regs_struct, gs)) 90 if (offset != offsetof(struct user_regs_struct, gs))
91 retval = *pt_regs_access(task_pt_regs(task), offset); 91 retval = *pt_regs_access(task_pt_regs(task), offset);
92 else { 92 else {
93 retval = task->thread.gs;
94 if (task == current) 93 if (task == current)
95 savesegment(gs, retval); 94 retval = get_user_gs(task_pt_regs(task));
95 else
96 retval = task_user_gs(task);
96 } 97 }
97 return retval; 98 return retval;
98} 99}
@@ -126,13 +127,10 @@ static int set_segment_reg(struct task_struct *task,
126 break; 127 break;
127 128
128 case offsetof(struct user_regs_struct, gs): 129 case offsetof(struct user_regs_struct, gs):
129 task->thread.gs = value;
130 if (task == current) 130 if (task == current)
131 /* 131 set_user_gs(task_pt_regs(task), value);
132 * The user-mode %gs is not affected by 132 else
133 * kernel entry, so we must update the CPU. 133 task_user_gs(task) = value;
134 */
135 loadsegment(gs, value);
136 } 134 }
137 135
138 return 0; 136 return 0;