From: Al Viro Signed-off-by: Al Viro Signed-off-by: Andrew Morton --- arch/x86_64/ia32/ia32_binfmt.c | 7 +++---- arch/x86_64/ia32/ptrace32.c | 6 +++--- arch/x86_64/kernel/process.c | 3 +-- arch/x86_64/kernel/ptrace.c | 10 ++-------- arch/x86_64/kernel/traps.c | 2 +- include/asm-x86_64/compat.h | 2 +- include/asm-x86_64/processor.h | 4 ++-- 7 files changed, 13 insertions(+), 21 deletions(-) diff -puN arch/x86_64/ia32/ia32_binfmt.c~amd64-task_pt_regs arch/x86_64/ia32/ia32_binfmt.c --- devel/arch/x86_64/ia32/ia32_binfmt.c~amd64-task_pt_regs 2006-01-04 22:01:46.000000000 -0800 +++ devel-akpm/arch/x86_64/ia32/ia32_binfmt.c 2006-01-04 22:01:46.000000000 -0800 @@ -197,8 +197,7 @@ static inline void elf_core_copy_regs(el static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs) { - struct pt_regs *pp = (struct pt_regs *)(t->thread.rsp0); - --pp; + struct pt_regs *pp = task_pt_regs(t); ELF_CORE_COPY_REGS((*elfregs), pp); /* fix wrong segments */ (*elfregs)[7] = t->thread.ds; @@ -217,7 +216,7 @@ elf_core_copy_task_fpregs(struct task_st if (!tsk_used_math(tsk)) return 0; if (!regs) - regs = ((struct pt_regs *)tsk->thread.rsp0) - 1; + regs = task_pt_regs(tsk); if (tsk == current) unlazy_fpu(tsk); set_fs(KERNEL_DS); @@ -233,7 +232,7 @@ elf_core_copy_task_fpregs(struct task_st static inline int elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu) { - struct pt_regs *regs = ((struct pt_regs *)(t->thread.rsp0))-1; + struct pt_regs *regs = task_pt_regs(t); if (!tsk_used_math(t)) return 0; if (t == current) diff -puN arch/x86_64/ia32/ptrace32.c~amd64-task_pt_regs arch/x86_64/ia32/ptrace32.c --- devel/arch/x86_64/ia32/ptrace32.c~amd64-task_pt_regs 2006-01-04 22:01:46.000000000 -0800 +++ devel-akpm/arch/x86_64/ia32/ptrace32.c 2006-01-04 22:01:46.000000000 -0800 @@ -38,7 +38,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val) { int i; - __u64 *stack = (__u64 *)(child->thread.rsp0 - sizeof(struct pt_regs)); + __u64 *stack = (__u64 *)task_pt_regs(child); switch (regno) { case offsetof(struct user32, regs.fs): @@ -134,7 +134,7 @@ static int putreg32(struct task_struct * static int getreg32(struct task_struct *child, unsigned regno, u32 *val) { - __u64 *stack = (__u64 *)(child->thread.rsp0 - sizeof(struct pt_regs)); + __u64 *stack = (__u64 *)task_pt_regs(child); switch (regno) { case offsetof(struct user32, regs.fs): @@ -235,7 +235,7 @@ asmlinkage long sys32_ptrace(long reques if (ret < 0) goto out; - childregs = (struct pt_regs *)(child->thread.rsp0 - sizeof(struct pt_regs)); + childregs = task_pt_regs(child); switch (request) { case PTRACE_PEEKDATA: diff -puN arch/x86_64/kernel/process.c~amd64-task_pt_regs arch/x86_64/kernel/process.c --- devel/arch/x86_64/kernel/process.c~amd64-task_pt_regs 2006-01-04 22:01:46.000000000 -0800 +++ devel-akpm/arch/x86_64/kernel/process.c 2006-01-04 22:01:46.000000000 -0800 @@ -851,8 +851,7 @@ int dump_task_regs(struct task_struct *t { struct pt_regs *pp, ptregs; - pp = (struct pt_regs *)(tsk->thread.rsp0); - --pp; + pp = task_pt_regs(tsk); ptregs = *pp; ptregs.cs &= 0xffff; diff -puN arch/x86_64/kernel/ptrace.c~amd64-task_pt_regs arch/x86_64/kernel/ptrace.c --- devel/arch/x86_64/kernel/ptrace.c~amd64-task_pt_regs 2006-01-04 22:01:46.000000000 -0800 +++ devel-akpm/arch/x86_64/kernel/ptrace.c 2006-01-04 22:01:46.000000000 -0800 @@ -64,12 +64,6 @@ static inline unsigned long get_stack_lo return (*((unsigned long *)stack)); } -static inline struct pt_regs *get_child_regs(struct task_struct *task) -{ - struct pt_regs *regs = (void *)task->thread.rsp0; - return regs - 1; -} - /* * this routine will put a word on the processes privileged stack. * the offset is how far from the base addr as stored in the TSS. @@ -167,7 +161,7 @@ static int is_at_popf(struct task_struct static void set_singlestep(struct task_struct *child) { - struct pt_regs *regs = get_child_regs(child); + struct pt_regs *regs = task_pt_regs(child); /* * Always set TIF_SINGLESTEP - this guarantees that @@ -205,7 +199,7 @@ static void clear_singlestep(struct task /* But touch TF only if it was set by us.. */ if (child->ptrace & PT_DTRACE) { - struct pt_regs *regs = get_child_regs(child); + struct pt_regs *regs = task_pt_regs(child); regs->eflags &= ~TRAP_FLAG; child->ptrace &= ~PT_DTRACE; } diff -puN arch/x86_64/kernel/traps.c~amd64-task_pt_regs arch/x86_64/kernel/traps.c --- devel/arch/x86_64/kernel/traps.c~amd64-task_pt_regs 2006-01-04 22:01:46.000000000 -0800 +++ devel-akpm/arch/x86_64/kernel/traps.c 2006-01-04 22:01:46.000000000 -0800 @@ -668,7 +668,7 @@ asmlinkage struct pt_regs *sync_regs(str ; /* Exception from user space */ else if (user_mode(eregs)) - regs = ((struct pt_regs *)current->thread.rsp0) - 1; + regs = task_pt_regs(current); /* Exception from kernel and interrupts are enabled. Move to kernel process stack. */ else if (eregs->eflags & X86_EFLAGS_IF) diff -puN include/asm-x86_64/compat.h~amd64-task_pt_regs include/asm-x86_64/compat.h --- devel/include/asm-x86_64/compat.h~amd64-task_pt_regs 2006-01-04 22:01:46.000000000 -0800 +++ devel-akpm/include/asm-x86_64/compat.h 2006-01-04 22:01:46.000000000 -0800 @@ -198,7 +198,7 @@ static inline compat_uptr_t ptr_to_compa static __inline__ void __user *compat_alloc_user_space(long len) { - struct pt_regs *regs = (void *)current->thread.rsp0 - sizeof(struct pt_regs); + struct pt_regs *regs = task_pt_regs(current); return (void __user *)regs->rsp - len; } diff -puN include/asm-x86_64/processor.h~amd64-task_pt_regs include/asm-x86_64/processor.h --- devel/include/asm-x86_64/processor.h~amd64-task_pt_regs 2006-01-04 22:01:46.000000000 -0800 +++ devel-akpm/include/asm-x86_64/processor.h 2006-01-04 22:01:46.000000000 -0800 @@ -321,8 +321,8 @@ extern long kernel_thread(int (*fn)(void #define thread_saved_pc(t) (*(unsigned long *)((t)->thread.rsp - 8)) extern unsigned long get_wchan(struct task_struct *p); -#define KSTK_EIP(tsk) \ - (((struct pt_regs *)(tsk->thread.rsp0 - sizeof(struct pt_regs)))->rip) +#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.rsp0 - 1) +#define KSTK_EIP(tsk) (task_pt_regs(tsk)->rip) #define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */ _