6caae6e7a7a5d4e338524f69eb7dc78ca34bdc08
1 #ifndef UST_PROCESSOR_H
2 #define UST_PROCESSOR_H
7 extern __thread
long ust_reg_stack
[500];
8 extern volatile __thread
long *ust_reg_stack_ptr
;
12 #error "32-bit support broken"
33 static inline save_registers(struct registers
*regs
)
37 #define RELATIVE_ADDRESS(__rel_label__) __rel_label__
39 #define _ASM_PTR ".long "
44 int padding
; /* 4 bytes */
66 #define save_registers(regsptr) \
68 /* save original rsp */ \
70 /* push original rflags */ \
72 /* rax will hold the ptr to the private stack bottom */ \
74 /* rbx will be used to temporarily hold the stack bottom addr */ \
76 /* rdi is the input to __tls_get_addr, and also a temp var */ \
78 /* Start TLS access of private reg stack pointer */ \
80 "leaq ust_reg_stack_ptr@tlsgd(%%rip), %%rdi\n\t" \
83 "call __tls_get_addr@plt\n\t" \
84 /* --- End TLS access */ \
85 /* check if ust_reg_stack_ptr has been initialized */ \
86 "movq (%%rax),%%rbx\n\t" \
87 "testq %%rbx,%%rbx\n\t" \
89 "movq %%rax,%%rbx\n\t" \
90 /* Start TLS access of private reg stack */ \
92 "leaq ust_reg_stack@tlsgd(%%rip), %%rdi\n\t" \
95 "call __tls_get_addr@plt\n\t" \
96 /* --- End TLS access */ \
97 "addq $500,%%rax\n\t" \
98 "movq %%rax,(%%rbx)\n\t" \
99 "movq %%rbx,%%rax\n\t" \
100 /* now the pointer to the private stack is in rax.
101 must add stack size so the ptr points to the stack bottom. */ \
103 /* Manually push rsp to private stack */ \
104 "addq $-8,(%%rax)\n\t" \
105 "movq 32(%%rsp), %%rdi\n\t" \
106 "movq (%%rax), %%rbx\n\t" \
107 "movq %%rdi, (%%rbx)\n\t" \
108 /* Manually push eflags to private stack */ \
109 "addq $-8,(%%rax)\n\t" \
110 "movq 24(%%rsp), %%rdi\n\t" \
111 "movq (%%rax), %%rbx\n\t" \
112 "movq %%rdi, (%%rbx)\n\t" \
113 /* Manually push rax to private stack */ \
114 "addq $-8,(%%rax)\n\t" \
115 "movq 16(%%rsp), %%rdi\n\t" \
116 "movq (%%rax), %%rbx\n\t" \
117 "movq %%rdi, (%%rbx)\n\t" \
118 /* Manually push rbx to private stack */ \
119 "addq $-8,(%%rax)\n\t" \
120 "movq 8(%%rsp), %%rdi\n\t" \
121 "movq (%%rax), %%rbx\n\t" \
122 "movq %%rdi, (%%rbx)\n\t" \
123 /* Manually push rdi to private stack */ \
124 "addq $-8,(%%rax)\n\t" \
125 "movq 0(%%rsp), %%rdi\n\t" \
126 "movq (%%rax), %%rbx\n\t" \
127 "movq %%rdi, (%%rbx)\n\t" \
128 /* now push regs to tls */ \
129 /* -- rsp already pushed -- */ \
130 /* -- rax already pushed -- */ \
131 /* -- rbx already pushed -- */ \
132 /* -- rdi already pushed -- */ \
133 "addq $-8,(%%rax)\n\t" \
134 "movq (%%rax), %%rbx\n\t" \
135 "movq %%rcx,(%%rbx)\n\t" \
136 "addq $-8,(%%rax)\n\t" \
137 "movq (%%rax), %%rbx\n\t" \
138 "movq %%rdx,(%%rbx)\n\t" \
139 "addq $-8,(%%rax)\n\t" \
140 "movq (%%rax), %%rbx\n\t" \
141 "movq %%rbp,(%%rbx)\n\t" \
142 "addq $-8,(%%rax)\n\t" \
143 "movq (%%rax), %%rbx\n\t" \
144 "movq %%rsi,(%%rbx)\n\t" \
145 "addq $-8,(%%rax)\n\t" \
146 "movq (%%rax), %%rbx\n\t" \
147 "movq %%r8,(%%rbx)\n\t" \
148 "addq $-8,(%%rax)\n\t" \
149 "movq (%%rax), %%rbx\n\t" \
150 "movq %%r9,(%%rbx)\n\t" \
151 "addq $-8,(%%rax)\n\t" \
152 "movq (%%rax), %%rbx\n\t" \
153 "movq %%r10,(%%rbx)\n\t" \
154 "addq $-8,(%%rax)\n\t" \
155 "movq (%%rax), %%rbx\n\t" \
156 "movq %%r11,(%%rbx)\n\t" \
157 "addq $-8,(%%rax)\n\t" \
158 "movq (%%rax), %%rbx\n\t" \
159 "movq %%r12,(%%rbx)\n\t" \
160 "addq $-8,(%%rax)\n\t" \
161 "movq (%%rax), %%rbx\n\t" \
162 "movq %%r13,(%%rbx)\n\t" \
163 "addq $-8,(%%rax)\n\t" \
164 "movq (%%rax), %%rbx\n\t" \
165 "movq %%r14,(%%rbx)\n\t" \
166 "addq $-8,(%%rax)\n\t" \
167 "movq (%%rax), %%rbx\n\t" \
168 "movq %%r15,(%%rbx)\n\t" \
170 "addq $-2,(%%rax)\n\t" \
171 "movq (%%rax), %%rbx\n\t" \
172 "movw %%cs, (%%rbx)\n\t" \
174 "addq $-2,(%%rax)\n\t" \
175 "movq (%%rax), %%rbx\n\t" \
176 "movw %%ss, (%%rbx)\n\t" \
177 /* add padding for struct registers */ \
178 "addq $-4,(%%rax)\n\t" \
179 /* restore original values of regs that were used internally */ \
183 /* cancel push of rsp */ \
184 "addq $8,%%rsp\n\t" \
185 /* cancel push of rflags */ \
186 "addq $8,%%rsp\n\t" \
188 memcpy(regsptr, (void *)ust_reg_stack_ptr, sizeof(struct registers)); \
189 ust_reg_stack_ptr = (void *)(((long)ust_reg_stack_ptr) + sizeof(struct registers));
191 /* Macro to insert the address of a relative jump in an assembly stub,
192 * in a relocatable way. On x86-64, this uses a special (%rip) notation. */
193 #define RELATIVE_ADDRESS(__rel_label__) __rel_label__(%%rip)
195 #define _ASM_PTR ".quad "
199 #endif /* UST_PROCESSOR_H */
This page took 0.038784 seconds and 3 git commands to generate.