Skip to content

Commit

Permalink
Construct init thread stack in the linker script rather than by union
Browse files Browse the repository at this point in the history
Construct the init thread stack in the linker script rather than doing it
by means of a union so that ia64's init_task.c can be got rid of.

The following symbols are then made available from INIT_TASK_DATA() linker
script macro:

	init_thread_union
	init_stack

INIT_TASK_DATA() also expands the region to THREAD_SIZE to accommodate the
size of the init stack.  init_thread_union is given its own section so that
it can be placed into the stack space in the right order.  I'm assuming
that the ia64 ordering is correct and that the task_struct is first and the
thread_info second.

Signed-off-by: David Howells <[email protected]>
Tested-by: Tony Luck <[email protected]>
Tested-by: Will Deacon <[email protected]> (arm64)
Tested-by: Palmer Dabbelt <[email protected]>
Acked-by: Thomas Gleixner <[email protected]>
  • Loading branch information
dhowells committed Jan 9, 2018
1 parent 1381019 commit 0500871
Show file tree
Hide file tree
Showing 50 changed files with 42 additions and 155 deletions.
4 changes: 2 additions & 2 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ config ARCH_HAS_FORTIFY_SOURCE
config ARCH_HAS_SET_MEMORY
bool

# Select if arch init_task initializer is different to init/init_task.c
config ARCH_INIT_TASK
# Select if arch init_task must go in the __init_task_data section
config ARCH_TASK_STRUCT_ON_STACK
bool

# Select if arch has its private alloc_task_struct() function
Expand Down
3 changes: 0 additions & 3 deletions arch/alpha/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ struct thread_info {
.preempt_count = INIT_PREEMPT_COUNT, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* How to get the thread information struct from C. */
register struct thread_info *__current_thread_info __asm__("$8");
#define current_thread_info() __current_thread_info
Expand Down
3 changes: 0 additions & 3 deletions arch/arc/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

static inline __attribute_const__ struct thread_info *current_thread_info(void)
{
register unsigned long sp asm("sp");
Expand Down
3 changes: 0 additions & 3 deletions arch/arm/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/*
* how to get the current stack pointer in C
*/
Expand Down
2 changes: 0 additions & 2 deletions arch/arm64/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_stack (init_thread_union.stack)

#define thread_saved_pc(tsk) \
((unsigned long)(tsk->thread.cpu_context.pc))
#define thread_saved_sp(tsk) \
Expand Down
2 changes: 0 additions & 2 deletions arch/blackfin/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ struct thread_info {
.cpu = 0, \
.preempt_count = INIT_PREEMPT_COUNT, \
}
#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* Given a task stack pointer, you can find its corresponding
* thread_info structure just by masking it to the THREAD_SIZE
Expand Down
3 changes: 0 additions & 3 deletions arch/c6x/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* get the thread information struct of current task */
static inline __attribute__((const))
struct thread_info *current_thread_info(void)
Expand Down
2 changes: 0 additions & 2 deletions arch/cris/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ static inline void release_thread(struct task_struct *dead_task)
/* Nothing needs to be done. */
}

#define init_stack (init_thread_union.stack)

#define cpu_relax() barrier()

void default_idle(void);
Expand Down
2 changes: 0 additions & 2 deletions arch/cris/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)

#endif /* !__ASSEMBLY__ */

