Commit 76737ce1 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

s390: add current_stack_pointer() helper function

Implement current_stack_pointer() helper function and use it
everywhere, instead of having several different inline assembly
variants.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Tested-by: default avatarPeter Oberparleiter <oberpar@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 77ec8a54
...@@ -203,6 +203,14 @@ unsigned long get_wchan(struct task_struct *p); ...@@ -203,6 +203,14 @@ unsigned long get_wchan(struct task_struct *p);
/* Has task runtime instrumentation enabled ? */ /* Has task runtime instrumentation enabled ? */
#define is_ri_task(tsk) (!!(tsk)->thread.ri_cb) #define is_ri_task(tsk) (!!(tsk)->thread.ri_cb)
static inline unsigned long current_stack_pointer(void)
{
unsigned long sp;
asm volatile("la %0,0(15)" : "=a" (sp));
return sp;
}
static inline unsigned short stap(void) static inline unsigned short stap(void)
{ {
unsigned short cpu_address; unsigned short cpu_address;
......
...@@ -67,12 +67,11 @@ static void show_trace(struct task_struct *task, unsigned long *stack) ...@@ -67,12 +67,11 @@ static void show_trace(struct task_struct *task, unsigned long *stack)
{ {
const unsigned long frame_size = const unsigned long frame_size =
STACK_FRAME_OVERHEAD + sizeof(struct pt_regs); STACK_FRAME_OVERHEAD + sizeof(struct pt_regs);
register unsigned long __r15 asm ("15");
unsigned long sp; unsigned long sp;
sp = (unsigned long) stack; sp = (unsigned long) stack;
if (!sp) if (!sp)
sp = task ? task->thread.ksp : __r15; sp = task ? task->thread.ksp : current_stack_pointer();
printk("Call Trace:\n"); printk("Call Trace:\n");
#ifdef CONFIG_CHECK_STACK #ifdef CONFIG_CHECK_STACK
sp = __show_trace(sp, sp = __show_trace(sp,
...@@ -95,15 +94,16 @@ static void show_trace(struct task_struct *task, unsigned long *stack) ...@@ -95,15 +94,16 @@ static void show_trace(struct task_struct *task, unsigned long *stack)
void show_stack(struct task_struct *task, unsigned long *sp) void show_stack(struct task_struct *task, unsigned long *sp)
{ {
register unsigned long *__r15 asm ("15");
unsigned long *stack; unsigned long *stack;
int i; int i;
if (!sp) stack = sp;
stack = task ? (unsigned long *) task->thread.ksp : __r15; if (!stack) {
else if (!task)
stack = sp; stack = (unsigned long *)current_stack_pointer();
else
stack = (unsigned long *)task->thread.ksp;
}
for (i = 0; i < 20; i++) { for (i = 0; i < 20; i++) {
if (((addr_t) stack & (THREAD_SIZE-1)) == 0) if (((addr_t) stack & (THREAD_SIZE-1)) == 0)
break; break;
......
...@@ -164,8 +164,7 @@ void do_softirq_own_stack(void) ...@@ -164,8 +164,7 @@ void do_softirq_own_stack(void)
{ {
unsigned long old, new; unsigned long old, new;
/* Get current stack pointer. */ old = current_stack_pointer();
asm volatile("la %0,0(15)" : "=a" (old));
/* Check against async. stack address range. */ /* Check against async. stack address range. */
new = S390_lowcore.async_stack; new = S390_lowcore.async_stack;
if (((new - old) >> (PAGE_SHIFT + THREAD_ORDER)) != 0) { if (((new - old) >> (PAGE_SHIFT + THREAD_ORDER)) != 0) {
......
...@@ -77,10 +77,9 @@ static void __save_stack_trace(struct stack_trace *trace, unsigned long sp) ...@@ -77,10 +77,9 @@ static void __save_stack_trace(struct stack_trace *trace, unsigned long sp)
void save_stack_trace(struct stack_trace *trace) void save_stack_trace(struct stack_trace *trace)
{ {
register unsigned long r15 asm ("15");
unsigned long sp; unsigned long sp;
sp = r15; sp = current_stack_pointer();
__save_stack_trace(trace, sp); __save_stack_trace(trace, sp);
if (trace->nr_entries < trace->max_entries) if (trace->nr_entries < trace->max_entries)
trace->entries[trace->nr_entries++] = ULONG_MAX; trace->entries[trace->nr_entries++] = ULONG_MAX;
...@@ -92,10 +91,8 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) ...@@ -92,10 +91,8 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
unsigned long sp, low, high; unsigned long sp, low, high;
sp = tsk->thread.ksp; sp = tsk->thread.ksp;
if (tsk == current) { if (tsk == current)
/* Get current stack pointer. */ sp = current_stack_pointer();
asm volatile("la %0,0(15)" : "=a" (sp));
}
low = (unsigned long) task_stack_page(tsk); low = (unsigned long) task_stack_page(tsk);
high = (unsigned long) task_pt_regs(tsk); high = (unsigned long) task_pt_regs(tsk);
save_context_stack(trace, sp, low, high, 1); save_context_stack(trace, sp, low, high, 1);
......
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