Commit c2c3258f authored by Heiko Carstens's avatar Heiko Carstens Committed by Vasily Gorbik
Browse files

s390/stack: use STACK_INIT_OFFSET where possible



Make STACK_INIT_OFFSET also available for assembler code, and
use it everywhere instead of open-coding it at several places.

Reviewed-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent e6badee9
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -9,6 +9,9 @@
#define _ASM_THREAD_INFO_H

#include <linux/bits.h>
#ifndef ASM_OFFSETS_C
#include <asm/asm-offsets.h>
#endif

/*
 * General size of kernel stacks
@@ -21,13 +24,12 @@
#define BOOT_STACK_SIZE (PAGE_SIZE << 2)
#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)

#define STACK_INIT_OFFSET (THREAD_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE)

#ifndef __ASSEMBLY__
#include <asm/lowcore.h>
#include <asm/page.h>

#define STACK_INIT_OFFSET \
	(THREAD_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs))

/*
 * low level task data that entry.S needs immediate access to
 * - this struct should fit entirely inside of one cache line
+4 −8
Original line number Diff line number Diff line
@@ -29,10 +29,6 @@
#include <asm/export.h>
#include <asm/nospec-insn.h>

STACK_SHIFT = PAGE_SHIFT + THREAD_SIZE_ORDER
STACK_SIZE  = 1 << STACK_SHIFT
STACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE

_LPP_OFFSET	= __LC_LPP

	.macro STBEAR address
@@ -53,7 +49,7 @@ _LPP_OFFSET = __LC_LPP

	.macro	CHECK_STACK savearea
#ifdef CONFIG_CHECK_STACK
	tml	%r15,STACK_SIZE - CONFIG_STACK_GUARD
	tml	%r15,THREAD_SIZE - CONFIG_STACK_GUARD
	lghi	%r14,\savearea
	jz	stack_overflow
#endif
@@ -62,8 +58,8 @@ _LPP_OFFSET = __LC_LPP
	.macro	CHECK_VMAP_STACK savearea,oklabel
#ifdef CONFIG_VMAP_STACK
	lgr	%r14,%r15
	nill	%r14,0x10000 - STACK_SIZE
	oill	%r14,STACK_INIT
	nill	%r14,0x10000 - THREAD_SIZE
	oill	%r14,STACK_INIT_OFFSET
	clg	%r14,__LC_KERNEL_STACK
	je	\oklabel
	clg	%r14,__LC_ASYNC_STACK
@@ -179,7 +175,7 @@ ENTRY(__switch_to)
	stmg	%r6,%r15,__SF_GPRS(%r15)	# store gprs of prev task
	lghi	%r4,__TASK_stack
	lghi	%r1,__TASK_thread
	llill	%r5,STACK_INIT
	llill	%r5,STACK_INIT_OFFSET
	stg	%r15,__THREAD_ksp(%r1,%r2)	# store kernel stack of prev
	lg	%r15,0(%r4,%r3)			# start of kernel stack of next
	agr	%r15,%r5			# end of kernel stack of next
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ ENTRY(startup_continue)
#
	larl	%r14,init_task
	stg	%r14,__LC_CURRENT
	larl	%r15,init_thread_union+THREAD_SIZE-STACK_FRAME_OVERHEAD-__PT_SIZE
	larl	%r15,init_thread_union+STACK_INIT_OFFSET
	brasl	%r14,sclp_early_adjust_va	# allow sclp_early_printk
	brasl	%r14,startup_init		# s390 specific early init
	brasl	%r14,start_kernel		# common init code
+1 −2
Original line number Diff line number Diff line
@@ -436,8 +436,7 @@ static void __init setup_lowcore(void)
	lc->io_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_MCHECK;
	lc->io_new_psw.addr = (unsigned long) io_int_handler;
	lc->clock_comparator = clock_comparator_max;
	lc->nodat_stack = ((unsigned long) &init_thread_union)
		+ THREAD_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs);
	lc->nodat_stack = ((unsigned long)&init_thread_union) + STACK_INIT_OFFSET;
	lc->current_task = (unsigned long)&init_task;
	lc->lpp = LPP_MAGIC;
	lc->machine_flags = S390_lowcore.machine_flags;
+2 −3
Original line number Diff line number Diff line
@@ -280,8 +280,7 @@ static void pcpu_attach_task(struct pcpu *pcpu, struct task_struct *tsk)

	cpu = pcpu - pcpu_devices;
	lc = lowcore_ptr[cpu];
	lc->kernel_stack = (unsigned long) task_stack_page(tsk)
		+ THREAD_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs);
	lc->kernel_stack = (unsigned long)task_stack_page(tsk) + STACK_INIT_OFFSET;
	lc->current_task = (unsigned long)tsk;
	lc->lpp = LPP_MAGIC;
	lc->current_pid = tsk->pid;