リビジョン | 83b519b8a44d6b7d9b9d9763e7189061e116215d (tree) |
---|---|
日時 | 2022-01-21 14:52:57 |
作者 | LIU Zhiwei <zhiwei_liu@c-sk...> |
コミッター | Alistair Francis |
target/riscv: Adjust csr write mask with XLEN
Write mask is representing the bits we care about.
Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20220120122050.41546-11-zhiwei_liu@c-sky.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
@@ -924,7 +924,8 @@ static bool do_csrrw_i128(DisasContext *ctx, int rd, int rc, | ||
924 | 924 | |
925 | 925 | static bool trans_csrrw(DisasContext *ctx, arg_csrrw *a) |
926 | 926 | { |
927 | - if (get_xl(ctx) < MXL_RV128) { | |
927 | + RISCVMXL xl = get_xl(ctx); | |
928 | + if (xl < MXL_RV128) { | |
928 | 929 | TCGv src = get_gpr(ctx, a->rs1, EXT_NONE); |
929 | 930 | |
930 | 931 | /* |
@@ -935,7 +936,8 @@ static bool trans_csrrw(DisasContext *ctx, arg_csrrw *a) | ||
935 | 936 | return do_csrw(ctx, a->csr, src); |
936 | 937 | } |
937 | 938 | |
938 | - TCGv mask = tcg_constant_tl(-1); | |
939 | + TCGv mask = tcg_constant_tl(xl == MXL_RV32 ? UINT32_MAX : | |
940 | + (target_ulong)-1); | |
939 | 941 | return do_csrrw(ctx, a->rd, a->csr, src, mask); |
940 | 942 | } else { |
941 | 943 | TCGv srcl = get_gpr(ctx, a->rs1, EXT_NONE); |
@@ -1013,7 +1015,8 @@ static bool trans_csrrc(DisasContext *ctx, arg_csrrc *a) | ||
1013 | 1015 | |
1014 | 1016 | static bool trans_csrrwi(DisasContext *ctx, arg_csrrwi *a) |
1015 | 1017 | { |
1016 | - if (get_xl(ctx) < MXL_RV128) { | |
1018 | + RISCVMXL xl = get_xl(ctx); | |
1019 | + if (xl < MXL_RV128) { | |
1017 | 1020 | TCGv src = tcg_constant_tl(a->rs1); |
1018 | 1021 | |
1019 | 1022 | /* |
@@ -1024,7 +1027,8 @@ static bool trans_csrrwi(DisasContext *ctx, arg_csrrwi *a) | ||
1024 | 1027 | return do_csrw(ctx, a->csr, src); |
1025 | 1028 | } |
1026 | 1029 | |
1027 | - TCGv mask = tcg_constant_tl(-1); | |
1030 | + TCGv mask = tcg_constant_tl(xl == MXL_RV32 ? UINT32_MAX : | |
1031 | + (target_ulong)-1); | |
1028 | 1032 | return do_csrrw(ctx, a->rd, a->csr, src, mask); |
1029 | 1033 | } else { |
1030 | 1034 | TCGv src = tcg_constant_tl(a->rs1); |
@@ -50,7 +50,8 @@ target_ulong helper_csrr(CPURISCVState *env, int csr) | ||
50 | 50 | |
51 | 51 | void helper_csrw(CPURISCVState *env, int csr, target_ulong src) |
52 | 52 | { |
53 | - RISCVException ret = riscv_csrrw(env, csr, NULL, src, -1); | |
53 | + target_ulong mask = env->xl == MXL_RV32 ? UINT32_MAX : (target_ulong)-1; | |
54 | + RISCVException ret = riscv_csrrw(env, csr, NULL, src, mask); | |
54 | 55 | |
55 | 56 | if (ret != RISCV_EXCP_NONE) { |
56 | 57 | riscv_raise_exception(env, ret, GETPC()); |