From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: mark.cave-ayland@ilande.co.uk, atar4qemu@gmail.com
Subject: [PATCH v2 3/7] target/sparc: Loosen decode of RDY for v7
Date: Fri, 5 Sep 2025 13:51:24 +0200 [thread overview]
Message-ID: <20250905115128.376295-4-richard.henderson@linaro.org> (raw)
In-Reply-To: <20250905115128.376295-1-richard.henderson@linaro.org>
Bits [18:0] are not decoded with v7, and for v8 unused values
of rs1 simply produce undefined results.
Fixes: af25071c1d ("target/sparc: Move RDASR, STBAR, MEMBAR to decodetree")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
target/sparc/translate.c | 14 ++------------
target/sparc/insns.decode | 12 ++++++++++--
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
index ece393fffc..cfdd9c1ce4 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -2863,18 +2863,8 @@ static TCGv do_rdy(DisasContext *dc, TCGv dst)
return cpu_y;
}
-static bool trans_RDY(DisasContext *dc, arg_RDY *a)
-{
- /*
- * TODO: Need a feature bit for sparcv8. In the meantime, treat all
- * 32-bit cpus like sparcv7, which ignores the rs1 field.
- * This matches after all other ASR, so Leon3 Asr17 is handled first.
- */
- if (avail_64(dc) && a->rs1 != 0) {
- return false;
- }
- return do_rd_special(dc, true, a->rd, do_rdy);
-}
+TRANS(RDY_v7, 32, do_rd_special, true, a->rd, do_rdy)
+TRANS(RDY_v9, 64, do_rd_special, true, a->rd, do_rdy)
static TCGv do_rd_leon3_config(DisasContext *dc, TCGv dst)
{
diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode
index 1b1b85e9c2..74848996ae 100644
--- a/target/sparc/insns.decode
+++ b/target/sparc/insns.decode
@@ -91,6 +91,7 @@ CALL 01 i:s30
STBAR_v9 10 00000 101000 01111 0 0000000000000
MEMBAR 10 00000 101000 01111 1 000000 cmask:3 mmask:4
+ RDY_v9 10 rd:5 101000 00000 0 0000000000000
RDCCR 10 rd:5 101000 00010 0 0000000000000
RDASI 10 rd:5 101000 00011 0 0000000000000
RDTICK 10 rd:5 101000 00100 0 0000000000000
@@ -118,8 +119,15 @@ CALL 01 i:s30
# This confirms that bit 13 is ignored, as 0x8143c000 is STBAR.
STBAR_v8 10 ----- 101000 01111 - -------------
- # Before v8, all rs1 accepted; otherwise rs1==0.
- RDY 10 rd:5 101000 rs1:5 0 0000000000000
+ # For v7, bits [18:0] are ignored.
+ # For v8, bits [18:14], aka rs1, are repurposed and rs1 = 0 is RDY,
+ # and other values are RDASR. However, the v8 manual explicitly
+ # says that rs1 in 1..14 yield undefined results and do not cause
+ # an illegal instruction trap, and rs1 in 16..31 are available for
+ # implementation specific usage.
+ # Implement not causing an illegal instruction trap for v8 by
+ # continuing to interpret unused values per v7, i.e. as RDY.
+ RDY_v7 10 rd:5 101000 ----- - -------------
}
{
--
2.43.0
next prev parent reply other threads:[~2025-09-05 11:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 11:51 [PATCH v2 0/7] target/sparc: Relax some decode for v7/v8 Richard Henderson
2025-09-05 11:51 ` [PATCH v2 1/7] target/sparc: Allow TRANS macro with no extra arguments Richard Henderson
2025-09-17 20:23 ` Mark Cave-Ayland
2025-09-05 11:51 ` [PATCH v2 2/7] target/sparc: Loosen decode of STBAR for v8 Richard Henderson
2025-09-05 11:51 ` Richard Henderson [this message]
2025-09-05 11:51 ` [PATCH v2 4/7] target/sparc: Loosen decode of RDPSR for v7 Richard Henderson
2025-09-17 20:26 ` Mark Cave-Ayland
2025-09-05 11:51 ` [PATCH v2 5/7] target/sparc: Loosen decode of RDWIM " Richard Henderson
2025-09-17 20:28 ` Mark Cave-Ayland
2025-09-05 11:51 ` [PATCH v2 6/7] target/sparc: Loosen decode of RDTBR " Richard Henderson
2025-09-17 20:29 ` Mark Cave-Ayland
2025-09-05 11:51 ` [PATCH v2 7/7] target/sparc: Relax decode of rs2_or_imm " Richard Henderson
2025-09-17 20:42 ` Mark Cave-Ayland
2025-09-17 22:23 ` Richard Henderson
2025-09-24 20:25 ` [PATCH v2 0/7] target/sparc: Relax some decode for v7/v8 Michael Tokarev
2025-09-24 21:25 ` Richard Henderson
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=20250905115128.376295-4-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=atar4qemu@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=qemu-devel@nongnu.org \
/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).