-#ifdef CONFIG_UST_GDB_INTEGRATION
-
-#define save_registers(regsptr) \
- asm volatile ( \
- /* save original rsp */ \
- "pushq %%rsp\n\t" \
- /* push original rflags */ \
- "pushfq\n\t" \
- /* rax will hold the ptr to the private stack bottom */ \
- "pushq %%rax\n\t" \
- /* rbx will be used to temporarily hold the stack bottom addr */ \
- "pushq %%rbx\n\t" \
- /* rdi is the input to __tls_get_addr, and also a temp var */ \
- "pushq %%rdi\n\t" \
- /* For TLS access, we have to do function calls. However, \
- * we must not lose the original value of: \
- * rsp, rflags, rax, rbx, rcx, rdx, rsi, rdi, rbp, r8, r9 \
- * r10, r11, r12, r13, r14, r15, cs, ss \
- * \
- * Some registers' original values have already been saved: \
- * rsp, rflags, rax, rbx, rdi \
- * \
- * In addition, the x86-64 ABI says the following registers \
- * belong to the caller function: \
- * rbp, rbx, r12, r13, r14, r15 \
- * \
- * The following registers should not be changed by the callee: \
- * cs, ss \
- * \
- * Therefore, the following registers must be explicitly \
- * preserved: \
- * rcx, rdx, rsi, r8, r9, r10, r11 \
- */ \
- "pushq %%rcx\n\t" \
- "pushq %%rdx\n\t" \
- "pushq %%rsi\n\t" \
- "pushq %%r8\n\t" \
- "pushq %%r9\n\t" \
- "pushq %%r10\n\t" \
- "pushq %%r11\n\t" \
- /* Start TLS access of private reg stack pointer */ \
- ".byte 0x66\n\t" \
- "leaq ust_reg_stack_ptr@tlsgd(%%rip), %%rdi\n\t" \
- ".hword 0x6666\n\t" \
- "rex64\n\t" \
- "call __tls_get_addr@plt\n\t" \
- /* --- End TLS access */ \
- /* check if ust_reg_stack_ptr has been initialized */ \
- "movq (%%rax),%%rbx\n\t" \
- "testq %%rbx,%%rbx\n\t" \
- "jne 1f\n\t" \
- "movq %%rax,%%rbx\n\t" \
- /* Start TLS access of private reg stack */ \
- ".byte 0x66\n\t" \
- "leaq ust_reg_stack@tlsgd(%%rip), %%rdi\n\t" \
- ".hword 0x6666\n\t" \
- "rex64\n\t" \
- "call __tls_get_addr@plt\n\t" \
- /* --- End TLS access */ \
- "addq $500,%%rax\n\t" \
- "movq %%rax,(%%rbx)\n\t" \
- "movq %%rbx,%%rax\n\t" \
- /* now the pointer to the private stack is in rax.
- must add stack size so the ptr points to the stack bottom. */ \
- "1:\n\t" \
- /* Pop regs that were pushed for function calls */ \
- "popq %%r11\n\t" \
- "popq %%r10\n\t" \
- "popq %%r9\n\t" \
- "popq %%r8\n\t" \
- "popq %%rsi\n\t" \
- "popq %%rdx\n\t" \
- "popq %%rcx\n\t" \
- /* Manually push rsp to private stack */ \
- "addq $-8,(%%rax)\n\t" \
- "movq 32(%%rsp), %%rdi\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%rdi, (%%rbx)\n\t" \
- /* Manually push eflags to private stack */ \
- "addq $-8,(%%rax)\n\t" \
- "movq 24(%%rsp), %%rdi\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%rdi, (%%rbx)\n\t" \
- /* Manually push rax to private stack */ \
- "addq $-8,(%%rax)\n\t" \
- "movq 16(%%rsp), %%rdi\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%rdi, (%%rbx)\n\t" \
- /* Manually push rbx to private stack */ \
- "addq $-8,(%%rax)\n\t" \
- "movq 8(%%rsp), %%rdi\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%rdi, (%%rbx)\n\t" \
- /* Manually push rdi to private stack */ \
- "addq $-8,(%%rax)\n\t" \
- "movq 0(%%rsp), %%rdi\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%rdi, (%%rbx)\n\t" \
- /* now push regs to tls */ \
- /* -- rsp already pushed -- */ \
- /* -- rax already pushed -- */ \
- /* -- rbx already pushed -- */ \
- /* -- rdi already pushed -- */ \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%rcx,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%rdx,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%rbp,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%rsi,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%r8,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%r9,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%r10,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%r11,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%r12,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%r13,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%r14,(%%rbx)\n\t" \
- "addq $-8,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movq %%r15,(%%rbx)\n\t" \
- /* push cs */ \
- "addq $-2,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movw %%cs, (%%rbx)\n\t" \
- /* push ss */ \
- "addq $-2,(%%rax)\n\t" \
- "movq (%%rax), %%rbx\n\t" \
- "movw %%ss, (%%rbx)\n\t" \
- /* add padding for struct registers */ \
- "addq $-4,(%%rax)\n\t" \
- /* restore original values of regs that were used internally */ \
- "popq %%rdi\n\t" \
- "popq %%rbx\n\t" \
- "popq %%rax\n\t" \
- /* cancel push of rsp */ \
- "addq $8,%%rsp\n\t" \
- /* cancel push of rflags */ \
- "addq $8,%%rsp\n\t" \
- ::); \
- memcpy(regsptr, (void *)ust_reg_stack_ptr, sizeof(struct registers)); \
- ust_reg_stack_ptr = (void *)(((long)ust_reg_stack_ptr) + sizeof(struct registers));
-
-#else /* CONFIG_UST_GDB_INTEGRATION */
-
-#define save_registers(a)
-
-#endif /* CONFIG_UST_GDB_INTEGRATION */
-
-/* Macro to insert the address of a relative jump in an assembly stub,
- * in a relocatable way. On x86-64, this uses a special (%rip) notation. */
-#define RELATIVE_ADDRESS(__rel_label__) __rel_label__(%%rip)
-
-#define ARCH_COPY_ADDR(dst) "lea 2b(%%rip)," dst "\n\t"
-
-#define _ASM_PTR ".quad "
-