From: Rishab Pradeep <rishab@rispop.dev>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, palmer@dabbelt.com,
alistair.francis@wdc.com, liwei1518@gmail.com,
daniel.barboza@oss.qualcomm.com, zhiwei_liu@linux.alibaba.com,
chao.liu@processmission.com, Rishab Pradeep <rishab@rispop.dev>,
Tarun Patanjali <tarun.patanjali@utexas.edu>,
Christopher Elwood <christopher.elwood2024@gmail.com>
Subject: [PATCH 1/2] target/riscv: apply pointer masking to flh/fsh
Date: Fri, 4 Dec 2026 14:17:31 -0600 [thread overview]
Message-ID: <20261204201732.254081-2-rishab@rispop.dev> (raw)
In-Reply-To: <20261204201732.254081-1-rishab@rispop.dev>
trans_flh() and trans_fsh() used the base register directly as the
effective address, without get_address(), so with pointer masking
enabled a tagged pointer was used unmasked and raised an access
fault.
Use get_address(), as flw/fsw and fld/fsd do, so the mask is applied
to every explicit memory access.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4967
Co-developed-by: Tarun Patanjali <tarun.patanjali@utexas.edu>
Signed-off-by: Tarun Patanjali <tarun.patanjali@utexas.edu>
Co-developed-by: Christopher Elwood <christopher.elwood2024@gmail.com>
Signed-off-by: Christopher Elwood <christopher.elwood2024@gmail.com>
Signed-off-by: Rishab Pradeep <rishab@rispop.dev>
---
target/riscv/tcg/insn_trans/trans_rvzfh.c.inc | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/target/riscv/tcg/insn_trans/trans_rvzfh.c.inc b/target/riscv/tcg/insn_trans/trans_rvzfh.c.inc
index 4af717ce54..229299ad2b 100644
--- a/target/riscv/tcg/insn_trans/trans_rvzfh.c.inc
+++ b/target/riscv/tcg/insn_trans/trans_rvzfh.c.inc
@@ -54,12 +54,7 @@ static bool trans_flh(DisasContext *ctx, arg_flh *a)
memop |= MO_ALIGN;
}
decode_save_opc(ctx, 0);
- t0 = get_gpr(ctx, a->rs1, EXT_NONE);
- if (a->imm) {
- TCGv temp = tcg_temp_new();
- tcg_gen_addi_tl(temp, t0, a->imm);
- t0 = temp;
- }
+ t0 = get_address(ctx, a->rs1, a->imm);
dest = cpu_fpr[a->rd];
tcg_gen_qemu_ld_i64(dest, t0, ctx->mem_idx, memop);
@@ -82,12 +77,7 @@ static bool trans_fsh(DisasContext *ctx, arg_fsh *a)
memop |= MO_ALIGN;
}
decode_save_opc(ctx, 0);
- t0 = get_gpr(ctx, a->rs1, EXT_NONE);
- if (a->imm) {
- TCGv temp = tcg_temp_new();
- tcg_gen_addi_tl(temp, t0, a->imm);
- t0 = temp;
- }
+ t0 = get_address(ctx, a->rs1, a->imm);
tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], t0, ctx->mem_idx, memop);
--
2.56.0
next prev parent reply other threads:[~2026-12-04 20:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 20:17 [PATCH 0/2] target/riscv: apply pointer masking to flh/fsh and Zcmp push/pop Rishab Pradeep
2026-12-04 20:17 ` Rishab Pradeep [this message]
2026-12-04 20:17 ` [PATCH 2/2] target/riscv: apply pointer masking to " Rishab Pradeep
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=20261204201732.254081-2-rishab@rispop.dev \
--to=rishab@rispop.dev \
--cc=alistair.francis@wdc.com \
--cc=chao.liu@processmission.com \
--cc=christopher.elwood2024@gmail.com \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=tarun.patanjali@utexas.edu \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.