Revert "BACKPORT: arm64: split thread_info from task stack"

This reverts commit ffa81d2e8b718f8aeb332b91d6fcf5ea4db34e27.
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index b788d0d..0727e05 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -98,7 +98,6 @@
 	select SPARSE_IRQ
 	select SYSCTL_EXCEPTION_TRACE
 	select HAVE_CONTEXT_TRACKING
-	select THREAD_INFO_IN_TASK
 	help
 	  ARM 64-bit (AArch64) Linux support.
 
diff --git a/arch/arm64/include/asm/current.h b/arch/arm64/include/asm/current.h
deleted file mode 100644
index 2e61d21..0000000
--- a/arch/arm64/include/asm/current.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __ASM_CURRENT_H
-#define __ASM_CURRENT_H
-
-#include <linux/compiler.h>
-
-#include <asm/sysreg.h>
-
-#ifndef __ASSEMBLY__
-
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-struct task_struct;
-
-static __always_inline struct task_struct *get_current(void)
-{
-	return (struct task_struct *)read_sysreg(sp_el0);
-}
-#define current get_current()
-#else
-#include <linux/thread_info.h>
-#define get_current() (current_thread_info()->task)
-#define current get_current()
-#endif
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* __ASM_CURRENT_H */
-
diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
index 9c0e5dc..2013a4d 100644
--- a/arch/arm64/include/asm/smp.h
+++ b/arch/arm64/include/asm/smp.h
@@ -57,9 +57,6 @@
  */
 struct secondary_data {
 	void *stack;
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	struct task_struct *task;
-#endif
 };
 extern struct secondary_data secondary_data;
 extern void secondary_entry(void);
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index eb9545a..794d226 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -47,25 +47,14 @@
 struct thread_info {
 	unsigned long		flags;		/* low level flags */
 	mm_segment_t		addr_limit;	/* address limit */
-#ifndef CONFIG_THREAD_INFO_IN_TASK
 	struct task_struct	*task;		/* main task structure */
-#endif
 #ifdef CONFIG_ARM64_SW_TTBR0_PAN
 	u64			ttbr0;		/* saved TTBR0_EL1 */
 #endif
 	int			preempt_count;	/* 0 => preemptable, <0 => bug */
-#ifndef CONFIG_THREAD_INFO_IN_TASK
 	int			cpu;		/* cpu */
-#endif
 };
 
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-#define INIT_THREAD_INFO(tsk)						\
-{									\
-	.preempt_count	= INIT_PREEMPT_COUNT,				\
-	.addr_limit	= KERNEL_DS,					\
-}
-#else
 #define INIT_THREAD_INFO(tsk)						\
 {									\
 	.task		= &tsk,						\
@@ -75,6 +64,7 @@
 }
 
 #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
@@ -97,9 +87,6 @@
 
 	return (struct thread_info *)sp_el0;
 }
-#endif
-
-#define init_stack		(init_thread_union.stack)
 
 #define thread_saved_pc(tsk)	\
 	((unsigned long)(tsk->thread.cpu_context.pc))
diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
index 6e722d8..ef8b4b3 100644
--- a/arch/arm64/kernel/asm-offsets.c
+++ b/arch/arm64/kernel/asm-offsets.c
@@ -34,16 +34,11 @@
 {
   DEFINE(TSK_ACTIVE_MM,		offsetof(struct task_struct, active_mm));
   BLANK();
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-  DEFINE(TSK_TI_FLAGS,		offsetof(struct task_struct, thread_info.flags));
-  DEFINE(TSK_TI_PREEMPT,	offsetof(struct task_struct, thread_info.preempt_count));
-  DEFINE(TSK_TI_ADDR_LIMIT,	offsetof(struct task_struct, thread_info.addr_limit));
-  DEFINE(TSK_STACK,		offsetof(struct task_struct, stack));
-#else
   DEFINE(TI_FLAGS,		offsetof(struct thread_info, flags));
   DEFINE(TI_PREEMPT,		offsetof(struct thread_info, preempt_count));
   DEFINE(TI_ADDR_LIMIT,		offsetof(struct thread_info, addr_limit));
-#endif
+  DEFINE(TI_TASK,		offsetof(struct thread_info, task));
+  DEFINE(TI_CPU,		offsetof(struct thread_info, cpu));
 #ifdef CONFIG_ARM64_SW_TTBR0_PAN
   DEFINE(TSK_TI_TTBR0,		offsetof(struct thread_info, ttbr0));
 #endif
@@ -113,11 +108,6 @@
   DEFINE(TZ_MINWEST,		offsetof(struct timezone, tz_minuteswest));
   DEFINE(TZ_DSTTIME,		offsetof(struct timezone, tz_dsttime));
   BLANK();
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-  DEFINE(CPU_BOOT_STACK,	offsetof(struct secondary_data, stack));
-  DEFINE(CPU_BOOT_TASK,		offsetof(struct secondary_data, task));
-  BLANK();
-#endif
 #ifdef CONFIG_KVM_ARM_HOST
   DEFINE(VCPU_CONTEXT,		offsetof(struct kvm_vcpu, arch.ctxt));
   DEFINE(CPU_GP_REGS,		offsetof(struct kvm_cpu_context, gp_regs));
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index a82f14f..bcc6a85 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -116,14 +116,9 @@
 
 	.if	\el == 0
 	mrs	x21, sp_el0
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	ldr_this_cpu	tsk, __entry_task, x20	// Ensure MDSCR_EL1.SS is clear,
-	ldr	x19, [tsk, #TSK_TI_FLAGS]	// since we can unmask debug
-#else
 	mov	tsk, sp
 	and	tsk, tsk, #~(THREAD_SIZE - 1)	// Ensure MDSCR_EL1.SS is clear,
 	ldr	x19, [tsk, #TI_FLAGS]		// since we can unmask debug
-#endif
 	disable_step_tsk x19, x20		// exceptions when scheduling.
 
 	mov	x29, xzr			// fp pointed to user-space
@@ -131,18 +126,10 @@
 	add	x21, sp, #S_FRAME_SIZE
 	get_thread_info tsk
 	/* Save the task's original addr_limit and set USER_DS (TASK_SIZE_64) */
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	ldr	x20, [tsk, #TSK_TI_ADDR_LIMIT]
-#else
 	ldr	x20, [tsk, #TI_ADDR_LIMIT]
-#endif
 	str	x20, [sp, #S_ORIG_ADDR_LIMIT]
 	mov	x20, #TASK_SIZE_64
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	str	x20, [tsk, #TSK_TI_ADDR_LIMIT]
-#else
 	str	x20, [tsk, #TI_ADDR_LIMIT]
-#endif
 	ALTERNATIVE(nop, SET_PSTATE_UAO(0), ARM64_HAS_UAO, CONFIG_ARM64_UAO)
 	.endif /* \el == 0 */
 	mrs	x22, elr_el1
@@ -204,11 +191,7 @@
 	.if	\el != 0
 	/* Restore the task's original addr_limit. */
 	ldr	x20, [sp, #S_ORIG_ADDR_LIMIT]
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	str	x20, [tsk, #TSK_TI_ADDR_LIMIT]
-#else
 	str	x20, [tsk, #TI_ADDR_LIMIT]
-#endif
 
 	/* No need to restore UAO, it will be restored from SPSR_EL1 */
 	.endif
@@ -308,20 +291,13 @@
 	mov	x19, sp			// preserve the original sp
 
 	/*
-	 * Compare sp with the base of the task stack.
-	 * If the top ~(THREAD_SIZE - 1) bits match, we are on a task stack,
-	 * and should switch to the irq stack.
+	 * Compare sp with the current thread_info, if the top
+	 * ~(THREAD_SIZE - 1) bits match, we are on a task stack, and
+	 * should switch to the irq stack.
 	 */
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	ldr	x25, [tsk, TSK_STACK]
-	eor	x25, x25, x19
-	and	x25, x25, #~(THREAD_SIZE - 1)
-	cbnz	x25, 9998f
-#else
 	and	x25, x19, #~(THREAD_SIZE - 1)
 	cmp	x25, tsk
 	b.ne	9998f
-#endif
 
 	this_cpu_ptr irq_stack, x25, x26
 	mov	x26, #IRQ_STACK_START_SP
@@ -549,17 +525,9 @@
 	irq_handler
 
 #ifdef CONFIG_PREEMPT
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	ldr	w24, [tsk, #TSK_TI_PREEMPT]	// get preempt count
-#else
 	ldr	w24, [tsk, #TI_PREEMPT]		// get preempt count
-#endif
 	cbnz	w24, 1f				// preempt count != 0
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	ldr	x0, [tsk, #TSK_TI_FLAGS]	// get flags
-#else
 	ldr	x0, [tsk, #TI_FLAGS]		// get flags
-#endif
 	tbz	x0, #TIF_NEED_RESCHED, 1f	// needs rescheduling?
 	bl	el1_preempt
 1:
@@ -574,11 +542,7 @@
 el1_preempt:
 	mov	x24, lr
 1:	bl	preempt_schedule_irq		// irq en/disable is done inside
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	ldr	x0, [tsk, #TSK_TI_FLAGS]	// get new tasks TI_FLAGS
-#else
 	ldr	x0, [tsk, #TI_FLAGS]		// get new tasks TI_FLAGS
-#endif
 	tbnz	x0, #TIF_NEED_RESCHED, 1b	// needs rescheduling?
 	ret	x24
 #endif
@@ -798,12 +762,8 @@
 	ldp	x29, x9, [x8], #16
 	ldr	lr, [x8]
 	mov	sp, x9
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	msr	sp_el0, x1
-#else
 	and	x9, x9, #~(THREAD_SIZE - 1)
 	msr	sp_el0, x9
-#endif
 	ret
 ENDPROC(cpu_switch_to)
 
@@ -814,11 +774,7 @@
 ret_fast_syscall:
 	disable_irq				// disable interrupts
 	str	x0, [sp, #S_X0]			// returned x0
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	ldr	x1, [tsk, #TSK_TI_FLAGS]	// re-check for syscall tracing
-#else
 	ldr	x1, [tsk, #TI_FLAGS]		// re-check for syscall tracing
-#endif
 	and	x2, x1, #_TIF_SYSCALL_WORK
 	cbnz	x2, ret_fast_syscall_trace
 	and	x2, x1, #_TIF_WORK_MASK
@@ -850,11 +806,7 @@
  */
 ret_to_user:
 	disable_irq				// disable interrupts
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	ldr	x1, [tsk, #TSK_TI_FLAGS]
-#else
 	ldr	x1, [tsk, #TI_FLAGS]
-#endif
 	and	x2, x1, #_TIF_WORK_MASK
 	cbnz	x2, work_pending
 	enable_step_tsk x1, x2
@@ -886,11 +838,7 @@
 	enable_dbg_and_irq
 	ct_user_exit 1
 
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	ldr	x16, [tsk, #TSK_TI_FLAGS]	// check for syscall hooks
-#else
 	ldr	x16, [tsk, #TI_FLAGS]		// check for syscall hooks
-#endif
 	tst	x16, #_TIF_SYSCALL_WORK
 	b.ne	__sys_trace
 	cmp     scno, sc_nr                     // check upper syscall limit
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 4ddecd0..461d6cc 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -424,7 +424,6 @@
 	.set	initial_sp, init_thread_union + THREAD_START_SP
 __mmap_switched:
 	mov	x28, lr				// preserve LR
-
 	adr_l	x8, vectors			// load VBAR_EL1 with virtual
 	msr	vbar_el1, x8			// vector table address
 	isb
@@ -475,18 +474,10 @@
 	dsb	sy				// with MMU off
 #endif
 
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-        adrp    x4, init_thread_union
-        add     sp, x4, #THREAD_SIZE
-        adr_l   x5, init_task
-        msr     sp_el0, x5                      // Save thread_info
-#else
 	adr_l	sp, initial_sp, x4
 	mov	x4, sp
 	and	x4, x4, #~(THREAD_SIZE - 1)
 	msr	sp_el0, x4			// Save thread_info
-#endif
-
 	str_l	x21, __fdt_pointer, x5		// Save FDT pointer
 
 	ldr_l	x4, kimage_vaddr		// Save the offset between
@@ -697,18 +688,11 @@
 	adr_l	x5, vectors
 	msr	vbar_el1, x5
 	isb
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	adr_l	x0, secondary_data
-	ldr	x1, [x0, #CPU_BOOT_STACK]	// get secondary_data.stack
-	mov	sp, x1
-	ldr	x2, [x0, #CPU_BOOT_TASK]
-	msr	sp_el0, x2
-#else
+
 	ldr_l	x0, secondary_data		// get secondary_data.stack
 	mov	sp, x0
 	and	x0, x0, #~(THREAD_SIZE - 1)
 	msr	sp_el0, x0			// save thread_info
-#endif
 	mov	x29, #0
 	b	secondary_start_kernel
 ENDPROC(__secondary_switched)
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index ebef72a..e96c696 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -45,9 +45,6 @@
 #include <linux/personality.h>
 #include <linux/notifier.h>
 #include <trace/events/power.h>
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-#include <linux/percpu.h>
-#endif
 
 #include <asm/alternative.h>
 #include <asm/compat.h>
@@ -390,22 +387,6 @@
 	}
 }
 
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-/*
- * We store our current task in sp_el0, which is clobbered by userspace. Keep a
- * shadow copy so that we can restore this upon entry from userspace.
- *
- * This is *only* for exception entry from EL0, and is not valid until we
- * __switch_to() a user task.
- */
-DEFINE_PER_CPU(struct task_struct *, __entry_task);
-
-static void entry_task_switch(struct task_struct *next)
-{
-	__this_cpu_write(__entry_task, next);
-}
-#endif
-
 /*
  * Thread switching.
  */
@@ -418,9 +399,6 @@
 	tls_thread_switch(next);
 	hw_breakpoint_thread_switch(next);
 	contextidr_thread_switch(next);
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	entry_task_switch(next);
-#endif
 	uao_thread_switch(next);
 
 	/*
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 17198b7..24cb4f8 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -95,9 +95,6 @@
 	 * We need to tell the secondary core where to find its stack and the
 	 * page tables.
 	 */
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	secondary_data.task = idle;
-#endif
 	secondary_data.stack = task_stack_page(idle) + THREAD_START_SP;
 	__flush_dcache_area(&secondary_data, sizeof(secondary_data));
 
@@ -121,9 +118,6 @@
 		pr_err("CPU%u: failed to boot: %d\n", cpu, ret);
 	}
 
-#ifdef CONFIG_THREAD_INFO_IN_TASK
-	secondary_data.task = NULL;
-#endif
 	secondary_data.stack = NULL;
 
 	return ret;