aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c7
-rw-r--r--arch/x86_64/ia32/ptrace32.c6
-rw-r--r--arch/x86_64/kernel/process.c3
-rw-r--r--arch/x86_64/kernel/ptrace.c10
-rw-r--r--arch/x86_64/kernel/traps.c2
-rw-r--r--include/asm-x86_64/compat.h2
-rw-r--r--include/asm-x86_64/processor.h4
7 files changed, 13 insertions, 21 deletions
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index 2b760d0d9ce2..029bddab0459 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -197,8 +197,7 @@ static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *re
197 197
198static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs) 198static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs)
199{ 199{
200 struct pt_regs *pp = (struct pt_regs *)(t->thread.rsp0); 200 struct pt_regs *pp = task_pt_regs(t);
201 --pp;
202 ELF_CORE_COPY_REGS((*elfregs), pp); 201 ELF_CORE_COPY_REGS((*elfregs), pp);
203 /* fix wrong segments */ 202 /* fix wrong segments */
204 (*elfregs)[7] = t->thread.ds; 203 (*elfregs)[7] = t->thread.ds;
@@ -217,7 +216,7 @@ elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpr
217 if (!tsk_used_math(tsk)) 216 if (!tsk_used_math(tsk))
218 return 0; 217 return 0;
219 if (!regs) 218 if (!regs)
220 regs = ((struct pt_regs *)tsk->thread.rsp0) - 1; 219 regs = task_pt_regs(tsk);
221 if (tsk == current) 220 if (tsk == current)
222 unlazy_fpu(tsk); 221 unlazy_fpu(tsk);
223 set_fs(KERNEL_DS); 222 set_fs(KERNEL_DS);
@@ -233,7 +232,7 @@ elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpr
233static inline int 232static inline int
234elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu) 233elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
235{ 234{
236 struct pt_regs *regs = ((struct pt_regs *)(t->thread.rsp0))-1; 235 struct pt_regs *regs = task_pt_regs(t);
237 if (!tsk_used_math(t)) 236 if (!tsk_used_math(t))
238 return 0; 237 return 0;
239 if (t == current) 238 if (t == current)
diff --git a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
index ea4394e021d6..23a4515a73b4 100644
--- a/arch/x86_64/ia32/ptrace32.c
+++ b/arch/x86_64/ia32/ptrace32.c
@@ -41,7 +41,7 @@
41static int putreg32(struct task_struct *child, unsigned regno, u32 val) 41static int putreg32(struct task_struct *child, unsigned regno, u32 val)
42{ 42{
43 int i; 43 int i;
44 __u64 *stack = (__u64 *)(child->thread.rsp0 - sizeof(struct pt_regs)); 44 __u64 *stack = (__u64 *)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):
@@ -137,7 +137,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
137 137
138static int getreg32(struct task_struct *child, unsigned regno, u32 *val) 138static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
139{ 139{
140 __u64 *stack = (__u64 *)(child->thread.rsp0 - sizeof(struct pt_regs)); 140 __u64 *stack = (__u64 *)task_pt_regs(child);
141 141
142 switch (regno) { 142 switch (regno) {
143 case offsetof(struct user32, regs.fs): 143 case offsetof(struct user32, regs.fs):
@@ -238,7 +238,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
238 if (ret < 0) 238 if (ret < 0)
239 goto out; 239 goto out;
240 240
241 childregs = (struct pt_regs *)(child->thread.rsp0 - sizeof(struct pt_regs)); 241 childregs = task_pt_regs(child);
242 242
243 switch (request) { 243 switch (request) {
244 case PTRACE_PEEKDATA: 244 case PTRACE_PEEKDATA:
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 2ea4acd47fc2..68df519c83e6 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -822,8 +822,7 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
822{ 822{
823 struct pt_regs *pp, ptregs; 823 struct pt_regs *pp, ptregs;
824 824
825 pp = (struct pt_regs *)(tsk->thread.rsp0); 825 pp = task_pt_regs(tsk);
826 --pp;
827 826
828 ptregs = *pp; 827 ptregs = *pp;
829 ptregs.cs &= 0xffff; 828 ptregs.cs &= 0xffff;
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
index 86248bc9303e..53205622351c 100644
--- a/arch/x86_64/kernel/ptrace.c
+++ b/arch/x86_64/kernel/ptrace.c
@@ -67,12 +67,6 @@ static inline unsigned long get_stack_long(struct task_struct *task, int offset)
67 return (*((unsigned long *)stack)); 67 return (*((unsigned long *)stack));
68} 68}
69 69
70static inline struct pt_regs *get_child_regs(struct task_struct *task)
71{
72 struct pt_regs *regs = (void *)task->thread.rsp0;
73 return regs - 1;
74}
75
76/* 70/*
77 * this routine will put a word on the processes privileged stack. 71 * this routine will put a word on the processes privileged stack.
78 * the offset is how far from the base addr as stored in the TSS. 72 * the offset is how far from the base addr as stored in the TSS.
@@ -170,7 +164,7 @@ static int is_at_popf(struct task_struct *child, struct pt_regs *regs)
170 164
171static void set_singlestep(struct task_struct *child) 165static void set_singlestep(struct task_struct *child)
172{ 166{
173 struct pt_regs *regs = get_child_regs(child); 167 struct pt_regs *regs = task_pt_regs(child);
174 168
175 /* 169 /*
176 * Always set TIF_SINGLESTEP - this guarantees that 170 * Always set TIF_SINGLESTEP - this guarantees that
@@ -208,7 +202,7 @@ static void clear_singlestep(struct task_struct *child)
208 202
209 /* But touch TF only if it was set by us.. */ 203 /* But touch TF only if it was set by us.. */
210 if (child->ptrace & PT_DTRACE) { 204 if (child->ptrace & PT_DTRACE) {
211 struct pt_regs *regs = get_child_regs(child); 205 struct pt_regs *regs = task_pt_regs(child);
212 regs->eflags &= ~TRAP_FLAG; 206 regs->eflags &= ~TRAP_FLAG;
213 child->ptrace &= ~PT_DTRACE; 207 child->ptrace &= ~PT_DTRACE;
214 } 208 }
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index d8f90b48aec4..8bb0aeda78b9 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -666,7 +666,7 @@ asmlinkage struct pt_regs *sync_regs(struct pt_regs *eregs)
666 ; 666 ;
667 /* Exception from user space */ 667 /* Exception from user space */
668 else if (user_mode(eregs)) 668 else if (user_mode(eregs))
669 regs = ((struct pt_regs *)current->thread.rsp0) - 1; 669 regs = task_pt_regs(current);
670 /* Exception from kernel and interrupts are enabled. Move to 670 /* Exception from kernel and interrupts are enabled. Move to
671 kernel process stack. */ 671 kernel process stack. */
672 else if (eregs->eflags & X86_EFLAGS_IF) 672 else if (eregs->eflags & X86_EFLAGS_IF)
diff --git a/include/asm-x86_64/compat.h b/include/asm-x86_64/compat.h
index 3863a7da372b..b37ab8218ef0 100644
--- a/include/asm-x86_64/compat.h
+++ b/include/asm-x86_64/compat.h
@@ -198,7 +198,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
198 198
199static __inline__ void __user *compat_alloc_user_space(long len) 199static __inline__ void __user *compat_alloc_user_space(long len)
200{ 200{
201 struct pt_regs *regs = (void *)current->thread.rsp0 - sizeof(struct pt_regs); 201 struct pt_regs *regs = task_pt_regs(current);
202 return (void __user *)regs->rsp - len; 202 return (void __user *)regs->rsp - len;
203} 203}
204 204
diff --git a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
index 394dd729752d..87a282b1043a 100644
--- a/include/asm-x86_64/processor.h
+++ b/include/asm-x86_64/processor.h
@@ -321,8 +321,8 @@ extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
321#define thread_saved_pc(t) (*(unsigned long *)((t)->thread.rsp - 8)) 321#define thread_saved_pc(t) (*(unsigned long *)((t)->thread.rsp - 8))
322 322
323extern unsigned long get_wchan(struct task_struct *p); 323extern unsigned long get_wchan(struct task_struct *p);
324#define KSTK_EIP(tsk) \ 324#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.rsp0 - 1)
325 (((struct pt_regs *)(tsk->thread.rsp0 - sizeof(struct pt_regs)))->rip) 325#define KSTK_EIP(tsk) (task_pt_regs(tsk)->rip)
326#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */ 326#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
327 327
328 328