[PATCH] amd64: task_pt_regs()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Al Viro and committed by Linus Torvalds bb049232 e4f17c43

+13 -21
+3 -4
arch/x86_64/ia32/ia32_binfmt.c
··· 197 198 static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs) 199 { 200 - struct pt_regs *pp = (struct pt_regs *)(t->thread.rsp0); 201 - --pp; 202 ELF_CORE_COPY_REGS((*elfregs), pp); 203 /* fix wrong segments */ 204 (*elfregs)[7] = t->thread.ds; ··· 216 if (!tsk_used_math(tsk)) 217 return 0; 218 if (!regs) 219 - regs = ((struct pt_regs *)tsk->thread.rsp0) - 1; 220 if (tsk == current) 221 unlazy_fpu(tsk); 222 set_fs(KERNEL_DS); ··· 232 static inline int 233 elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu) 234 { 235 - struct pt_regs *regs = ((struct pt_regs *)(t->thread.rsp0))-1; 236 if (!tsk_used_math(t)) 237 return 0; 238 if (t == current)
··· 197 198 static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs) 199 { 200 + struct pt_regs *pp = task_pt_regs(t); 201 ELF_CORE_COPY_REGS((*elfregs), pp); 202 /* fix wrong segments */ 203 (*elfregs)[7] = t->thread.ds; ··· 217 if (!tsk_used_math(tsk)) 218 return 0; 219 if (!regs) 220 + regs = task_pt_regs(tsk); 221 if (tsk == current) 222 unlazy_fpu(tsk); 223 set_fs(KERNEL_DS); ··· 233 static inline int 234 elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu) 235 { 236 + struct pt_regs *regs = task_pt_regs(t); 237 if (!tsk_used_math(t)) 238 return 0; 239 if (t == current)
+3 -3
arch/x86_64/ia32/ptrace32.c
··· 41 static int putreg32(struct task_struct *child, unsigned regno, u32 val) 42 { 43 int i; 44 - __u64 *stack = (__u64 *)(child->thread.rsp0 - sizeof(struct pt_regs)); 45 46 switch (regno) { 47 case offsetof(struct user32, regs.fs): ··· 137 138 static int getreg32(struct task_struct *child, unsigned regno, u32 *val) 139 { 140 - __u64 *stack = (__u64 *)(child->thread.rsp0 - sizeof(struct pt_regs)); 141 142 switch (regno) { 143 case offsetof(struct user32, regs.fs): ··· 238 if (ret < 0) 239 goto out; 240 241 - childregs = (struct pt_regs *)(child->thread.rsp0 - sizeof(struct pt_regs)); 242 243 switch (request) { 244 case PTRACE_PEEKDATA:
··· 41 static int putreg32(struct task_struct *child, unsigned regno, u32 val) 42 { 43 int i; 44 + __u64 *stack = (__u64 *)task_pt_regs(child); 45 46 switch (regno) { 47 case offsetof(struct user32, regs.fs): ··· 137 138 static int getreg32(struct task_struct *child, unsigned regno, u32 *val) 139 { 140 + __u64 *stack = (__u64 *)task_pt_regs(child); 141 142 switch (regno) { 143 case offsetof(struct user32, regs.fs): ··· 238 if (ret < 0) 239 goto out; 240 241 + childregs = task_pt_regs(child); 242 243 switch (request) { 244 case PTRACE_PEEKDATA:
+1 -2
arch/x86_64/kernel/process.c
··· 822 { 823 struct pt_regs *pp, ptregs; 824 825 - pp = (struct pt_regs *)(tsk->thread.rsp0); 826 - --pp; 827 828 ptregs = *pp; 829 ptregs.cs &= 0xffff;
··· 822 { 823 struct pt_regs *pp, ptregs; 824 825 + pp = task_pt_regs(tsk); 826 827 ptregs = *pp; 828 ptregs.cs &= 0xffff;
+2 -8
arch/x86_64/kernel/ptrace.c
··· 67 return (*((unsigned long *)stack)); 68 } 69 70 - static 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 /* 77 * 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. ··· 164 165 static void set_singlestep(struct task_struct *child) 166 { 167 - struct pt_regs *regs = get_child_regs(child); 168 169 /* 170 * Always set TIF_SINGLESTEP - this guarantees that ··· 202 203 /* But touch TF only if it was set by us.. */ 204 if (child->ptrace & PT_DTRACE) { 205 - struct pt_regs *regs = get_child_regs(child); 206 regs->eflags &= ~TRAP_FLAG; 207 child->ptrace &= ~PT_DTRACE; 208 }
··· 67 return (*((unsigned long *)stack)); 68 } 69 70 /* 71 * this routine will put a word on the processes privileged stack. 72 * the offset is how far from the base addr as stored in the TSS. ··· 170 171 static void set_singlestep(struct task_struct *child) 172 { 173 + struct pt_regs *regs = task_pt_regs(child); 174 175 /* 176 * Always set TIF_SINGLESTEP - this guarantees that ··· 208 209 /* But touch TF only if it was set by us.. */ 210 if (child->ptrace & PT_DTRACE) { 211 + struct pt_regs *regs = task_pt_regs(child); 212 regs->eflags &= ~TRAP_FLAG; 213 child->ptrace &= ~PT_DTRACE; 214 }
+1 -1
arch/x86_64/kernel/traps.c
··· 666 ; 667 /* Exception from user space */ 668 else if (user_mode(eregs)) 669 - regs = ((struct pt_regs *)current->thread.rsp0) - 1; 670 /* Exception from kernel and interrupts are enabled. Move to 671 kernel process stack. */ 672 else if (eregs->eflags & X86_EFLAGS_IF)
··· 666 ; 667 /* Exception from user space */ 668 else if (user_mode(eregs)) 669 + regs = task_pt_regs(current); 670 /* Exception from kernel and interrupts are enabled. Move to 671 kernel process stack. */ 672 else if (eregs->eflags & X86_EFLAGS_IF)
+1 -1
include/asm-x86_64/compat.h
··· 198 199 static __inline__ void __user *compat_alloc_user_space(long len) 200 { 201 - struct pt_regs *regs = (void *)current->thread.rsp0 - sizeof(struct pt_regs); 202 return (void __user *)regs->rsp - len; 203 } 204
··· 198 199 static __inline__ void __user *compat_alloc_user_space(long len) 200 { 201 + struct pt_regs *regs = task_pt_regs(current); 202 return (void __user *)regs->rsp - len; 203 } 204
+2 -2
include/asm-x86_64/processor.h
··· 321 #define thread_saved_pc(t) (*(unsigned long *)((t)->thread.rsp - 8)) 322 323 extern unsigned long get_wchan(struct task_struct *p); 324 - #define KSTK_EIP(tsk) \ 325 - (((struct pt_regs *)(tsk->thread.rsp0 - sizeof(struct pt_regs)))->rip) 326 #define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */ 327 328
··· 321 #define thread_saved_pc(t) (*(unsigned long *)((t)->thread.rsp - 8)) 322 323 extern unsigned long get_wchan(struct task_struct *p); 324 + #define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.rsp0 - 1) 325 + #define KSTK_EIP(tsk) (task_pt_regs(tsk)->rip) 326 #define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */ 327 328