Skip to content

Commit 5e54b43

Browse files
romanherosalistair23
authored andcommitted
target/riscv: Relax fld alignment requirement
According to the risc-v specification: "FLD and FSD are only guaranteed to execute atomically if the effective address is naturally aligned and XLEN≥64." We currently implement fld as MO_ATOM_IFALIGN when XLEN < 64, which does not violate the rules. But it will hide some problems. So relax it to MO_ATOM_NONE. Signed-off-by: LIU Zhiwei <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-ID: <[email protected]> Signed-off-by: Alistair Francis <[email protected]>
1 parent 30d2414 commit 5e54b43

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

target/riscv/insn_trans/trans_rvd.c.inc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,17 @@ static bool trans_fld(DisasContext *ctx, arg_fld *a)
4848
REQUIRE_EXT(ctx, RVD);
4949

5050
/*
51-
* Zama16b applies to loads and stores of no more than MXLEN bits defined
52-
* in the F, D, and Q extensions.
51+
* FLD and FSD are only guaranteed to execute atomically if the effective
52+
* address is naturally aligned and XLEN≥64. Also, zama16b applies to
53+
* loads and stores of no more than MXLEN bits defined in the F, D, and
54+
* Q extensions.
5355
*/
54-
if ((get_xl_max(ctx) >= MXL_RV64) && ctx->cfg_ptr->ext_zama16b) {
56+
if (get_xl_max(ctx) == MXL_RV32) {
57+
memop |= MO_ATOM_NONE;
58+
} else if (ctx->cfg_ptr->ext_zama16b) {
5559
memop |= MO_ATOM_WITHIN16;
60+
} else {
61+
memop |= MO_ATOM_IFALIGN;
5662
}
5763

5864
decode_save_opc(ctx);
@@ -71,8 +77,12 @@ static bool trans_fsd(DisasContext *ctx, arg_fsd *a)
7177
REQUIRE_FPU;
7278
REQUIRE_EXT(ctx, RVD);
7379

74-
if ((get_xl_max(ctx) >= MXL_RV64) && ctx->cfg_ptr->ext_zama16b) {
80+
if (get_xl_max(ctx) == MXL_RV32) {
81+
memop |= MO_ATOM_NONE;
82+
} else if (ctx->cfg_ptr->ext_zama16b) {
7583
memop |= MO_ATOM_WITHIN16;
84+
} else {
85+
memop |= MO_ATOM_IFALIGN;
7686
}
7787

7888
decode_save_opc(ctx);

0 commit comments

Comments
 (0)