diff options
author | Dave Hansen <dave.hansen@intel.com> | 2017-11-06 17:29:55 -0800 |
---|---|---|
committer | Dave Hansen <dave.hansen@intel.com> | 2017-11-06 17:29:55 -0800 |
commit | 782adc82c16ea795972463cd34e0a11d59f8bae5 (patch) | |
tree | c4a213e55c87a60ac5a26804efa88b973c9ca7b9 | |
parent | e8bbf6923dd0ace0de16ae302c6f9b7ad5c81308 (diff) | |
download | x86-kaiser-782adc82c16ea795972463cd34e0a11d59f8bae5.tar.gz |
x86, kaiser: map entry stack variables
From: Dave Hansen <dave.hansen@linux.intel.com>
There are times that we enter the kernel and do not have a safe
stack, like at SYSCALL entry. We use the per-cpu vairables
'rsp_scratch' and 'cpu_current_top_of_stack' to save off the old
%rsp and find a safe place to have a stack.
You can not directly manipulate the CR3 register. You can only
'MOV' to it from another register, which means we need to clobber
a register in order to do any CR3 manipulation. User-mapping these
variables allows us to obtain a safe stack *before* we switch the
CR3 value.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Moritz Lipp <moritz.lipp@iaik.tugraz.at>
Cc: Daniel Gruss <daniel.gruss@iaik.tugraz.at>
Cc: Michael Schwarz <michael.schwarz@iaik.tugraz.at>
Cc: Richard Fellner <richard.fellner@student.tugraz.at>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Kees Cook <keescook@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: x86@kernel.org
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/process_64.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 0054887900dbf5..6031fd726bd237 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1447,7 +1447,7 @@ DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary); * trampoline, not the thread stack. Use an extra percpu variable to track * the top of the kernel stack directly. */ -DEFINE_PER_CPU(unsigned long, cpu_current_top_of_stack) = +DEFINE_PER_CPU_USER_MAPPED(unsigned long, cpu_current_top_of_stack) = (unsigned long)&init_thread_union + THREAD_SIZE; EXPORT_PER_CPU_SYMBOL(cpu_current_top_of_stack); diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index d8dcdb01094f31..0e9972e0005c7a 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -59,7 +59,7 @@ #include <asm/unistd_32_ia32.h> #endif -__visible DEFINE_PER_CPU(unsigned long, rsp_scratch); +__visible DEFINE_PER_CPU_USER_MAPPED(unsigned long, rsp_scratch); /* Prints also some state that isn't saved in the pt_regs */ void __show_regs(struct pt_regs *regs, int all) |