powerpc: Rename current_stack_pointer() to current_stack_frame()
authorMichael Ellerman <mpe@ellerman.id.au>
Thu, 20 Feb 2020 11:51:37 +0000 (22:51 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 4 Mar 2020 11:44:28 +0000 (22:44 +1100)
current_stack_pointer(), which was called __get_SP(), used to just
return the value in r1.

But that caused problems in some cases, so it was turned into a
function in commit bfe9a2cfe91a ("powerpc: Reimplement __get_SP() as a
function not a define").

Because it's a function in a separate compilation unit to all its
callers, it has the effect of causing a stack frame to be created, and
then returns the address of that frame. This is good in some cases
like those described in the above commit, but in other cases it's
overkill, we just need to know what stack page we're on.

On some other arches current_stack_pointer is just a register global
giving the stack pointer, and we'd like to do that too. So rename our
current_stack_pointer() to current_stack_frame() to make that
possible.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Link: https://lore.kernel.org/r/20200220115141.2707-1-mpe@ellerman.id.au
arch/powerpc/include/asm/perf_event.h
arch/powerpc/include/asm/reg.h
arch/powerpc/kernel/irq.c
arch/powerpc/kernel/misc.S
arch/powerpc/kernel/process.c
arch/powerpc/kernel/stacktrace.c

index 7426d7a90e1e1a2a7539e3e174974cb298ab4a29..eed3954082fa24d04ae68dc746dd2cb56dd9f707 100644 (file)
@@ -32,7 +32,7 @@
        do {                                                    \
                (regs)->result = 0;                             \
                (regs)->nip = __ip;                             \
-               (regs)->gpr[1] = current_stack_pointer();       \
+               (regs)->gpr[1] = current_stack_frame();         \
                asm volatile("mfmsr %0" : "=r" ((regs)->msr));  \
        } while (0)
 
index 1aa46dff095758ec1b5afb4fcdc7db0a9dfad66e..1b1ffdba60974bb750d3120c3e7acc044e7d4935 100644 (file)
@@ -1448,7 +1448,7 @@ static inline void mtsrin(u32 val, u32 idx)
 
 #define proc_trap()    asm volatile("trap")
 
-extern unsigned long current_stack_pointer(void);
+extern unsigned long current_stack_frame(void);
 
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long value);
index 5c9b11878555afef75bfb81d61809a13b2f2c61f..02118c18434d25f6de89f371e8274926bc2299d6 100644 (file)
@@ -602,7 +602,7 @@ static inline void check_stack_overflow(void)
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
        long sp;
 
-       sp = current_stack_pointer() & (THREAD_SIZE-1);
+       sp = current_stack_frame() & (THREAD_SIZE-1);
 
        /* check for stack overflow: is there less than 2KB free? */
        if (unlikely(sp < 2048)) {
@@ -647,7 +647,7 @@ void do_IRQ(struct pt_regs *regs)
        void *cursp, *irqsp, *sirqsp;
 
        /* Switch to the irq stack to handle this */
-       cursp = (void *)(current_stack_pointer() & ~(THREAD_SIZE - 1));
+       cursp = (void *)(current_stack_frame() & ~(THREAD_SIZE - 1));
        irqsp = hardirq_ctx[raw_smp_processor_id()];
        sirqsp = softirq_ctx[raw_smp_processor_id()];
 
index 974f65f79a8efeb6e0c05042e169fefe694bb434..65f9f731c229be1dc68a62f745c980d98f29e21d 100644 (file)
@@ -110,7 +110,7 @@ _GLOBAL(longjmp)
        li      r3, 1
        blr
 
-_GLOBAL(current_stack_pointer)
+_GLOBAL(current_stack_frame)
        PPC_LL  r3,0(r1)
        blr
-EXPORT_SYMBOL(current_stack_pointer)
+EXPORT_SYMBOL(current_stack_frame)
index e730b8e522b0571d846057bc28393493f062f4d9..110db94cdf3c3e8d86cbdf34691d8696c513fc31 100644 (file)
@@ -2051,7 +2051,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
        sp = (unsigned long) stack;
        if (sp == 0) {
                if (tsk == current)
-                       sp = current_stack_pointer();
+                       sp = current_stack_frame();
                else
                        sp = tsk->thread.ksp;
        }
index e2a46cfed5fd1b97ca3139f52678363c5b8d5456..c477b8585a297a0e3998d7fb910e672ad6a525ff 100644 (file)
@@ -57,7 +57,7 @@ void save_stack_trace(struct stack_trace *trace)
 {
        unsigned long sp;
 
-       sp = current_stack_pointer();
+       sp = current_stack_frame();
 
        save_context_stack(trace, sp, current, 1);
 }
@@ -71,7 +71,7 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
                return;
 
        if (tsk == current)
-               sp = current_stack_pointer();
+               sp = current_stack_frame();
        else
                sp = tsk->thread.ksp;
 
@@ -131,7 +131,7 @@ static int __save_stack_trace_tsk_reliable(struct task_struct *tsk,
        }
 
        if (tsk == current)
-               sp = current_stack_pointer();
+               sp = current_stack_frame();
        else
                sp = tsk->thread.ksp;