4 #include <asm/segment.h>
5 #include <asm/cmpxchg.h>
9 /* entries in ARCH_DLINFO: */
10 #ifdef CONFIG_IA32_EMULATION
11 # define AT_VECTOR_SIZE_ARCH 2
13 # define AT_VECTOR_SIZE_ARCH 1
16 #define __SAVE(reg,offset) "movq %%" #reg ",(14-" #offset ")*8(%%rsp)\n\t"
17 #define __RESTORE(reg,offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t"
19 /* frame pointer must be last for get_wchan */
20 #define SAVE_CONTEXT "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t"
21 #define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t"
23 #define __EXTRA_CLOBBER \
24 ,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15"
26 /* Save restore flags to clear handle leaking NT */
27 #define switch_to(prev,next,last) \
28 asm volatile(SAVE_CONTEXT \
29 "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \
30 "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \
31 "call __switch_to\n\t" \
32 ".globl thread_return\n" \
33 "thread_return:\n\t" \
34 "movq %%gs:%P[pda_pcurrent],%%rsi\n\t" \
35 "movq %P[thread_info](%%rsi),%%r8\n\t" \
36 LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \
37 "movq %%rax,%%rdi\n\t" \
38 "jc ret_from_fork\n\t" \
41 : [next] "S" (next), [prev] "D" (prev), \
42 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
43 [ti_flags] "i" (offsetof(struct thread_info, flags)),\
44 [tif_fork] "i" (TIF_FORK), \
45 [thread_info] "i" (offsetof(struct task_struct, stack)), \
46 [pda_pcurrent] "i" (offsetof(struct x8664_pda, pcurrent)) \
47 : "memory", "cc" __EXTRA_CLOBBER)
49 #endif /* __KERNEL__ */
51 static inline unsigned long read_cr8(void)
54 asm volatile("movq %%cr8,%0" : "=r" (cr8));
58 static inline void write_cr8(unsigned long val)
60 asm volatile("movq %0,%%cr8" :: "r" (val) : "memory");
63 #include <linux/irqflags.h>