Commit bb049232 authored by Al Viro's avatar Al Viro Committed by Linus Torvalds

[PATCH] amd64: task_pt_regs()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e4f17c43
...@@ -197,8 +197,7 @@ static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *re ...@@ -197,8 +197,7 @@ static inline void elf_core_copy_regs(elf_gregset_t *elfregs, struct pt_regs *re
static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t* elfregs) 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); struct pt_regs *pp = task_pt_regs(t);
--pp;
ELF_CORE_COPY_REGS((*elfregs), pp); ELF_CORE_COPY_REGS((*elfregs), pp);
/* fix wrong segments */ /* fix wrong segments */
(*elfregs)[7] = t->thread.ds; (*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,7 +216,7 @@ elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpr
if (!tsk_used_math(tsk)) if (!tsk_used_math(tsk))
return 0; return 0;
if (!regs) if (!regs)
regs = ((struct pt_regs *)tsk->thread.rsp0) - 1; regs = task_pt_regs(tsk);
if (tsk == current) if (tsk == current)
unlazy_fpu(tsk); unlazy_fpu(tsk);
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
...@@ -233,7 +232,7 @@ elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpr ...@@ -233,7 +232,7 @@ elf_core_copy_task_fpregs(struct task_struct *tsk, struct pt_regs *regs, elf_fpr
static inline int static inline int
elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu) 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)) if (!tsk_used_math(t))
return 0; return 0;
if (t == current) if (t == current)
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
static int putreg32(struct task_struct *child, unsigned regno, u32 val) static int putreg32(struct task_struct *child, unsigned regno, u32 val)
{ {
int i; int i;
__u64 *stack = (__u64 *)(child->thread.rsp0 - sizeof(struct pt_regs)); __u64 *stack = (__u64 *)task_pt_regs(child);
switch (regno) { switch (regno) {
case offsetof(struct user32, regs.fs): case offsetof(struct user32, regs.fs):
...@@ -137,7 +137,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val) ...@@ -137,7 +137,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
static int getreg32(struct task_struct *child, unsigned regno, u32 *val) 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) { switch (regno) {
case offsetof(struct user32, regs.fs): case offsetof(struct user32, regs.fs):
...@@ -238,7 +238,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) ...@@ -238,7 +238,7 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
if (ret < 0) if (ret < 0)
goto out; goto out;
childregs = (struct pt_regs *)(child->thread.rsp0 - sizeof(struct pt_regs)); childregs = task_pt_regs(child);
switch (request) { switch (request) {
case PTRACE_PEEKDATA: case PTRACE_PEEKDATA:
......
...@@ -822,8 +822,7 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs) ...@@ -822,8 +822,7 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
{ {
struct pt_regs *pp, ptregs; struct pt_regs *pp, ptregs;
pp = (struct pt_regs *)(tsk->thread.rsp0); pp = task_pt_regs(tsk);
--pp;
ptregs = *pp; ptregs = *pp;
ptregs.cs &= 0xffff; ptregs.cs &= 0xffff;
......
...@@ -67,12 +67,6 @@ static inline unsigned long get_stack_long(struct task_struct *task, int offset) ...@@ -67,12 +67,6 @@ static inline unsigned long get_stack_long(struct task_struct *task, int offset)
return (*((unsigned long *)stack)); 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. * 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. * 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,7 +164,7 @@ static int is_at_popf(struct task_struct *child, struct pt_regs *regs)
static void set_singlestep(struct task_struct *child) 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 * Always set TIF_SINGLESTEP - this guarantees that
...@@ -208,7 +202,7 @@ static void clear_singlestep(struct task_struct *child) ...@@ -208,7 +202,7 @@ static void clear_singlestep(struct task_struct *child)
/* But touch TF only if it was set by us.. */ /* But touch TF only if it was set by us.. */
if (child->ptrace & PT_DTRACE) { 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; regs->eflags &= ~TRAP_FLAG;
child->ptrace &= ~PT_DTRACE; child->ptrace &= ~PT_DTRACE;
} }
......
...@@ -666,7 +666,7 @@ asmlinkage struct pt_regs *sync_regs(struct pt_regs *eregs) ...@@ -666,7 +666,7 @@ asmlinkage struct pt_regs *sync_regs(struct pt_regs *eregs)
; ;
/* Exception from user space */ /* Exception from user space */
else if (user_mode(eregs)) 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 /* Exception from kernel and interrupts are enabled. Move to
kernel process stack. */ kernel process stack. */
else if (eregs->eflags & X86_EFLAGS_IF) else if (eregs->eflags & X86_EFLAGS_IF)
......
...@@ -198,7 +198,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr) ...@@ -198,7 +198,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
static __inline__ void __user *compat_alloc_user_space(long len) 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; return (void __user *)regs->rsp - len;
} }
......
...@@ -321,8 +321,8 @@ extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); ...@@ -321,8 +321,8 @@ extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
#define thread_saved_pc(t) (*(unsigned long *)((t)->thread.rsp - 8)) #define thread_saved_pc(t) (*(unsigned long *)((t)->thread.rsp - 8))
extern unsigned long get_wchan(struct task_struct *p); extern unsigned long get_wchan(struct task_struct *p);
#define KSTK_EIP(tsk) \ #define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.rsp0 - 1)
(((struct pt_regs *)(tsk->thread.rsp0 - sizeof(struct pt_regs)))->rip) #define KSTK_EIP(tsk) (task_pt_regs(tsk)->rip)
#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */ #define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment