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