Skip to content

Commit fb1be88

Browse files
alistair23Michael Tokarev
authored andcommitted
target/riscv: rvzicbo: Fixup CBO extension register calculation
When running the instruction ``` cbo.flush 0(x0) ``` QEMU would segfault. The issue was in cpu_gpr[a->rs1] as QEMU does not have cpu_gpr[0] allocated. In order to fix this let's use the existing get_address() helper. This also has the benefit of performing pointer mask calculations on the address specified in rs1. The pointer masking specificiation specifically states: """ Cache Management Operations: All instructions in Zicbom, Zicbop and Zicboz """ So this is the correct behaviour and we previously have been incorrectly not masking the address. Signed-off-by: Alistair Francis <[email protected]> Reported-by: Fabian Thomas <[email protected]> Fixes: e05da09 ("target/riscv: implement Zicbom extension") Reviewed-by: Richard Henderson <[email protected]> Cc: qemu-stable <[email protected]> Message-ID: <[email protected]> Signed-off-by: Alistair Francis <[email protected]> (cherry picked from commit c5eb8d6) Signed-off-by: Michael Tokarev <[email protected]>
1 parent a58758c commit fb1be88

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

target/riscv/insn_trans/trans_rvzicbo.c.inc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,35 @@
3131
static bool trans_cbo_clean(DisasContext *ctx, arg_cbo_clean *a)
3232
{
3333
REQUIRE_ZICBOM(ctx);
34-
gen_helper_cbo_clean_flush(tcg_env, cpu_gpr[a->rs1]);
34+
TCGv src = get_address(ctx, a->rs1, 0);
35+
36+
gen_helper_cbo_clean_flush(tcg_env, src);
3537
return true;
3638
}
3739

3840
static bool trans_cbo_flush(DisasContext *ctx, arg_cbo_flush *a)
3941
{
4042
REQUIRE_ZICBOM(ctx);
41-
gen_helper_cbo_clean_flush(tcg_env, cpu_gpr[a->rs1]);
43+
TCGv src = get_address(ctx, a->rs1, 0);
44+
45+
gen_helper_cbo_clean_flush(tcg_env, src);
4246
return true;
4347
}
4448

4549
static bool trans_cbo_inval(DisasContext *ctx, arg_cbo_inval *a)
4650
{
4751
REQUIRE_ZICBOM(ctx);
48-
gen_helper_cbo_inval(tcg_env, cpu_gpr[a->rs1]);
52+
TCGv src = get_address(ctx, a->rs1, 0);
53+
54+
gen_helper_cbo_inval(tcg_env, src);
4955
return true;
5056
}
5157

5258
static bool trans_cbo_zero(DisasContext *ctx, arg_cbo_zero *a)
5359
{
5460
REQUIRE_ZICBOZ(ctx);
55-
gen_helper_cbo_zero(tcg_env, cpu_gpr[a->rs1]);
61+
TCGv src = get_address(ctx, a->rs1, 0);
62+
63+
gen_helper_cbo_zero(tcg_env, src);
5664
return true;
5765
}

0 commit comments

Comments
 (0)