hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/x86/include/asm/switch_to.h
....@@ -12,27 +12,6 @@
1212 __visible struct task_struct *__switch_to(struct task_struct *prev,
1313 struct task_struct *next);
1414
15
-/* This runs runs on the previous thread's stack. */
16
-static inline void prepare_switch_to(struct task_struct *next)
17
-{
18
-#ifdef CONFIG_VMAP_STACK
19
- /*
20
- * If we switch to a stack that has a top-level paging entry
21
- * that is not present in the current mm, the resulting #PF will
22
- * will be promoted to a double-fault and we'll panic. Probe
23
- * the new stack now so that vmalloc_fault can fix up the page
24
- * tables if needed. This can only happen if we use a stack
25
- * in vmap space.
26
- *
27
- * We assume that the stack is aligned so that it never spans
28
- * more than one top-level paging entry.
29
- *
30
- * To minimize cache pollution, just follow the stack pointer.
31
- */
32
- READ_ONCE(*(unsigned char *)next->thread.sp);
33
-#endif
34
-}
35
-
3615 asmlinkage void ret_from_fork(void);
3716
3817 /*
....@@ -40,13 +19,13 @@
4019 * order of the fields must match the code in __switch_to_asm().
4120 */
4221 struct inactive_task_frame {
43
- unsigned long flags;
4422 #ifdef CONFIG_X86_64
4523 unsigned long r15;
4624 unsigned long r14;
4725 unsigned long r13;
4826 unsigned long r12;
4927 #else
28
+ unsigned long flags;
5029 unsigned long si;
5130 unsigned long di;
5231 #endif
....@@ -67,8 +46,6 @@
6746
6847 #define switch_to(prev, next, last) \
6948 do { \
70
- prepare_switch_to(next); \
71
- \
7249 ((last) = __switch_to_asm((prev), (next))); \
7350 } while (0)
7451
....@@ -103,7 +80,17 @@
10380 if (static_cpu_has(X86_FEATURE_XENPV))
10481 load_sp0(task_top_of_stack(task));
10582 #endif
83
+}
10684
85
+static inline void kthread_frame_init(struct inactive_task_frame *frame,
86
+ unsigned long fun, unsigned long arg)
87
+{
88
+ frame->bx = fun;
89
+#ifdef CONFIG_X86_32
90
+ frame->di = arg;
91
+#else
92
+ frame->r12 = arg;
93
+#endif
10794 }
10895
10996 #endif /* _ASM_X86_SWITCH_TO_H */