, INJECT_ASM_REG
/*
- * "mov asm_loop_cnt_" #n ", %%" INJECT_ASM_REG "\n\t" causes the
- * following linker warning:
- *
- * /usr/bin/ld: param_test.o: warning: relocation in read-only section `.text'
- * /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
+ * Use ip-relative addressing to get the loop counter.
*/
-#define RSEQ_INJECT_ASM(n) \
- "mov asm_loop_cnt_" #n ", %%" INJECT_ASM_REG "\n\t" \
+#define __RSEQ_INJECT_ASM(n, ref_ip, ref_label) \
+ "movl " __rseq_str(ref_ip) ", %%" INJECT_ASM_REG "\n\t" \
+ "leal ( asm_loop_cnt_" #n " - " __rseq_str(ref_label) "b)(%%" INJECT_ASM_REG "), %%" INJECT_ASM_REG "\n\t" \
+ "movl (%%" INJECT_ASM_REG "), %%" INJECT_ASM_REG "\n\t" \
"test %%" INJECT_ASM_REG ",%%" INJECT_ASM_REG "\n\t" \
"jz 333f\n\t" \
"222:\n\t" \
"jnz 222b\n\t" \
"333:\n\t"
+#define RSEQ_INJECT_ASM(n) \
+ __RSEQ_INJECT_ASM(n, %[ref_ip], RSEQ_ASM_REF_LABEL)
+
#elif defined(__x86_64__)
#define INJECT_ASM_REG_P "rax"
/* Test MEMBARRIER_CMD_PRIVATE_RESTART_RSEQ_ON_CPU membarrier command. */
#ifdef TEST_MEMBARRIER
struct test_membarrier_thread_args {
+ struct rseq_percpu_pool *mempool;
struct percpu_list __rseq_percpu *percpu_list_ptr;
int stop;
};
do {
int cpu = get_current_cpu_id();
- struct percpu_list __rseq_percpu *list = RSEQ_READ_ONCE(args->percpu_list_ptr);
- struct percpu_list *cpulist = rseq_percpu_ptr(list, cpu);
+ ptrdiff_t mempool_offset = rseq_percpu_pool_ptr_offset(args->mempool, cpu);
- ret = rseq_load_cbne_load_add_store__ptr(RSEQ_MO_RELAXED, RSEQ_PERCPU,
- (intptr_t *) &args->percpu_list_ptr, (intptr_t) list,
- &cpulist->head->data, 1, cpu);
+ ret = rseq_load_add_load_load_add_store__ptr(RSEQ_MO_RELAXED, RSEQ_PERCPU,
+ (intptr_t *) &args->percpu_list_ptr,
+ mempool_offset + offsetof(struct percpu_list, head),
+ 1, cpu);
} while (rseq_unlikely(ret));
}
perror("rseq_percpu_pool_create");
abort();
}
+ args->mempool = mempool;
if (rseq_register_current_thread()) {
fprintf(stderr, "Error: rseq_register_current_thread(...) failed(%d): %s\n",