Skip to content

Commit 46b0cb9

Browse files
committed
CHERI-RISC-V: as-user cap-auth cap store-cond
1 parent d4407c7 commit 46b0cb9

5 files changed

Lines changed: 15 additions & 0 deletions

File tree

target/riscv/helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ DEF_HELPER_3(lr_c_u_cap, void, env, i32, i32)
7878
DEF_HELPER_3(sc_c_modedep, tl, env, i32, i32)
7979
DEF_HELPER_3(sc_c_ddc, tl, env, i32, i32)
8080
DEF_HELPER_3(sc_c_cap, tl, env, i32, i32)
81+
DEF_HELPER_3(sc_c_u_cap, tl, env, i32, i32)
8182
#endif
8283

8384
#ifdef CONFIG_TCG_LOG_INSTR

target/riscv/insn32-cheri-32.decode

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ amoswap_c 00001 . . ..... ..... 011 ..... 0101111 @atom_st
5555
ld_c_u_cap 1111001 01011 ..... 000 ..... 1011011 @r2 # This is ld_d_u_cap (8-byte load) for RV64
5656
lr_c_u_cap 1111001 11011 ..... 000 ..... 1011011 @atom_ld_cap_or_ddc # This is lr_d_u_cap for RV64
5757
st_c_u_cap 1111000 ..... ..... 000 01011 1011011 @r_2source # This is st_d_u_cap (8-byte store) for RV64
58+
sc_c_u_cap 1111000 ..... ..... 000 11011 1011011 @atom_st_cap_or_ddc # This is sc_d_u_cap for RV64

target/riscv/insn32-cheri-64.decode

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ ld_c_u_cap 1111001 11111 ..... 000 ..... 1011011 @r2 # Would be ld_q_cap for
6969
st_d_u_cap 1111000 ..... ..... 000 01011 1011011 @r_2source # This is st_c_cap (capability store) for RV32
7070
st_c_u_cap 1111000 ..... ..... 000 01100 1011011 @r_2source # Would be st_q_cap for RV128
7171
sc_d_u_cap 1111000 ..... ..... 000 11011 1011011 @atom_st_cap_or_ddc # RV64-only (sc_c_cap for RV32)
72+
sc_c_u_cap 1111000 ..... ..... 000 11100 1011011 @atom_st_cap_or_ddc # RV64-only (would be sc_q_cap for RV128)

target/riscv/insn_trans/trans_cheri.c.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,12 @@ static inline bool trans_sc_c_cap(DisasContext *ctx, arg_sc_c_cap *a)
603603
return trans_sc_c_impl(ctx, a, &gen_helper_sc_c_cap);
604604
}
605605

606+
static inline bool trans_sc_c_u_cap(DisasContext *ctx, arg_sc_c_u_cap *a)
607+
{
608+
a->rd = a->rs2; /* Not enough encoding space for explicit rd */
609+
return trans_sc_c_impl(ctx, a, &gen_helper_sc_c_u_cap);
610+
}
611+
606612
static inline bool trans_amoswap_c(DisasContext *ctx, arg_amoswap_c *a)
607613
{
608614
REQUIRE_EXT(ctx, RVA);

target/riscv/op_helper_cheri.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,9 @@ target_ulong HELPER(sc_c_cap)(CPUArchState *env, uint32_t addr_reg, uint32_t val
466466
return sc_c_impl(env, addr_reg, val_reg, /*offset=*/0,
467467
cpu_mmu_index(env, false), GETPC());
468468
}
469+
470+
target_ulong HELPER(sc_c_u_cap)(CPUArchState *env, uint32_t addr_reg, uint32_t val_reg)
471+
{
472+
return sc_c_impl(env, addr_reg, val_reg, /*offset=*/0, MMU_USER_IDX,
473+
GETPC());
474+
}

0 commit comments

Comments
 (0)