rseq/selftests: Add support for RISC-V
[linux-2.6-microblaze.git] / tools / testing / selftests / rseq / param_test.c
index 699ad5f..0a6b8ea 100644 (file)
@@ -207,6 +207,29 @@ unsigned int yield_mod_cnt, nr_abort;
        "addiu " INJECT_ASM_REG ", -1\n\t" \
        "bnez " INJECT_ASM_REG ", 222b\n\t" \
        "333:\n\t"
+#elif defined(__riscv)
+
+#define RSEQ_INJECT_INPUT \
+       , [loop_cnt_1]"m"(loop_cnt[1]) \
+       , [loop_cnt_2]"m"(loop_cnt[2]) \
+       , [loop_cnt_3]"m"(loop_cnt[3]) \
+       , [loop_cnt_4]"m"(loop_cnt[4]) \
+       , [loop_cnt_5]"m"(loop_cnt[5]) \
+       , [loop_cnt_6]"m"(loop_cnt[6])
+
+#define INJECT_ASM_REG "t1"
+
+#define RSEQ_INJECT_CLOBBER \
+       , INJECT_ASM_REG
+
+#define RSEQ_INJECT_ASM(n)                                     \
+       "lw " INJECT_ASM_REG ", %[loop_cnt_" #n "]\n\t"         \
+       "beqz " INJECT_ASM_REG ", 333f\n\t"                     \
+       "222:\n\t"                                              \
+       "addi  " INJECT_ASM_REG "," INJECT_ASM_REG ", -1\n\t"   \
+       "bnez " INJECT_ASM_REG ", 222b\n\t"                     \
+       "333:\n\t"
+
 
 #else
 #error unsupported target