diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-11-18 12:50:10 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-12-19 18:07:39 -0500 |
commit | 1ca97bb541a1f5a735e697a8bba763cde3aab452 (patch) | |
tree | 548d835c0f13de780678922ba3b3ea4c841e8cd7 | |
parent | 5208ba24e7826519d310474dedaed2f84b0ab6a0 (diff) |
new helper: current_user_stack_pointer()
Cross-architecture equivalent of rdusp(); default is
user_stack_pointer(current_pt_regs()) - that works for almost all
platforms that have usp saved in pt_regs. The only exception from
that is ia64 - we want memory stack, not the backing store for
register one.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | arch/alpha/include/asm/ptrace.h | 1 | ||||
-rw-r--r-- | arch/blackfin/include/asm/ptrace.h | 1 | ||||
-rw-r--r-- | arch/cris/include/asm/ptrace.h | 1 | ||||
-rw-r--r-- | arch/h8300/include/asm/ptrace.h | 1 | ||||
-rw-r--r-- | arch/ia64/include/asm/ptrace.h | 5 | ||||
-rw-r--r-- | arch/m68k/include/asm/ptrace.h | 1 | ||||
-rw-r--r-- | include/linux/ptrace.h | 4 |
7 files changed, 14 insertions, 0 deletions
diff --git a/arch/alpha/include/asm/ptrace.h b/arch/alpha/include/asm/ptrace.h index b4c5b2fbb647..fd53c74ac943 100644 --- a/arch/alpha/include/asm/ptrace.h +++ b/arch/alpha/include/asm/ptrace.h | |||
@@ -72,6 +72,7 @@ struct switch_stack { | |||
72 | #define user_mode(regs) (((regs)->ps & 8) != 0) | 72 | #define user_mode(regs) (((regs)->ps & 8) != 0) |
73 | #define instruction_pointer(regs) ((regs)->pc) | 73 | #define instruction_pointer(regs) ((regs)->pc) |
74 | #define profile_pc(regs) instruction_pointer(regs) | 74 | #define profile_pc(regs) instruction_pointer(regs) |
75 | #define current_user_stack_pointer() rdusp() | ||
75 | 76 | ||
76 | #define task_pt_regs(task) \ | 77 | #define task_pt_regs(task) \ |
77 | ((struct pt_regs *) (task_stack_page(task) + 2*PAGE_SIZE) - 1) | 78 | ((struct pt_regs *) (task_stack_page(task) + 2*PAGE_SIZE) - 1) |
diff --git a/arch/blackfin/include/asm/ptrace.h b/arch/blackfin/include/asm/ptrace.h index 10d8641180f2..c42002506a26 100644 --- a/arch/blackfin/include/asm/ptrace.h +++ b/arch/blackfin/include/asm/ptrace.h | |||
@@ -106,6 +106,7 @@ struct pt_regs { | |||
106 | #define arch_has_single_step() (1) | 106 | #define arch_has_single_step() (1) |
107 | /* common code demands this function */ | 107 | /* common code demands this function */ |
108 | #define ptrace_disable(child) user_disable_single_step(child) | 108 | #define ptrace_disable(child) user_disable_single_step(child) |
109 | #define current_user_stack_pointer() rdusp() | ||
109 | 110 | ||
110 | extern int is_user_addr_valid(struct task_struct *child, | 111 | extern int is_user_addr_valid(struct task_struct *child, |
111 | unsigned long start, unsigned long len); | 112 | unsigned long start, unsigned long len); |
diff --git a/arch/cris/include/asm/ptrace.h b/arch/cris/include/asm/ptrace.h index 6618893bfe8e..551c081ab62b 100644 --- a/arch/cris/include/asm/ptrace.h +++ b/arch/cris/include/asm/ptrace.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #define PTRACE_SETREGS 13 | 10 | #define PTRACE_SETREGS 13 |
11 | 11 | ||
12 | #define profile_pc(regs) instruction_pointer(regs) | 12 | #define profile_pc(regs) instruction_pointer(regs) |
13 | #define current_user_stack_pointer() rdusp() | ||
13 | 14 | ||
14 | #endif /* __KERNEL__ */ | 15 | #endif /* __KERNEL__ */ |
15 | 16 | ||
diff --git a/arch/h8300/include/asm/ptrace.h b/arch/h8300/include/asm/ptrace.h index 7468589a128b..6183371d0c93 100644 --- a/arch/h8300/include/asm/ptrace.h +++ b/arch/h8300/include/asm/ptrace.h | |||
@@ -63,6 +63,7 @@ struct pt_regs { | |||
63 | #define current_pt_regs() ((struct pt_regs *) \ | 63 | #define current_pt_regs() ((struct pt_regs *) \ |
64 | (THREAD_SIZE + (unsigned long)current_thread_info()) - 1) | 64 | (THREAD_SIZE + (unsigned long)current_thread_info()) - 1) |
65 | #define signal_pt_regs() ((struct pt_regs *)current->thread.esp0) | 65 | #define signal_pt_regs() ((struct pt_regs *)current->thread.esp0) |
66 | #define current_user_stack_pointer() rdusp() | ||
66 | #endif /* __KERNEL__ */ | 67 | #endif /* __KERNEL__ */ |
67 | #endif /* __ASSEMBLY__ */ | 68 | #endif /* __ASSEMBLY__ */ |
68 | #endif /* _H8300_PTRACE_H */ | 69 | #endif /* _H8300_PTRACE_H */ |
diff --git a/arch/ia64/include/asm/ptrace.h b/arch/ia64/include/asm/ptrace.h index b0e973649cb9..845143990a1d 100644 --- a/arch/ia64/include/asm/ptrace.h +++ b/arch/ia64/include/asm/ptrace.h | |||
@@ -78,6 +78,11 @@ static inline long regs_return_value(struct pt_regs *regs) | |||
78 | unsigned long __ip = instruction_pointer(regs); \ | 78 | unsigned long __ip = instruction_pointer(regs); \ |
79 | (__ip & ~3UL) + ((__ip & 3UL) << 2); \ | 79 | (__ip & ~3UL) + ((__ip & 3UL) << 2); \ |
80 | }) | 80 | }) |
81 | /* | ||
82 | * Why not default? Because user_stack_pointer() on ia64 gives register | ||
83 | * stack backing store instead... | ||
84 | */ | ||
85 | #define current_user_stack_pointer() (current_pt_regs()->r12) | ||
81 | 86 | ||
82 | /* given a pointer to a task_struct, return the user's pt_regs */ | 87 | /* given a pointer to a task_struct, return the user's pt_regs */ |
83 | # define task_pt_regs(t) (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1) | 88 | # define task_pt_regs(t) (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1) |
diff --git a/arch/m68k/include/asm/ptrace.h b/arch/m68k/include/asm/ptrace.h index 0f717045bdde..a45cb6894ad3 100644 --- a/arch/m68k/include/asm/ptrace.h +++ b/arch/m68k/include/asm/ptrace.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #define profile_pc(regs) instruction_pointer(regs) | 15 | #define profile_pc(regs) instruction_pointer(regs) |
16 | #define current_pt_regs() \ | 16 | #define current_pt_regs() \ |
17 | (struct pt_regs *)((char *)current_thread_info() + THREAD_SIZE) - 1 | 17 | (struct pt_regs *)((char *)current_thread_info() + THREAD_SIZE) - 1 |
18 | #define current_user_stack_pointer() rdusp() | ||
18 | 19 | ||
19 | #define arch_has_single_step() (1) | 20 | #define arch_has_single_step() (1) |
20 | 21 | ||
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index a89ff04bddd9..a3a9d085f932 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h | |||
@@ -342,6 +342,10 @@ static inline void user_single_step_siginfo(struct task_struct *tsk, | |||
342 | #define signal_pt_regs() task_pt_regs(current) | 342 | #define signal_pt_regs() task_pt_regs(current) |
343 | #endif | 343 | #endif |
344 | 344 | ||
345 | #ifndef current_user_stack_pointer | ||
346 | #define current_user_stack_pointer() user_stack_pointer(current_pt_regs()) | ||
347 | #endif | ||
348 | |||
345 | extern int task_current_syscall(struct task_struct *target, long *callno, | 349 | extern int task_current_syscall(struct task_struct *target, long *callno, |
346 | unsigned long args[6], unsigned int maxargs, | 350 | unsigned long args[6], unsigned int maxargs, |
347 | unsigned long *sp, unsigned long *pc); | 351 | unsigned long *sp, unsigned long *pc); |