1 #ifndef _X86_64_CURRENT_H
2 #define _X86_64_CURRENT_H
4 #if !defined(__ASSEMBLY__)
10 * In normal operation, the current task pointer is read directly from
13 * If the PDA has not been setup or is not available for some reason,
14 * the slower get_current_via_RSP() must be used instead. This is
15 * sometimes necessary during the bootstrap process.
17 static inline struct task_struct *
20 struct task_struct *t = read_pda(pcurrent);
23 #define current get_current()
26 * Derives the current task pointer from the current value of the
27 * stack pointer (RSP register).
29 * WARNING: Do not call this from interrupt context. It won't work.
30 * It is only safe to call this from task context.
32 static inline struct task_struct *
33 get_current_via_RSP(void)
35 struct task_struct *tsk;
36 __asm__("andq %%rsp,%0; " : "=r" (tsk) : "0" (~(TASK_SIZE - 1)));
43 #include <arch/asm-offsets.h>
46 #define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg
50 #endif /* !(_X86_64_CURRENT_H) */