Commit 92652cf9 authored by Kees Cook's avatar Kees Cook
Browse files

xtensa: Implement "current_stack_pointer"



To follow the existing per-arch conventions replace open-coded uses
of asm "sp" as "current_stack_pointer". This will let it be used in
non-arch places (like HARDENED_USERCOPY).

Cc: Chris Zankel <chris@zankel.net>
Cc: Marc Zyngier <maz@kernel.org>
Cc: linux-xtensa@linux-xtensa.org
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Acked-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
Link: https://lore.kernel.org/lkml/CAMo8BfJFJE-n3=AF+pb9_6oF3gzxX7a+7aBrASHjjNX5byqDqw@mail.gmail.com
parent 2792d84e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ config XTENSA
	def_bool y
	select ARCH_32BIT_OFF_T
	select ARCH_HAS_BINFMT_FLAT if !MMU
	select ARCH_HAS_CURRENT_STACK_POINTER
	select ARCH_HAS_DMA_PREP_COHERENT if MMU
	select ARCH_HAS_SYNC_DMA_FOR_CPU if MMU
	select ARCH_HAS_SYNC_DMA_FOR_DEVICE if MMU
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ static inline struct task_struct *get_current(void)

#define current get_current()

register unsigned long current_stack_pointer __asm__("a1");

#else

#define GET_CURRENT(reg,sp)		\
+4 −4
Original line number Diff line number Diff line
@@ -19,14 +19,14 @@ struct stackframe {

static __always_inline unsigned long *stack_pointer(struct task_struct *task)
{
	unsigned long *sp;
	unsigned long sp;

	if (!task || task == current)
		__asm__ __volatile__ ("mov %0, a1\n" : "=a"(sp));
		sp = current_stack_pointer;
	else
		sp = (unsigned long *)task->thread.sp;
		sp = task->thread.sp;

	return sp;
	return (unsigned long *)sp;
}

void walk_stackframe(unsigned long *sp,
+1 −2
Original line number Diff line number Diff line
@@ -36,9 +36,8 @@ asmlinkage void do_IRQ(int hwirq, struct pt_regs *regs)
#ifdef CONFIG_DEBUG_STACKOVERFLOW
	/* Debugging check for stack overflow: is there less than 1KB free? */
	{
		unsigned long sp;
		unsigned long sp = current_stack_pointer;

		__asm__ __volatile__ ("mov %0, a1\n" : "=a" (sp));
		sp &= THREAD_SIZE - 1;

		if (unlikely(sp < (sizeof(thread_info) + 1024)))