diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-12-01 10:32:48 +0100 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-12-17 12:58:53 +0100 |
commit | 0fd2e9c53d82704a3ba87ea1980ec515188c5316 (patch) | |
tree | a828c396110053feba9e65307a4e802b00966519 /arch/x86/include/asm/switch_to.h | |
parent | drivers/misc/intel/pti: Rename the header file to free up the namespace (diff) | |
parent | x86/entry/64: Shorten TEST instructions (diff) | |
download | linux-0fd2e9c53d82704a3ba87ea1980ec515188c5316.tar.xz linux-0fd2e9c53d82704a3ba87ea1980ec515188c5316.zip |
Merge commit 'upstream-x86-entry' into WIP.x86/mm
Pull in a minimal set of v4.15 entry code changes, for a base for the MM isolation patches.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/include/asm/switch_to.h')
-rw-r--r-- | arch/x86/include/asm/switch_to.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h index 899084b70412..8c6bd6863db9 100644 --- a/arch/x86/include/asm/switch_to.h +++ b/arch/x86/include/asm/switch_to.h @@ -2,6 +2,8 @@ #ifndef _ASM_X86_SWITCH_TO_H #define _ASM_X86_SWITCH_TO_H +#include <linux/sched/task_stack.h> + struct task_struct; /* one of the stranger aspects of C forward declarations */ struct task_struct *__switch_to_asm(struct task_struct *prev, @@ -73,4 +75,26 @@ do { \ ((last) = __switch_to_asm((prev), (next))); \ } while (0) +#ifdef CONFIG_X86_32 +static inline void refresh_sysenter_cs(struct thread_struct *thread) +{ + /* Only happens when SEP is enabled, no need to test "SEP"arately: */ + if (unlikely(this_cpu_read(cpu_tss.x86_tss.ss1) == thread->sysenter_cs)) + return; + + this_cpu_write(cpu_tss.x86_tss.ss1, thread->sysenter_cs); + wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0); +} +#endif + +/* This is used when switching tasks or entering/exiting vm86 mode. */ +static inline void update_sp0(struct task_struct *task) +{ +#ifdef CONFIG_X86_32 + load_sp0(task->thread.sp0); +#else + load_sp0(task_top_of_stack(task)); +#endif +} + #endif /* _ASM_X86_SWITCH_TO_H */ |