Skip to content

Commit

Permalink
rseq/selftests: Add support for RISC-V
Browse files Browse the repository at this point in the history
Add support for RISC-V in the rseq selftests, which covers both
64-bit and 32-bit ISA with little endian mode.

Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
Tested-by: Eric Lin <eric.lin@sifive.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
  • Loading branch information
Vincent Chen authored and Palmer Dabbelt committed Mar 22, 2022
1 parent 93917ad commit 6d1a6f4
Show file tree
Hide file tree
Showing 3 changed files with 702 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tools/testing/selftests/rseq/param_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 6d1a6f4

Please sign in to comment.