1 #ifndef _ASM_X86_SWITCH_TO_H
2 #define _ASM_X86_SWITCH_TO_H
4 struct task_struct; /* one of the stranger aspects of C forward declarations */
6 struct task_struct *__switch_to_asm(struct task_struct *prev,
7 struct task_struct *next);
9 __visible struct task_struct *__switch_to(struct task_struct *prev,
10 struct task_struct *next);
12 /* This runs runs on the previous thread's stack. */
13 static inline void prepare_switch_to(struct task_struct *prev,
14 struct task_struct *next)
16 #ifdef CONFIG_VMAP_STACK
18 * If we switch to a stack that has a top-level paging entry
19 * that is not present in the current mm, the resulting #PF will
20 * will be promoted to a double-fault and we'll panic. Probe
21 * the new stack now so that vmalloc_fault can fix up the page
22 * tables if needed. This can only happen if we use a stack
25 * We assume that the stack is aligned so that it never spans
26 * more than one top-level paging entry.
28 * To minimize cache pollution, just follow the stack pointer.
30 READ_ONCE(*(unsigned char *)next->thread.sp);
34 asmlinkage void ret_from_fork(void);
36 /* data that is pointed to by thread.sp */
37 struct inactive_task_frame {
50 unsigned long ret_addr;
54 struct inactive_task_frame frame;
58 #define switch_to(prev, next, last) \
60 prepare_switch_to(prev, next); \
62 ((last) = __switch_to_asm((prev), (next))); \
65 #endif /* _ASM_X86_SWITCH_TO_H */