From: Richard Henderson <richard.henderson@linaro.org>
To: Roan Richmond <roan.richmond@codethink.co.uk>, qemu-riscv@nongnu.org
Cc: palmer@dabbelt.com, alistair.francis@wdc.com,
liwei1518@gmail.com, dbarboza@ventanamicro.com,
zhiwei_liu@linux.alibaba.com, qemu-devel@nongnu.org,
alistair23@gmail.com
Subject: Re: [PATCH v2] Add RISCV Zilsd extension
Date: Thu, 13 Nov 2025 11:54:22 +0100 [thread overview]
Message-ID: <ad83714b-ee19-4c0b-a230-2fd078a7dece@linaro.org> (raw)
In-Reply-To: <20251110090510.84103-1-roan.richmond@codethink.co.uk>
On 11/10/25 10:05, Roan Richmond wrote:
> +/* Zilsd extension adds load/store double for 32bit arch */
> +static bool gen_store_zilsd(DisasContext *ctx, arg_sb *a)
> +{
> + TCGv data_1 = tcg_temp_new();
> + TCGv data_2 = tcg_temp_new();
> + if (a->rs2 != 0) {
> + data_1 = get_gpr(ctx, a->rs2, EXT_NONE);
> + data_2 = get_gpr(ctx, a->rs2+1, EXT_NONE);
> + }
> + TCGv addr_1 = get_address(ctx, a->rs1, a->imm);
> + TCGv addr_2 = get_address(ctx, a->rs1, a->imm+4);
> +
> + if (ctx->ztso) {
> + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL);
> + }
> +
> + tcg_gen_qemu_st_tl(data_1, addr_1, ctx->mem_idx, MO_SL);
> + tcg_gen_qemu_st_tl(data_2, addr_2, ctx->mem_idx, MO_SL);
This is wrong, because if rs2 == 0, then data_1 and data_2 are uninitialized. If you're
testing properly with --enable-debug-tcg, this should trigger an assertion failure.
You wanted
if (a->rs2 == 0) {
data_1 = tcg_constant_tl(0);
data_2 = data_1;
} else {
data_1 = get_gpr(ctx, a->rs2, EXT_NONE);
data_2 = get_gpr(ctx, a->rs2 + 1, EXT_NONE);
}
You're also missing the endianness indicator: mo_endian().
You really should consider combining the two halves so that you can perform one 64-bit
store. While I see that the spec allows the store to be non-atomic, you still probably do
not want to to allow the first half store to succeed when the second half store faults. I
don't see clear language about that. Anyway, that's as simple as
TCGv_i64 data;
MemOp end = mo_endian(ctx);
if (a->rs2 == 0) {
data = tcg_constant_i64(0);
} else {
TCGv data_1 = get_gpr(ctx, a->rs2, EXT_NONE);
TCGv data_2 = get_gpr(ctx, a->rs2 + 1, EXT_NONE);
data = tcg_temp_new_i64();
if (end == MO_LE) {
tcg_gen_concat_tl_i64(data, data_1, data_2);
} else {
tcg_gen_concat_tl_i64(data, data_2, data_1);
}
}
tcg_gen_qemu_st_i64(data, addr, ctx->mem_idx, MO_UQ | end);
r~
prev parent reply other threads:[~2025-11-13 10:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 9:05 [PATCH v2] Add RISCV Zilsd extension Roan Richmond
2025-11-12 1:41 ` Alistair Francis
2025-11-13 8:53 ` Roan Richmond
2025-11-21 7:41 ` Philippe Mathieu-Daudé
2025-11-13 10:54 ` Richard Henderson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad83714b-ee19-4c0b-a230-2fd078a7dece@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=dbarboza@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=roan.richmond@codethink.co.uk \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).