Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63332a84 authored by Denys Vlasenko's avatar Denys Vlasenko Committed by Ingo Molnar
Browse files

x86/entry: Stop using PER_CPU_VAR(kernel_stack)



PER_CPU_VAR(kernel_stack) is redundant:

  - On the 64-bit build, we can use PER_CPU_VAR(cpu_tss + TSS_sp0).
  - On the 32-bit build, we can use PER_CPU_VAR(cpu_current_top_of_stack).

PER_CPU_VAR(kernel_stack) will be deleted by a separate change.

Signed-off-by: default avatarDenys Vlasenko <dvlasenk@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1429889495-27850-1-git-send-email-dvlasenk@redhat.com


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent e22438f8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ ENTRY(ia32_cstar_target)
	SWAPGS_UNSAFE_STACK
	movl	%esp,%r8d
	CFI_REGISTER	rsp,r8
	movq	PER_CPU_VAR(kernel_stack),%rsp
	movq	PER_CPU_VAR(cpu_tss + TSS_sp0),%rsp
	ENABLE_INTERRUPTS(CLBR_NONE)

	/* Zero-extending 32-bit regs, do not remove */
+7 −1
Original line number Diff line number Diff line
@@ -198,9 +198,15 @@ static inline unsigned long current_stack_pointer(void)
#else /* !__ASSEMBLY__ */

/* Load thread_info address into "reg" */
#ifdef CONFIG_X86_32
#define GET_THREAD_INFO(reg) \
	_ASM_MOV PER_CPU_VAR(kernel_stack),reg ; \
	_ASM_MOV PER_CPU_VAR(cpu_current_top_of_stack),reg ; \
	_ASM_SUB $(THREAD_SIZE),reg ;
#else
#define GET_THREAD_INFO(reg) \
	_ASM_MOV PER_CPU_VAR(cpu_tss + TSS_sp0),reg ; \
	_ASM_SUB $(THREAD_SIZE),reg ;
#endif

/*
 * ASM operand which evaluates to a 'thread_info' address of
+1 −1
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ ENTRY(system_call)
GLOBAL(system_call_after_swapgs)

	movq	%rsp,PER_CPU_VAR(rsp_scratch)
	movq	PER_CPU_VAR(kernel_stack),%rsp
	movq	PER_CPU_VAR(cpu_tss + TSS_sp0),%rsp

	/* Construct struct pt_regs on stack */
	pushq_cfi $__USER_DS			/* pt_regs->ss */
+3 −2
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <asm/percpu.h>
#include <asm/processor-flags.h>
#include <asm/segment.h>
#include <asm/asm-offsets.h>

#include <xen/interface/xen.h>

@@ -53,7 +54,7 @@ ENTRY(xen_sysret64)
	 * still with the kernel gs, so we can easily switch back
	 */
	movq %rsp, PER_CPU_VAR(rsp_scratch)
	movq PER_CPU_VAR(kernel_stack), %rsp
	movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp

	pushq $__USER_DS
	pushq PER_CPU_VAR(rsp_scratch)
@@ -72,7 +73,7 @@ ENTRY(xen_sysret32)
	 * still with the kernel gs, so we can easily switch back
	 */
	movq %rsp, PER_CPU_VAR(rsp_scratch)
	movq PER_CPU_VAR(kernel_stack), %rsp
	movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp

	pushq $__USER32_DS
	pushq PER_CPU_VAR(rsp_scratch)