/*
Expand Down
3 changes: 0 additions & 3 deletions arch/frv/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
register struct thread_info *__current_thread_info asm("gr15");

Expand Down
3 changes: 0 additions & 3 deletions arch/h8300/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
Expand Down
3 changes: 0 additions & 3 deletions arch/hexagon/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ struct thread_info {
.regs = NULL, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* Tacky preprocessor trickery */
#define qqstr(s) qstr(s)
#define qstr(s) #s
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ config IA64
select ARCH_HAVE_NMI_SAFE_CMPXCHG
select GENERIC_IOMAP
select GENERIC_SMP_IDLE_THREAD
select ARCH_INIT_TASK
select ARCH_TASK_STRUCT_ON_STACK
select ARCH_TASK_STRUCT_ALLOCATOR
select ARCH_THREAD_STACK_ALLOCATOR
select ARCH_CLOCKSOURCE_DATA
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $(error Sorry, you need a newer version of the assember, one that is built from
endif

KBUILD_CFLAGS += $(cflags-y)
head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o
head-y := arch/ia64/kernel/head.o

libs-y += arch/ia64/lib/
core-y += arch/ia64/kernel/ arch/ia64/mm/
Expand Down
4 changes: 2 additions & 2 deletions arch/ia64/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <asm/processor.h>
#include <asm/ptrace.h>

#define THREAD_SIZE KERNEL_STACK_SIZE

#ifndef __ASSEMBLY__

/*
Expand Down Expand Up @@ -41,8 +43,6 @@ struct thread_info {
#endif
};

#define THREAD_SIZE KERNEL_STACK_SIZE

#define INIT_THREAD_INFO(tsk) \
{ \
.task = &tsk, \
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ifdef CONFIG_DYNAMIC_FTRACE
CFLAGS_REMOVE_ftrace.o = -pg
endif

extra-y := head.o init_task.o vmlinux.lds
extra-y := head.o vmlinux.lds

obj-y := entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \
irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \
Expand Down
44 changes: 0 additions & 44 deletions arch/ia64/kernel/init_task.c

This file was deleted.

1 change: 1 addition & 0 deletions arch/ia64/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <asm/cache.h>
#include <asm/ptrace.h>
#include <asm/pgtable.h>
#include <asm/thread_info.h>

#include <asm-generic/vmlinux.lds.h>

Expand Down
3 changes: 0 additions & 3 deletions arch/m32r/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
Expand Down
4 changes: 0 additions & 4 deletions arch/m68k/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ struct thread_info {
.preempt_count = INIT_PREEMPT_COUNT, \
}

#define init_stack (init_thread_union.stack)

#ifndef __ASSEMBLY__
/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
Expand All @@ -58,8 +56,6 @@ static inline struct thread_info *current_thread_info(void)
}
#endif

#define init_thread_info (init_thread_union.thread_info)

/* entry.S relies on these definitions!
* bits 0-7 are tested at every exception exit
* bits 8-15 are also tested at syscall exit
Expand Down
3 changes: 0 additions & 3 deletions arch/metag/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the current stack pointer from C */
register unsigned long current_stack_pointer asm("A0StP") __used;

Expand Down
3 changes: 0 additions & 3 deletions arch/microblaze/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
Expand Down
3 changes: 0 additions & 3 deletions arch/mips/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* How to get the thread information struct from C. */
register struct thread_info *__current_thread_info __asm__("$28");

Expand Down
2 changes: 0 additions & 2 deletions arch/mn10300/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)
#define init_uregs \
((struct pt_regs *) \
((unsigned long) init_stack + THREAD_SIZE - sizeof(struct pt_regs)))
Expand Down
3 changes: 0 additions & 3 deletions arch/nios2/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
static inline struct thread_info *current_thread_info(void)
{
Expand Down
2 changes: 0 additions & 2 deletions arch/openrisc/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp);
void release_thread(struct task_struct *);
unsigned long get_wchan(struct task_struct *p);

#define init_stack (init_thread_union.stack)

#define cpu_relax() barrier()

#endif /* __ASSEMBLY__ */
Expand Down
2 changes: 0 additions & 2 deletions arch/openrisc/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ struct thread_info {
.ksp = 0, \
}

#define init_thread_info (init_thread_union.thread_info)

/* how to get the thread information struct from C */
register struct thread_info *current_thread_info_reg asm("r10");
#define current_thread_info() (current_thread_info_reg)
Expand Down
3 changes: 0 additions & 3 deletions arch/parisc/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ struct thread_info {
.preempt_count = INIT_PREEMPT_COUNT, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
#define current_thread_info() ((struct thread_info *)mfctl(30))

Expand Down
3 changes: 0 additions & 3 deletions arch/powerpc/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ struct thread_info {
.flags = 0, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)

/* how to get the thread information struct from C */
Expand Down
2 changes: 0 additions & 2 deletions arch/riscv/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_stack (init_thread_union.stack)

#endif /* !__ASSEMBLY__ */

/*
Expand Down
2 changes: 0 additions & 2 deletions arch/s390/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ struct thread_info {
.flags = 0, \
}

#define init_stack (init_thread_union.stack)

void arch_release_task_struct(struct task_struct *tsk);
int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);

Expand Down
3 changes: 0 additions & 3 deletions arch/score/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* How to get the thread information struct from C. */
register struct thread_info *__current_thread_info __asm__("r28");
#define current_thread_info() __current_thread_info
Expand Down
3 changes: 0 additions & 3 deletions arch/sh/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ struct thread_info {
.addr_limit = KERNEL_DS, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the current stack pointer from C */
register unsigned long current_stack_pointer asm("r15") __used;

Expand Down
3 changes: 0 additions & 3 deletions arch/sparc/include/asm/thread_info_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ struct thread_info {
.preempt_count = INIT_PREEMPT_COUNT, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
register struct thread_info *current_thread_info_reg asm("g6");
#define current_thread_info() (current_thread_info_reg)
Expand Down
3 changes: 0 additions & 3 deletions arch/sparc/include/asm/thread_info_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ struct thread_info {
.preempt_count = INIT_PREEMPT_COUNT, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

/* how to get the thread information struct from C */
register struct thread_info *current_thread_info_reg asm("g6");
#define current_thread_info() (current_thread_info_reg)
Expand Down
3 changes: 0 additions & 3 deletions arch/tile/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ struct thread_info {
.align_ctl = 0, \
}

#define init_thread_info (init_thread_union.thread_info)
#define init_stack (init_thread_union.stack)

#endif /* !__ASSEMBLY__ */

#if PAGE_SIZE < 8192
Expand Down
Loading

0 comments on commit 0500871

Please sign in to comment.